Implement TSimpleJSON Protocol

Summary: This is an implementation of the TSimpleJSONProtocol for Haskell.  This code will allow Haskell services to communicate with other services using Thrift and JSON serialization

Test Plan: fbconfig -r thirft/lib/hs && fbmake runtests_dev

Reviewed By: bnitka@fb.com

Subscribers: alandau, bmatheny, jcoens, davejwatson

FB internal diff: D1435164

Tasks: 4413836
Handle the case when starting a thread fails

Summary: Before, the counters were incremented incorrectly. If ->start() threw, the object would be left in a bad state. Destroying this object would reslult in a deadlock.

Test Plan: Made sure the repro D1440067 no longer works with this fix

Reviewed By: mshneer@fb.com

Subscribers: alandau, bmatheny, srenfro, wstefancik

FB internal diff: D1440244

Tasks: 4494943
Revert "[ThreadManager] Handle the case when starting a thread fails"

Summary: This reverts commit cbb4eefda32431bfa2892ef403e5c152a8773862.

Test Plan: None

Reviewed By: mshneer@fb.com

Subscribers: alandau, bmatheny

FB internal diff: D1440563
Benchmarks for CompactProtocol.

Summary: [Thrift] Benchmarks for CompactProtocol.

Test Plan: Build and run the benchmarks.

Reviewed By: marccelani@fb.com

Subscribers: scottstraw, chalfant, alandau, bmatheny

FB internal diff: D1439898
Benchmarks for CompactProtocol.

Summary:
[Thrift] Benchmarks for CompactProtocol.

This one is for cpp2.

Test Plan: Build and run the benchmarks.

Reviewed By: marccelani@fb.com

Subscribers: alandau, bmatheny, chalfant, scottstraw

FB internal diff: D1441164
CompactProtocolReader can skip some unnecessary mallocs.

Summary:
[Thrift] CompactProtocolReader can skip some unnecessary mallocs.

An instance of this class is constructed inline for each call to cpp2 recv. This class needs a `std::stack`, which by default is implemented on top of a `std::deque` (double-ended queue), which keeps two dynamically-allocated sentinel nodes at all times and therefore always requires at least two mallocs and two frees per instance. However: we can switch from deque to fbvector, which for small reservations requires no mallocs at all.

Test Plan: Continuous build.

Reviewed By: marccelani@fb.com

Subscribers: jaredg, alandau, bmatheny, chalfant, scottstraw, dougw

FB internal diff: D1434099
For typedef, support generating equal and hash_to declaration

Summary:
we use typedef'ed type as the key of unordered map. So thrift
generator needs to generate declaration for hash and equal_to.
E.g. The following thrift def fails to compile:
typedef map<string, string> StringMap
map<StringMap, string> (cpp.template="unordered_map") anotherMap;
With this diff, the following line makes generator work:
typedef map<string, string> (cpp.generate_hash, cpp.generate_equal_to) StringMap

Test Plan: compiled our thrift files with the new feature.

Reviewed By: andrewcox@fb.com

Subscribers: ruibalp, zeus-diffs@, vikas, zhguo, alandau, jying

FB internal diff: D1421833
Handle the case when starting a thread fails -- attempt 2

Summary: In the first diff the idle count was incremented after start(). Turns out the thread manager expects idle count to be > 0 when the threads start running. In this diff I attempt to remove this race.

Test Plan:
Unit tests
ldbrandy's repro diff

Reviewed By: mshneer@fb.com

Subscribers: alandau, bmatheny, wstefancik

FB internal diff: D1440739

Tasks: 4494943
Remove MonadIO

Summary: MonadIO didn't end up adding useful functionality to the Thrift code, so I changed the type signatures back to `IO` and removed all occurences of `liftIO`

Test Plan: fbconfig -r thrift/lib/hs && fbmake runtests_dev

Reviewed By: bnitka@fb.com

Subscribers: alandau, bmatheny, jcoens, davejwatson

FB internal diff: D1441343
Change Thrift codegen to work with dmd 2.065

Summary: In 2.065 the D front-end became more trigger-happy about detecting recursive instantiation of templates, so this diff special-cases two more functions. The question remains open whether this is an insufficiency in introspection or a misapplication thereof.

