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

Remove OnOpampConnectionSettingsAccepted callback #266

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions client/internal/receivedprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@

if r.hasCapability(protobufs.AgentCapabilities_AgentCapabilities_AcceptsOpAMPConnectionSettings) {
err := r.callbacks.OnOpampConnectionSettings(ctx, settings.Opamp)
if err == nil {
// TODO: verify connection using new settings.
r.callbacks.OnOpampConnectionSettingsAccepted(ctx, settings.Opamp)
if err != nil {
r.logger.Errorf(ctx, "Failed to process OpAMPConnectionSettings: %v", err)

Check warning on line 214 in client/internal/receivedprocessor.go

View check run for this annotation

Codecov / codecov/patch

client/internal/receivedprocessor.go#L214

Added line #L214 was not covered by tests
}
} else {
r.logger.Debugf(ctx, "Ignoring Opamp, agent does not have AcceptsOpAMPConnectionSettings capability")
Expand Down
29 changes: 3 additions & 26 deletions client/types/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,9 @@ type Callbacks interface {
// authorization headers or TLS certificate, potentially also a different
// OpAMP destination to work with.
//
// The Agent should process the offer and return an error if the Agent does not
// want to accept the settings (e.g. if the TSL certificate in the settings
// cannot be verified).
//
// If OnOpampConnectionSettings returns nil and then the caller will
// attempt to reconnect to the OpAMP Server using the new settings.
// If the connection fails the settings will be rejected and an error will
// be reported to the Server. If the connection succeeds the new settings
// will be used by the client from that moment on.
// The Agent should process the offer by reconnecting the client using the new
// settings or return an error if the Agent does not want to accept the settings
// (e.g. if the TSL certificate in the settings cannot be verified).
//
// Only one OnOpampConnectionSettings call can be active at any time.
// See OnRemoteConfig for the behavior.
Expand All @@ -98,12 +92,6 @@ type Callbacks interface {
settings *protobufs.OpAMPConnectionSettings,
) error

// OnOpampConnectionSettingsAccepted will be called after the settings are
// verified and accepted (OnOpampConnectionSettingsOffer and connection using
// new settings succeeds). The Agent should store the settings and use them
// in the future. Old connection settings should be forgotten.
OnOpampConnectionSettingsAccepted(ctx context.Context, settings *protobufs.OpAMPConnectionSettings)

// For all methods that accept a context parameter the caller may cancel the
// context if processing takes too long. In that case the method should return
// as soon as possible with an error.
Expand Down Expand Up @@ -137,10 +125,6 @@ type CallbacksStruct struct {
ctx context.Context,
settings *protobufs.OpAMPConnectionSettings,
) error
OnOpampConnectionSettingsAcceptedFunc func(
ctx context.Context,
settings *protobufs.OpAMPConnectionSettings,
)

OnCommandFunc func(ctx context.Context, command *protobufs.ServerToAgentCommand) error

Expand Down Expand Up @@ -203,13 +187,6 @@ func (c CallbacksStruct) OnOpampConnectionSettings(
return nil
}

// OnOpampConnectionSettingsAccepted implements Callbacks.OnOpampConnectionSettingsAccepted.
func (c CallbacksStruct) OnOpampConnectionSettingsAccepted(ctx context.Context, settings *protobufs.OpAMPConnectionSettings) {
if c.OnOpampConnectionSettingsAcceptedFunc != nil {
c.OnOpampConnectionSettingsAcceptedFunc(ctx, settings)
}
}

// OnCommand implements Callbacks.OnCommand.
func (c CallbacksStruct) OnCommand(ctx context.Context, command *protobufs.ServerToAgentCommand) error {
if c.OnCommandFunc != nil {
Expand Down
Loading