Created
October 27, 2021 02:51
-
-
Save jayhuang75/24bbcd63de99b92c2f7da4ba6af882f8 to your computer and use it in GitHub Desktop.
go-train-delay-listen.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (l *Lister) ListenSubscription(cm chan<- *pubsub.Message, subID string) error { | |
| defer l.pubsub.Close() | |
| sub := l.pubsub.Subscription(subID) | |
| // Receive blocks until the context is cancelled or an error occurs. | |
| err := sub.Receive(l.ctx, func(ctx context.Context, msg *pubsub.Message) { | |
| log.Debugf("[ListenSubscription] Receive message from pubsub:%q\n", string(msg.Data)) | |
| cm <- msg | |
| }) | |
| if err != nil { | |
| return fmt.Errorf("Receive: %v", err) | |
| } | |
| return nil | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment