Skip to content
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

Feature request: field_behavior support #800

Open
Tudyx opened this issue Jan 19, 2023 · 1 comment
Open

Feature request: field_behavior support #800

Tudyx opened this issue Jan 19, 2023 · 1 comment

Comments

@Tudyx
Copy link

Tudyx commented Jan 19, 2023

We are using tonic in a service handling user commands. These commands are used later in our business logic and have required Message field which is generated by prost as Optional as stated in the proto3 specs.

Google has a workaround for having required fields while still respecting the proto3 specs, they are using field_behavior.

The syntax looks like this.

message Foo { 
  Bar bar = 1 [(google.api.field_behavior) = REQUIRED];
}

message Bar { 
  string s = 1;
}

They are using it a lot, for instance in pubsub proto.

The idea is not to make the field optional if its "tagged" with [(google.api.field_behavior) = REQUIRED];.

Related to #521

@jwilm
Copy link

jwilm commented Oct 31, 2023

Chiming in from OneSignal - we have found that across engineering we burn a non-trivial amount of time writing conversions simply to get all of the Option handling out of our business code. It's been extensively discussed elsewhere on the issue tracker how tedious and time consuming this can be, so I'll just leave it at that.

We would love to see a mechanism for the code gen to obviate the need for this Option-eliminating boilerplate that comes with every new RPC endpoint. The field_behavior attributes are generally a great solution to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants