Skip to content

Commit

Permalink
address comments AGain
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Feb 14, 2023
1 parent 2356d5a commit bfde4d3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/dataplane/config_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (n *ChannelConfigNotifier) SubscribeConfigStatus() chan ConfigStatus {
return n.ch
}

func NewChannelConfigNotifier(ch chan ConfigStatus) *ChannelConfigNotifier {
func NewChannelConfigNotifier() *ChannelConfigNotifier {
return &ChannelConfigNotifier{
ch: ch,
ch: make(chan ConfigStatus, 1),
}
}
2 changes: 1 addition & 1 deletion internal/dataplane/kong_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ func handleSendToClientResult(client sendconfig.KonnectAwareClient, logger logru
return newSHA, nil
}

// SetConfigStatusNotifier sets a notifier notifies configurations to subscribers
// SetConfigStatusNotifier sets a notifier which notifies subscribers about configuration sending results.
// Currently it is used for uploading the node status to konnect runtime group.
func (c *KongClient) SetConfigStatusNotifier(n ConfigStatusNotifier) {
c.lock.Lock()
Expand Down
10 changes: 6 additions & 4 deletions internal/konnect/node_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ func (a *NodeAgent) clearOutdatedNodes() error {
}

func (a *NodeAgent) subscribeConfigStatus(ctx context.Context) {
ch := a.configStatusSubscriber.SubscribeConfigStatus()
chDone := ctx.Done()

for {
select {
case <-ctx.Done():
err := ctx.Err()
a.Logger.Info("subscribe loop stopped", "message", err.Error())
case <-chDone:
a.Logger.Info("subscribe loop stopped", "message", ctx.Err().Error())
return
case configStatus := <-a.configStatusSubscriber.SubscribeConfigStatus():
case configStatus := <-ch:
a.configStatus.Store(uint32(configStatus))
}
}
Expand Down
3 changes: 1 addition & 2 deletions internal/manager/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ func Run(ctx context.Context, c *Config, diagnostic util.ConfigDumpDiagnostic, d
hostname, _ := os.Hostname()
version := metadata.Release
// set channel to send config status.
configStatusChan := make(chan dataplane.ConfigStatus, 1)
configStatusNotifier := dataplane.NewChannelConfigNotifier(configStatusChan)
configStatusNotifier := dataplane.NewChannelConfigNotifier()
dataplaneClient.SetConfigStatusNotifier(configStatusNotifier)

agent := konnect.NewNodeAgent(
Expand Down

0 comments on commit bfde4d3

Please sign in to comment.