-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proto: initial protobuf for config #185
Conversation
Don't put a refactor patch which refactors another patch inside the same pr. |
@laijs eh? |
I found you pr has a style-related patch and an indent patch, they are applied for an earlier patch in the same pr, it is bad, the earlier patch should be updated directly to resolve these problem. |
Oh I see, I'll flatten the indentation fixes. Not sure why that wasn't
|
To have a less source based, and more consumable example of structures, this is an initial pass at protobuf structures for the structures in the specs golang source. There is some exercise needed in platform specific structures. For the sake of example, the Makefile defaults to outputing golang source, but has a 'c' target (`make c`) for C source, a `make py` and `make all` target. This User structure does not map to the cleanliness of the current go structure, but will allow the definition to be all in one place, regardless of the host that is doing the compilation. All field rules to `optional` for now. Per vish and the docs, https://developers.google.com/protocol-buffers/docs/proto?csw=1#specifying-field-rules "! Required Is Forever" There are a couple of concessions, but is pretty much lined up. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
https://developers.google.com/protocol-buffers/docs/style?hl=en Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Let the user decide the value. opencontainers#179 (comment) Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
per opencontainers#179 (comment) Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
@laijs I squashed some and moved the indentation fixes to the initial commit |
The idea is that we use protobuf 3 JSON encodings? Update: this is what I mean by protobuf encoding: https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json |
https://github.com/google/protobuf/releases/tag/v3.0.0-beta-1 beta was only 28 days ago... |
@philips here is the output with this most recent push:
|
@vbatts The json looks good 👍 |
Now the default make target shows json output from the example.go source. Consolidated the protobuf files due to a cyclic import issue. Cleaned up outputs to source respective outputs directories. Added a `cpp` target. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
On Thu, Sep 24, 2015 at 10:21:17AM -0700, Brandon Philips wrote:
I've pushed some work along this lines to vbatts#2, which turns I've also pushed some proto2 work fleshing out Process to I'll leave it there for now, but I'm happy to help push this forward |
On Sat, Sep 26, 2015 at 01:12:07PM -0700, W. Trevor King wrote:
One way around the Any+Go issue is to use C++ instead of Go ;), so |
one approach that could work, regardless of protobuf, but could facilitate this kind of multi-platform accommodation, would be to have the canonical configuration be |
How about concept of overlaid configurations? -jojy
|
On Mon, Sep 28, 2015 at 08:30:23AM -0700, Jojy George Varghese wrote:
Previous discussion along these lines in #73, #74, and #76. My |
On Mon, Sep 28, 2015 at 07:51:04AM -0700, Vincent Batts wrote:
I don't think that works for multi-platform bundles. For example, If you're just suggesting it as a way to work around the platform.user |
Thanks for the history Trevor. If there has to be a way to "include" other configs to form a configuration "union", shouldnt there be a spec so that its uniform and unambiguous? -jojy
|
On Mon, Sep 28, 2015 at 09:48:43AM -0700, Jojy George Varghese wrote:
I think this is getting pretty off-topic for “what do we think about |
@conqer I tried this, but when importing, it added to the golang source an |
Just as an interested observer, I'd highly recommend going with proto3 syntax, the beta was only 28 days ago but it's pretty highly stable and used in production (and gRPC is really good). Some things that might help: go.pedge.io/google-protobuf - takes care of $(which protoc)/../include/google/protobuf files Let me know if I can be of help. |
* a more field out config structure * display using the jsonpb library * display the binary proto message Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
@peter-edge thanks for the pointers. |
I did this recently too: https://github.com/peter-edge/go-protoeasy |
Further updates on this protobuf. One thing that I am not entirely certain about, is the ability to have variation in the fields of a message. For example, if there is the ability to introduce new fields in a message type, such that did not conflict with prior versions of the message type. Would decoders of the prior version of the message type decode only the fields known it its version? Hopefully that question is clear enough. |
Yes, that's basically half the point of protobuf, and why a lot of people use it :) Let me see if I can find some docs to explain better. |
Actually https://developers.google.com/protocol-buffers/docs/overview explains it a little at the bottom in the "A bit of history" section. Most protocol buffer language implementations have the notion of unrecognized fields, that is fields that given the definition of a message it has, do not have matching tag numbers. When you edit a protocol buffer message, you only ever add fields, and if you do want to delete fields, the general pattern is you always use an increasing field number for new fields, to avoid ever reusing old field numbers. |
Two other things:
|
I'm increasingly of the mind that going the route of protobuf is too much a hammer-looking-for-a-nail. I think this needs a step back, to solve the actual problem of implementation independent reference and schema. |
I agree. Sent from my iPhone
|
I tend to agree. Going away from other, simple, choices like json, yml (or heck even xml) feels really odd to me. |
Just the minority opinion here: Protobufs make dev life way nicer once you figure it out. Really the auto-generation of what amount to DTO objects is enough for a huge win - once you start using them, a lot of code that would otherwise not be easy to document or would be inconsistent is suddenly just generated. Compiling etc is very easy once you understand it. |
@peter-edge I agree that code-generation is a huge plus. I tried myself and schema much more convenient than json, apart from human-readability of the ready spec itself. |
Protobufs have a lot of other wins too:
|
Another instructive example: here's the docker volume API as a protobuf service, generated to grpc and grpc-gateway golang code: https://github.com/peter-edge/go-dockervolume/blob/master/dockervolume.proto |
Closing this. The specification of the configuration file is a json schema question. Even #276 moves in this direction, by having the golang source being a reference to achieve the desired structures. See also #306 |
To have a less source based, and more consumable example of structures,
this is an initial pass at protobuf structures for the structures from all the current golang source.
There is some exercise needed in platform specific structures.
The
Makefile
defaults to golang source output, but also has ac
target for C source andpy
target for python as well.Signed-off-by: Vincent Batts vbatts@hashbangbash.com