notification add ack and nack

This commit is contained in:
Chris Lu
2021-01-26 11:08:44 -08:00
parent 3a1d3d3413
commit ad2a20c8a5
6 changed files with 38 additions and 9 deletions

View File

@@ -85,16 +85,22 @@ func (k *GooglePubSubInput) initialize(google_application_credentials, projectId
go k.sub.Receive(ctx, func(ctx context.Context, m *pubsub.Message) {
k.messageChan <- m
m.Ack()
})
return err
}
func (k *GooglePubSubInput) ReceiveMessage() (key string, message *filer_pb.EventNotification, err error) {
func (k *GooglePubSubInput) ReceiveMessage() (key string, message *filer_pb.EventNotification, onSuccessFn func(), onFailureFn func(), err error) {
m := <-k.messageChan
onSuccessFn = func() {
m.Ack()
}
onFailureFn = func() {
m.Nack()
}
// process the message
key = m.Attributes["key"]
message = &filer_pb.EventNotification{}