Skip to content

Commit

Permalink
internal/remoteconfig: merge status updates together
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellzy committed Apr 12, 2023
1 parent 63d4ba5 commit bd4ec20
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/remoteconfig/remoteconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,23 @@ func (c *Client) applyUpdate(pbUpdate *clientGetConfigsResponse) error {
return nil
}
// Performs the callbacks registered and update the application status in the repository (RCTE2)
// In case of several callbacks handling the same config, statuses take precedence in this order:
// 1 - ApplyStateError
// 2 - ApplyStateUnacknowledged
// 3 - ApplyStateAcknowledged
// This makes sure that any product that would need to re-receive the config in a subsequent update will be allowed to
statuses := make(map[string]rc.ApplyStatus)
for _, fn := range c.callbacks {
for path, status := range fn(productUpdates) {
c.repository.UpdateApplyStatus(path, status)
if s, ok := statuses[path]; !ok || status.State == rc.ApplyStateError ||
s.State == rc.ApplyStateAcknowledged && status.State == rc.ApplyStateUnacknowledged {
statuses[path] = status
}
}
}
for p, s := range statuses {
c.repository.UpdateApplyStatus(p, s)
}

return nil
}
Expand Down

0 comments on commit bd4ec20

Please sign in to comment.