github.com/xmlking/toolkit/broker/pubsub@v0.3.4/publish_options.go (about) 1 package broker 2 3 import ( 4 "cloud.google.com/go/pubsub" 5 ) 6 7 // TODO support more pubsub.PublishSettings settings 8 type PublishOptions struct { 9 // pubsub PublishSettings 10 PublishSettings pubsub.PublishSettings 11 // publishes msg to the topic asynchronously if set to true. 12 // Default false. i.e., publishes synchronously(blocking) 13 Async bool 14 } 15 16 type PublishOption func(*PublishOptions) 17 18 func PublishAsync(b bool) PublishOption { 19 return func(o *PublishOptions) { 20 o.Async = b 21 } 22 } 23 24 func WithPublishSettings(publishSettings pubsub.PublishSettings) PublishOption { 25 return func(o *PublishOptions) { 26 o.PublishSettings = publishSettings 27 } 28 }