code: func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, <-chan struct{}, error) {
  	// TODO(stevvooe): Move this to a single, global event dispatch. For
  	// now, we create a connection per container.
  	var (
  		eventsq = make(chan events.Message)
  		closed  = make(chan struct{})
  	)
  
  	log.G(ctx).Debugf("waiting on events")
  	// TODO(stevvooe): For long running tasks, it is likely that we will have
  	// to restart this under failure.
  	eventCh, errCh := c.client.Events(ctx, types.EventsOptions{
  		Since:   "0",
  		Filters: c.container.eventFilter(),
  	})
  
  	go func() {
  		defer close(closed)
  
  		for {
  			select {
  			case msg := <-eventCh:
  				select {
  				case eventsq <- msg:
  				case <-ctx.Done():
  					return
  				}
  			case err := <-errCh:
  				log.G(ctx).WithError(err).Error("error from events stream")
  				return
  			case <-ctx.Done():
  				// exit
  				return
  			}
  		}
  	}()
  
  	return eventsq, closed, nil
  }
docs: // events issues a call to the events API and returns a channel with all
  // events. The stream of events can be shutdown by cancelling the context.
  //
  // A chan struct{} is returned that will be closed if the event processing
  // fails and needs to be restarted.