Test Plan: built it, ran it, became a part of it

Reviewed By: davidsp@fb.com, simpkins@fb.com

Subscribers: alandau, bmatheny

FB internal diff: D1443169

Tasks: 4503363
Update swift examples to latest releases

Summary: These examples were on swift 0.10.0 and we're now on swift 0.13.x. It's way past time they got updated.

Test Plan: built & ran each example to make sure it works as expected

Reviewed By: haijunz@fb.com

Subscribers: doug, andrewcox, alandau

FB internal diff: D1445559
Unit tests for failures when starting a thread

Summary: See title. This turned out to be more complicated that I thought (to stub out a method). @mshneer's solution may be a bit less code changes.

Test Plan: Unit test

Reviewed By: mshneer@fb.com

Subscribers: davejwatson, alandau, bmatheny, mshneer, wstefancik

FB internal diff: D1442941

Tasks: 4540057
Fixing required fields

Summary: Fixing dumb compilation erros with Required fields, enabling more required field implementation specializations

Test Plan: Build

Reviewed By: philipp@fb.com

Subscribers: ruibalp, alandau, bmatheny

FB internal diff: D1446554
Adapter channel

Summary: If you use header protocol, we could use  under the covers and adapt the interface. This does that.

Test Plan: set flags to true and tested existing tests, which include header XDC calls.

Reviewed By: mshneer@fb.com

Subscribers: claudiu, mcduff, marccelani, hitesh, mshneer, alandau, bmatheny

FB internal diff: D1441091
Truncate before doing zigzag encoding in compact protocol

Summary: If a float number is passed for an integer, TCompactProtocol just accepts it and tries to zigzag encode it and this will fail. Trucate a number to integer before encoding it.

Test Plan: Use header client in ods_router_thrift_client.py. appops/tools/irc_stat_grabber.lpar won't fail with this change

Reviewed By: cgthayer@fb.com

Subscribers: ruibalp, alandau, bmatheny

FB internal diff: D1448084

Blame Revision: D1447965
Fix Non-Optional Fields in Structs

Summary: Non-optional fields in Thrift structs were defined with `Maybe` types.  This doesn't make sense and makes the code ugly and hard to use, so I changed the Thrift Compiler to only use `Maybe` types for optional fields

Test Plan: fbconfig -r thrift/lib/hs && fbmake runtests_dev

Reviewed By: smarlow@fb.com

Subscribers: simpkins, agallagher, alandau, bmatheny, jcoens, davejwatson

FB internal diff: D1443624

Tasks: 4724976
Add Support for Default Values

Summary: The Thrift Compiler did not support filling in default values for Thrift Structs.  This code adds that functionality

Test Plan: fbconfig -r thrift/lib/hs && fbmake runtests_dev

Reviewed By: smarlow@fb.com

Subscribers: alandau, bmatheny, jcoens, davejwatson

FB internal diff: D1450508

Tasks: 4752057
Fixed contbuild_haxl_build

Summary: In case there are ambiguities in enum values, the module that an enum is imported from muct be appended to the front.  This issue arose when the default value functionality was added to the Haskell Thrift Compiler

Test Plan: fbconfig -r sigma/haxl && fbmake runtests_dev

Reviewed By: jon.coens@fb.com

Subscribers: alandau, jcoens

FB internal diff: D1452650

Tasks: 4760593
Versioning for Thrift, remove thrift/lib/cpp/config.h

Summary:
Also, regenerate thrift_config.h.

Move .gitignore to public_tld so I can add thrift_config.h while still
having it checked into fbcode.

Test Plan: fbconfig -r thrift && fbmake runtests_opt

Reviewed By: meyering@fb.com

Subscribers: alandau, bmatheny, jhj, kma, lesha

FB internal diff: D1449068
Add Integration Test for Haskell Thrift Protocols

Summary: I added an integration test for the Haskell implementation of Thrift.  This test uses the FFI to write a struct from CPP and then reads it in Haskell to check if it gets the same result.

Test Plan: fbconfig -r thrift/lib/hs && fbmake runtests_dev

Reviewed By: jon.coens@fb.com

Subscribers: alandau, bmatheny, jcoens, davejwatson

FB internal diff: D1440494

Tasks: 4723963