code: func (e *EventListener) Listen() error {
  	log := logger.New("fn", "EventListener.Listen")
  	listener, err := e.eventRepo.db.Listen("events", log)
  	if err != nil {
  		e.CloseWithError(err)
  		return err
  	}
  	go func() {
  		for {
  			select {
  			case n, ok := <-listener.Notify:
  				if !ok {
  					e.CloseWithError(listener.Err)
  					return
  				}
  				idApp := strings.SplitN(n.Payload, ":", 2)
  				if len(idApp) < 1 {
  					log.Error(fmt.Sprintf("invalid event notification: %q", n.Payload))
  					continue
  				}
  				id, err := strconv.ParseInt(idApp[0], 10, 64)
  				if err != nil {
  					log.Error(fmt.Sprintf("invalid event notification: %q", n.Payload), "err", err)
  					continue
  				}
  				event, err := e.eventRepo.GetEvent(id)
  				if err != nil {
  					log.Error(fmt.Sprintf("invalid event notification: %q", n.Payload), "err", err)
  					continue
  				}
  				e.Notify(event)
  			case <-e.doneCh:
  				listener.Close()
  				return
  			}
  		}
  	}()
  	return nil
  }
docs: // Listen creates a postgres listener for events and starts a goroutine to
  // forward the events to subscribers.