Commit Graph

198 Commits

Author SHA1 Message Date
Preston Guillory
a35c8a723b Support file argument to thrift.generate (#59)
This gives the user more fine grained control over which .thrift files are
processed. For instance, a directory might contain many files but you only want
one or a few.
2016-11-30 13:04:44 -08:00
Preston Guillory
819216f830 Pure elixir implementation (#54)
A pure Elixir implementation of the Thrift binary protocol.

This PR includes serialization and deserialization for all thrift types as well as testing to make sure we match the thrift spec (which can be found here: https://erikvanoosten.github.io/thrift-missing-specification/#_binary_encoding)

The binary protocol is generated alongside the thrift data types, yielding a much faster implementation than the apache project's canonical one. 

Our benchmarks (using benchfella) indicate a speedup of between 10 and 20x.

## Binary Protocol Performance
benchmark name |  iterations | average time 
------------------|-----------|---------------
elixir serialization (left as IOList)                   |  2000  | 849.01 µs/op
elixir serialization (iolist_size)                        |  2000  | 933.83 µs/op
elixir serialization (converted to binary)        | 1000   | 1281.23 µs/op
elixir deserialization                                       |  1000   | 1178.46 µs/op
erlang serialization left as IOList                    |   100   | 10284.84 µs/op
erlang serialization (converted to binary)      |   100   | 11588.89 µs/op
erlang deserialization                                      |   100   | 21433.17 µs/op
2016-11-30 11:31:59 -08:00
Jon Parise
4857b40275 Preparing the 1.3.1 release 2016-11-15 16:12:35 -08:00
Jon Parise
aaa350a1e2 Minor code cleanup per credo's suggestions 2016-11-15 15:55:02 -08:00
Jon Parise
2f5dd252c6 Fix broken --gen compiler option merging
The previous code attempted to append `nil` to the `opts` list when a
user-provided `--gen` option was given.
2016-11-15 15:39:54 -08:00
Jon Parise
72966a4d82 Remove unused StructRef alias 2016-11-15 12:49:43 -08:00
Jon Parise
440df4f67b Update to credo 0.5.2 and dialyxir 0.4.0 (#34) 2016-11-10 16:32:00 -08:00
Jon Parise
b7dc23e17a Fix double-escaped {CCOMMENT} rule pattern (#33)
This pattern's literal `\` characters were unnecessarily escaped,
probably as a transcription error from the original lex source code.
This causes this pattern to misbehave and conflict with the {COMMENT}
rule.

The test suite has been extended to cover juxtapositional comment cases,
too, which ensures were correctly account for whitespace within and
around comments.
2016-11-10 16:20:30 -08:00
Steve Cohen
2eddb4e1be File Parser / Resolver (#31)
* File Parser / Resolver

The parser can now take a single thrift file and follow all its
includes and parse them as well. The output is stored in a FileGroup,
which is returned.

Added a resolver to handle resolution of struct references. As
references are added to the FileGroup, they are placed in the resolver
and after parsing is complete, added to the resolutions field in the
FileGroup.

* Fixed bad spec

* Removed dead code; increased unit test coverage

* placed __file__ directive at the end.

* Addressed PR comments

* update -> canonicalize

* Changed from using mktemp

* Fixed spelling
2016-11-10 13:21:19 -08:00
Preston Guillory
3f8002a8ad Add true/false literal to parser (#30) 2016-11-09 15:43:17 -08:00
Jon Parise
2c24bcfc04 Bump the Elixir 1.3.x version to 1.3.4 (#29) 2016-11-03 14:50:25 -07:00
Dan Swain
35ae1f1ca4 Use docker to run thrift for travis (#24) 2016-10-19 18:16:48 -07:00
Jon Parise
ef89a6fa41 Upgrade excoveralls to version 0.5.7
This fixes some compile issues with Elixir 1.3 and 1.4. It also updates
its dependencies.
2016-10-18 16:14:35 -04:00
Jon Parise
1af5b3b25d Upgrade credo to version 0.4.12
This is a very minor upgrade, but it fixes some compile-time warnings.
2016-10-18 16:10:56 -04:00
Jon Parise
abff932379 Switch to the dialyxir package (#27)
The dialyze package has been deprecated in favor of dialyxir.
2016-10-18 16:07:34 -04:00
Jon Parise
2461b842ac Allow $THRIFT to specify the thrift executable (#26)
This makes it easy to run the unit tests against alternate Thrift
compiler executables.
2016-10-18 15:42:59 -04:00
Jon Parise
58e1204577 Upgrade ex_doc and earmark to the latest versions (#25) 2016-10-18 15:30:37 -04:00
Jon Parise
601110d96c Full test coverage for Mix.Tasks.Compile.Thrift (#22)
Add test coverage for the last two remaining error cases. This brings
this module's unit test coverage up to 100%.

This also includes one functional change: we now redirect :stderr output
to :stdout so we can more consistently capture and display output from
the Thrift compiler executable.
2016-10-03 09:38:08 -07:00
Jon Parise
a8ae4d971d Update to Elixir 1.3.3 2016-09-30 09:47:30 -07:00
Jon Parise
69fffda26e Upgrade to ex_doc 1.4 2016-09-30 09:17:17 -07:00
Jon Parise
97840c95a0 Remove license appendix text 2016-09-22 08:06:09 -07:00
Jon Parise
441777efdf Prepare the 1.3.0 release (#19) 2016-09-15 07:49:55 -07:00
Jon Parise
1c3e64a947 Improve the top-level Thrift module docs (#20)
Also, update our ex_doc and earmark dependencies.
2016-09-15 07:49:14 -07:00
Jon Parise
6418e020fc Upgrade to credo 0.4.11 (#18)
No new issues were flagged as a result of this upgrade.
2016-09-14 17:00:36 -07:00
Jon Parise
4f1ba6e63b Include OTP 18.3 and 19.0 in the test matrix (#15)
Also bump Elixir 1.3.1 to 1.3.2.
2016-07-18 10:57:46 -07:00
Jon Parise
764627d171 Upgrade the test environment to Elixir 1.3.1 2016-07-11 08:57:48 -07:00
Jon Parise
284f495894 Minor variable name normalization 2016-07-09 11:20:27 -07:00
Jon Parise
d29788e73d Run the lexer and parser tests asynchronously 2016-07-09 11:04:02 -07:00
Steve Cohen
d12b22a6f5 Merge pull request #13 from pinterest/elixir-1.3
Also test using Elixir 1.3.0
2016-06-23 15:14:33 -07:00
Jon Parise
8aad91c26f Test using a predictable field order 2016-06-23 15:08:44 -07:00
Jon Parise
717a573c27 Also test using Elixir 1.3.0 2016-06-23 14:48:54 -07:00
Steve Cohen
e48808c4e5 Merge pull request #12 from scohen/make_1_2_compat
Made aliases 1.2 compliant
2016-06-21 10:22:01 -07:00
Steve Cohen
e8ce9b7b9c Made aliases 1.2 compliant 2016-06-21 09:15:35 -07:00
Jon Parise
7b495853e8 Include a Hex-based dependency example 2016-06-21 09:10:25 -07:00
Jon Parise
1003d94a09 Simplify the Travis configuration (#10)
Travis already updates our git submodules automatically, and the default
`install` and `script` commands do all of the things we need them to do.
2016-06-21 09:04:18 -07:00
Jon Parise
8c75213a59 Require at least Elixir 1.2 (#11)
With today's release of Elixir 1.3, now is a good time to drop compatibility
with much older releases. This also lets us use some of the nicer language
features introduced in Elixir 1.2, like the multi-alias syntax.
2016-06-21 08:56:00 -07:00
Jon Parise
a3f1e44845 Bump the testing matrix up to version 1.2.6 2016-06-21 08:12:01 -07:00
Jon Parise
701e4787cf Fix unsafe conditional assignments
These now produce a warning under Elixir 1.3.
2016-06-21 07:52:21 -07:00
Jon Parise
c288cbe9e6 Update to Credo 0.4.5
This change also fixes the new code readability warnings that it found.
2016-06-20 13:11:16 -07:00
Steve Cohen
996c4c6792 Merge pull request #8 from scohen/credo_clean
Credo clean
2016-06-20 09:59:56 -07:00
Steve Cohen
ed6cc3df78 Credo clean
Added module docs and fixed any credo errors
2016-06-17 10:45:31 -07:00
Jon Parise
2c83e09692 Reformat match assignments for consistency 2016-06-17 10:21:27 -07:00
Jon Parise
8fa4589443 Add Credo to the [:dev, :test] build 2016-06-17 10:19:51 -07:00
Jon Parise
c3da700d34 Simplify merge reduction work in Schema.new/2 (#7)
This approach introduces private merge/2 functions that match on the
individual model types that we want to merge into our schema. This
simplifies the top-level reduction.
2016-06-17 10:17:31 -07:00
Jon Parise
d65ce2a548 Upgrade to ex_doc 0.12.0 2016-06-17 08:33:32 -07:00
Steve Cohen
90836a2bc6 Merge pull request #6 from scohen/erlang_thrift_parser
An implementation of the Thrift parser
2016-06-14 09:05:48 -07:00
Steve Cohen
bb1c1a4dce An implementation of the Thrift parser
This PR introduces a parser based on @jparise's lexer. The parser
runs on thrift files and produces a set of Program models. The
intention is to be able to give Elixir full-fledged thrift support
and a better implementation.
2016-06-14 08:53:54 -07:00
Jon Parise
82a34c1e16 Extend lexer test coverage
- list, map, set literals
- typedefs
- enum, struct, exception, service definitions
2016-05-29 20:45:28 -07:00
Jon Parise
769d0ba289 Remove currently unused Thrift module test file 2016-05-29 20:33:29 -07:00
Jon Parise
90438d74bd Prepare version 1.2.1 2016-05-29 17:45:01 -07:00