Save extensions from field options in message props#85
Save extensions from field options in message props#85artemeff wants to merge 1 commit intoelixir-protobuf:mainfrom
Conversation
dbba09c to
124b0fc
Compare
|
I'm also added handy mix task to compile proto schema: #!/bin/sh
mix protobufand run protoc like: Added config :protobuf,
extensions: :enabled,
extension_paths: ["lib/my_app/myext.pb.ex"] |
|
I feel the correct direction for plugins should be writing a separated protoc plugin and generate separated files. For example, these plugins https://github.com/envoyproxy/protoc-gen-validate & https://github.com/grpc-ecosystem/grpc-gateway work like this. And we can add some functions In this way, we have to do things in separated module, like instead of If we have to inject something into original protobuf modules, we can discuss case by case. But I prefer avoiding doing this if we can. |
124b0fc to
c8244e8
Compare
This is first step to implement plugins. Protobuf allows to declare and use custom options for fields too (currently only file options is supported), but this library omits that info, so I think neat place to put that info is
__message_props__/0:I thought a lot about how Plugins interface should looks like to support wide area of features, but I get stuck :(
In my project I have a few different types, that requires pre- and post-processing, like UUID that should be transformed from string representation to binary, or enum constants that should be converted from human readable to protobuf-acceptable (accordingly to protobuf style guide).
Keep that meta information in options looks like a solution (but it looks like workaround without plugins system), with that meta I can write Elixir's Protocol that process protobuf structs and automatically generate encoders/decoders for each struct/field.
The most important thing — this is not a duct tape for this library, my PR just add able to hold custom options :)