subscribe to container changes in Caddyfile controller

This commit is contained in:
Pavel Sviderski
2024-12-11 15:14:32 +10:00
parent 2134f3c1d9
commit 6b80ef9db8
5 changed files with 134 additions and 4 deletions
+8 -1
View File
@@ -120,7 +120,14 @@ func (s *Store) SubscribeMachines(ctx context.Context) ([]*pb.MachineInfo, <-cha
select {
case <-ctx.Done():
return
case <-events:
case _, ok := <-events:
if !ok {
// events channel has been closed.
if sub.Err() != nil {
slog.Error("Machines subscription failed.", "id", sub.ID(), "err", sub.Err())
}
return
}
// Just signal that there is a change in the machines list.
changes <- struct{}{}
}