Comments (8)
I'm happy with this feature and PR for it :)
from protobuf.
As I said in #15 (comment). I want to give some ideas:
First of all, I want to give a summary about extensions and options in Protobuf:
- Only protobuf2 supports extensions, protobuf3 only supports using extension for defining options.
- Protobuf supports options in different levels(file, message, field, ...).
- Developers can use extensions to define custom options(extend
google.protobuf.*Options
).
For your PR, I think there're some problems:
- We need to split the implementations of extension and options because they're different features(in different PRs).
- The way you implement extensions is a little complex(indeed, as you said, it's difficult 😄). So, is there a better way to do that?
- Maybe we should let other projects handle custom options instead of in this lib.
For the 3rd problem(custom options), I looked into official Go implementation of protobuf and gRPC, I found it doesn't generate custom options for you. You have to use grpc-gateway
plugin to generate code by using the custom options. The idea behind it, I think, is the protobuf lib should care about official defined options. For the custom options, it's the business of other plugins. In this way, the generated can be simpler(we only have what we need to use, like rpc definitions or http definitions).
Considering it's they're really advanced features, we can discuss more before implementing them.🙂
from protobuf.
As per 1
: sorry that a lot has been pushed into this PR-- I've been using it for several projects in production.
As per 2
, happy to discuss alternative implementations. Holistically, the issue was that we needed to parse everything once to define extensions and messages, and then parse everything in a second pass to allow extensions. This works well (minus the redefining of modules) and doesn't present real issues since the process is only called on protocol generation, not once the modules are loaded by a project.
For 3
, my core question, and the one that led to this pull request is how to handle this protobuf:
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
message Http {
// A list of HTTP configuration rules that apply to individual API methods.
//
// **NOTE:** All service configuration rules follow "last one wins" order.
repeated HttpRule rules = 1;
// ...
}
For me, it's a sine qua non that a library I use has the ability to process and read from these protobufs. These are standard libraries and promoted by Google itself. Are you suggesting that we don't handle options and/or extensions at all? Again, I am happy to discuss how this is best implemented, but I think it's important that we make this library fully-featured with the official protobuf specifications.
from protobuf.
+1 for this. Looking forward to being merged!
from protobuf.
@tony612 Any thoughts on how we should handle addressing/merging this? For my usage, it's been pretty helpful. I wouldn't mind this ending up as a permanent fork (by a different name?) or looking for a way to merge. What do you think is best?
from protobuf.
@tony612 was about to start a pr to implement this also. Having options/extensions available in generated code is very useful for lots of different projects that I work on. We've been able to use these in the golang proto package to help us write libs but once I got to elixir I've had to pause until I can get access to the options.
@hayesgm wrt the code snippet at the start of this issue, would you consider the RPC/field signature to out the options map inside a keyword, keyed to :option?
from protobuf.
@tony612 Do you have any updates on support for options in protobuf-elixir?
from protobuf.
Since extension is implemented in #83 I think we can move forward to think about this again.
from protobuf.
Related Issues (20)
- How to use type specs? HOT 2
- Invalid field number 0 when decoding binary data HOT 3
- JSON decoding should work with "." in FieldMask path
- Can't create Firestore.V1.Value HOT 3
- Decoding Invalid Strings sometimes raise MatchError instead of Protobuf.DecodeError
- How to encode oneof fields? HOT 1
- The plugin one gets with "$ mix escript.install hex protobuf" seems to be old or broken HOT 2
- Let's release 1.0.0 HOT 2
- Encoding oneof attribute results in invalid struct HOT 2
- There's something wrong to get `.[...]` type
- Add option to use type_check during struct generation HOT 2
- (UndefinedFunctionError) function Protobuf.Encoder.encode/2 is undefined or private when running benchmarks HOT 1
- Error while trying to compile: google/cloud/secretmanager/v1/resources.proto HOT 1
- Any support unusable
- Consideration in generating options in Messages in OTP 26 HOT 3
- Inconsistent behaviour when encoding oneof HOT 3
- Can JSON decoder be loose on constraints about float? HOT 2
- `Protobuf.encode/1` does not actually verify struct in some cases HOT 2
- lib/elixirpb/pb_extension.pb.ex is missing in the package
- Warning on Elixir 1.16 + OTP 25 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf.