MCPcopy Index your code
hub / github.com/docker/cli / watch

Method watch

cli/command/container/stats.go:386–403  ·  view source on GitHub ↗

watch ranges over the passed in event chan and processes the events based on the handlers created for a given action. To stop watching, close the event chan.

(ctx context.Context, c <-chan events.Message)

Source from the content-addressed store, hash-verified

384// handlers created for a given action.
385// To stop watching, close the event chan.
386func (eh *eventHandler) watch(ctx context.Context, c <-chan events.Message) {
387 for e := range c {
388 h, exists := eh.handlers[e.Action]
389 if !exists {
390 continue
391 }
392 if e.Actor.ID == "" {
393 log.G(ctx).WithField("event", e).Errorf("event handler: received %s event with empty ID", e.Action)
394 continue
395 }
396 logger := log.G(ctx).WithFields(log.Fields{
397 "event": e.Action,
398 "container": e.Actor.ID,
399 })
400
401 go h(log.WithLogger(ctx, logger), e)
402 }
403}

Callers 1

RunStatsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected