Skip to content

Commit

Permalink
[configgrpc] Remove deprecated func, add ToServer with context (#9787)
Browse files Browse the repository at this point in the history
**Description:** 
Removes deprecated `ToServer`.
Deprecate `ToServerContext`
Add new `ToServer` with `context.Context`.

**Link to tracking Issue:** Related to
#9490

---------

Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
  • Loading branch information
TylerHelmuth and dmitryax committed Mar 20, 2024
1 parent 268cdc2 commit fc4c13d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-remove-deprecated-func.yaml
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: configgrpc

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove deprecated `ToServer` function.

# One or more tracking issues or pull requests related to the change
issues: [9787]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-remove-deprecated-func2.yaml
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: configgrpc

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecated `ToServerContext`, use `ToServer` instead.

# One or more tracking issues or pull requests related to the change
issues: [9787]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
14 changes: 7 additions & 7 deletions config/configgrpc/configgrpc.go
Expand Up @@ -269,13 +269,7 @@ func validateBalancerName(balancerName string) bool {
}

// ToServer returns a grpc.Server for the configuration
// Deprecated: [0.96.0] Use ToServerContext instead.
func (gss *ServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
return gss.ToServerContext(context.Background(), host, settings, extraOpts...)
}

// ToServerContext returns a grpc.Server for the configuration
func (gss *ServerConfig) ToServerContext(_ context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
func (gss *ServerConfig) ToServer(_ context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
opts, err := gss.toServerOption(host, settings)
if err != nil {
return nil, err
Expand All @@ -284,6 +278,12 @@ func (gss *ServerConfig) ToServerContext(_ context.Context, host component.Host,
return grpc.NewServer(opts...), nil
}

// ToServerContext returns a grpc.Server for the configuration
// Deprecated: [v0.97.0] Use ToServer instead.
func (gss *ServerConfig) ToServerContext(ctx context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
return gss.ToServer(ctx, host, settings, extraOpts...)
}

func (gss *ServerConfig) toServerOption(host component.Host, settings component.TelemetrySettings) ([]grpc.ServerOption, error) {
switch gss.NetAddr.Transport {
case confignet.TransportTypeTCP, confignet.TransportTypeTCP4, confignet.TransportTypeTCP6, confignet.TransportTypeUDP, confignet.TransportTypeUDP4, confignet.TransportTypeUDP6:
Expand Down
2 changes: 1 addition & 1 deletion config/configgrpc/configgrpc_test.go
Expand Up @@ -256,7 +256,7 @@ func TestGrpcServerAuthSettings_Deprecated(t *testing.T) {
mockID: auth.NewServer(),
},
}
srv, err := gss.ToServer(host, componenttest.NewNopTelemetrySettings())
srv, err := gss.ToServer(context.Background(), host, componenttest.NewNopTelemetrySettings())
assert.NoError(t, err)
assert.NotNil(t, srv)
}
Expand Down

0 comments on commit fc4c13d

Please sign in to comment.