Skip to content

Commit e3b33c9

Browse files
committed
refactor: switch callback to use an interface
Signed-off-by: Brian Fox <[email protected]>
1 parent aacdefa commit e3b33c9

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎go/core/internal/a2a/a2a_registrar.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ type A2ARegistrar struct {
3131
sandboxA2AURL string
3232
authenticator auth.AuthProvider
3333
a2aBaseOptions []a2aclient.Option
34-
onAgentChange func(ctx context.Context)
34+
agentObserver AgentObserver
35+
}
36+
37+
type AgentObserver interface {
38+
NotifyAgentsChanged(ctx context.Context)
3539
}
3640

3741
var _ manager.Runnable = (*A2ARegistrar)(nil)
@@ -154,8 +158,8 @@ func (a *A2ARegistrar) registerAgentInformer(ctx context.Context, prototype v1al
154158
}
155159

156160
func (a *A2ARegistrar) notifyAgentChange(ctx context.Context) {
157-
if a.onAgentChange != nil {
158-
a.onAgentChange(ctx)
161+
if a.agentObserver != nil {
162+
a.agentObserver.NotifyAgentsChanged(ctx)
159163
}
160164
}
161165

‎go/core/pkg/app/app.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ func Start(getExtensionConfig GetExtensionConfig, migrationRunner MigrationRunne
639639
setupLog.Error(err, "unable to create MCP handler")
640640
os.Exit(1)
641641
}
642-
a2aRegistrar.SetAgentChangeCallback(mcpHandler.NotifyAgentsChanged)
642+
a2aRegistrar.SetAgentObserver(mcpHandler)
643643

644644
// +kubebuilder:scaffold:builder
645645
if metricsCertWatcher != nil {

0 commit comments

Comments
 (0)