-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[configrpc] Consider adding option wrapper on ToServer
and ToClientConn
#9480
Comments
@mx-psi can you elaborate a little more on what you'd like to see? For our type ToServerOption func() grpc.ServerOption
func MaxConcurrentStreams(n uint32) ToServerOption {
return func() grpc.ServerOption {
return grpc.MaxConcurrentStreams(n)
}
} Since I believe |
Are you thinking we add something like |
Yes, that's what I was thinking:
|
@mx-psi i am worried that this solution will mean we have to remember to update our options whenever a new grpc option comes out. If we are ever behind it will mean a grpc option exists that isn't usable with configgrpc. Is that ok? |
@TylerHelmuth We would just have just a single wrapper |
@mx-psi if we can get away with just the 1 generic wrapper that's great. Based on my brief experimentation the lack of exported fields in grpc and the need to end up with []grpc.ServerOption before calling grpc.NewServer will pose a challenge I think, but worth looking into more. |
@mx-psi we could do something like this: // toServerOptions has options that change the behavior of the gRPC server
// returned by ServerConfig.ToServer().
type toServerOptions struct {
grpcServerOptions []grpc.ServerOption
}
// ToServerOption is an option to change the behavior of the gRPC server
// returned by ServerConfig.ToServer().
type ToServerOption func(opts *toServerOptions)
func WithgRPCServerOption(opt grpc.ServerOption) ToServerOption {
return func(opts *toServerOptions) {
opts.grpcServerOptions = append(opts.grpcServerOptions, opt)
}
}
// ToServer returns a grpc.Server for the configuration
func (gss *ServerConfig) ToServer(_ context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...ToServerOption) (*grpc.Server, error) {
// this is an existing function that makes a bunch of grpc.ServerOptions based on the host/settings.
opts, err := gss.toServerOption(host, settings)
if err != nil {
return nil, err
}
tso := toServerOptions{}
for _, otp := range extraOpts {
otp(&tso)
}
opts = append(opts, tso.grpcServerOptions...)
return grpc.NewServer(opts...), nil
} Is this what you had in mind? |
This pattern conflicts with #9479 tho, but it could be made to fit the interface pattern instead. |
@TylerHelmuth Yeah, that's what I had in mind! Sorry that I wasn't very clear in the previous messages, my bad 😅 |
@legendary-acp go for it |
I'll take this one. |
This still needs removing and renaming the deprecated APIs, reopening |
#11271) #### Description `ClientConfig.ToClientConn` and `ServerConfig.ToServer` were deprecated in v0.110.0 in favor of `ClientConfig.ToClientConnWithOptions` and `ServerConfig.ToServerWithOptions` which use a more flexible option type (#11069). The original functions are now removed, and the new ones are renamed to the old names. The `WithOptions` names are kept as deprecated aliases for now. Note: The "4 lines missing coverage" are from the `WithOptions` function aliases. #### Link to tracking issue Updates #9480 #### Next steps - `collector-contrib` will need to be updated to rename uses of the `WithOptions` functions - The newly deprecated aliases will then need to be removed in the next release
open-telemetry#11271) #### Description `ClientConfig.ToClientConn` and `ServerConfig.ToServer` were deprecated in v0.110.0 in favor of `ClientConfig.ToClientConnWithOptions` and `ServerConfig.ToServerWithOptions` which use a more flexible option type (open-telemetry#11069). The original functions are now removed, and the new ones are renamed to the old names. The `WithOptions` names are kept as deprecated aliases for now. Note: The "4 lines missing coverage" are from the `WithOptions` function aliases. #### Link to tracking issue Updates open-telemetry#9480 #### Next steps - `collector-contrib` will need to be updated to rename uses of the `WithOptions` functions - The newly deprecated aliases will then need to be removed in the next release
#### Description This PR removes `ClientConfig.ToClientConnWithOptions`/`ServerConfig.ToServerWithOptions`, deprecated aliases of `ClientConfig.ToClientConn`/`ServerConfig.ToServer`, which were introduced in v0.111.0. This was part of the three step process to change the option type used by these methods (introduce new methods using the new option type and deprecate the old ones / remove old methods, rename new methods to the old names, add deprecated aliases for the new names / remove aliases). #### Link to tracking issue Fixes open-telemetry#9480
Instead of passing
grpc.ServerOption
s to each, we could pass newToServerOption
s orToClientOption
s and require wrappinggrpc.ServerOption
s into these, to make the interface more flexible and allow for other kinds of options in the future.The text was updated successfully, but these errors were encountered: