Last active
May 29, 2024 22:08
-
-
Save henridf/704c1c812f04a502c1c26f77a739090b to your computer and use it in GitHub Desktop.
Revisions
-
henridf revised this gist
Mar 28, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,6 +38,7 @@ message LabelMatcher { Then any of the following text snippets are valid input to `protoc --encode` #### `LabelMatcher`: ``` type: EQ name: "foo" @@ -51,7 +52,7 @@ type: EQ, name: "foo", value: "bar" ``` type: EQ;name: "foo";value: "bar" ``` (Note the absence of outer curly braces!) #### `Query`: -
henridf revised this gist
Mar 28, 2018 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,10 +54,27 @@ type: EQ;name: "foo";value: "bar" #### `Query`: ``` start_timestamp_ms: 0 end_timestamp_ms: 100 matchers: [{type: EQ; name: "bla"; value: 'val'}] ``` ``` start_timestamp_ms: 0 end_timestamp_ms: 100 matchers: [ { type: EQ name: "bla" value: 'val' } ] ``` -
henridf revised this gist
Mar 28, 2018 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,13 @@ Here are a few examples based on some quick experimentation (as opposed to looki Assume the following proto def (coming from [prometheus](https://github.com/prometheus/prometheus/blob/master/prompb/types.proto)): ```proto message Query { required int64 start_timestamp_ms = 1; required int64 end_timestamp_ms = 2; repeated prometheus.LabelMatcher matchers = 3; } message LabelMatcher { enum Type { EQ = 0; @@ -30,7 +37,7 @@ message LabelMatcher { Then any of the following text snippets are valid input to `protoc --encode` #### `LabelMatcher`: ``` type: EQ name: "foo" -
henridf revised this gist
Mar 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Here is the relevant snippet from `protoc --help`: Here are a few examples based on some quick experimentation (as opposed to looking at whatever parsing/grammar is used by protoc itself... which would probably have taken a bit more than the few minutes for the experiments below). Assume the following proto def (coming from [prometheus](https://github.com/prometheus/prometheus/blob/master/prompb/types.proto)): ```proto message LabelMatcher { -
henridf revised this gist
Mar 28, 2018 . 1 changed file with 2 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ message LabelMatcher { } ``` Then any of the following text snippets are valid input to `protoc --encode` ``` @@ -38,7 +38,7 @@ value: "bar" ``` ``` type: EQ, name: "foo", value: "bar" ``` ``` @@ -54,9 +54,3 @@ type: EQ;name: "foo";value: "bar" -
henridf revised this gist
Mar 28, 2018 . 1 changed file with 52 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,3 +8,55 @@ Here is the relevant snippet from `protoc --help`: to standard output. The message type must be defined in PROTO_FILES or their imports. ``` Here are a few examples based on some quick experimentation (as opposed to looking at whatever parsing/grammar is used by protoc itself... which would probably have taken a bit more than the few minutes for the experiments below). Assume the following proto def (coming from [prometheus](https://github.com/prometheus/prometheus/blob/master/prompb/types.proto): ```proto message LabelMatcher { enum Type { EQ = 0; NEQ = 1; RE = 2; NRE = 3; } Type type = 1; string name = 2; string value = 3; } ``` Then any of the following text is valid input to `protoc --encode` ``` type: EQ name: "foo" value: "bar" ``` ``` type: EQ,name: "foo",value: "bar" ``` ``` type: EQ;name: "foo";value: "bar" ``` -
henridf created this gist
Mar 28, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ I needed to quickly encode a protobuf from the command-line, and while I pretty much immediately came across `protoc --encode` as the obvious solution, I did not find much documentation on the input textual syntax. Here is the relevant snippet from `protoc --help`: ```text --encode=MESSAGE_TYPE Read a text-format message of the given type from standard input and write it in binary to standard output. The message type must be defined in PROTO_FILES or their imports. ```