Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Helper ¶
type Helper[T any] struct { // contains filtered or unexported fields }
Helper assists in creating event handlers for Pub/Sub with multiple topics.
func NewHelperWithOptions ¶
func NewHelperWithOptions[T any](client *pubsub.Client, handler function.Handler[T], options *Options) *Helper[T]
NewHelperWithOptions returns a new Helper with custom options.
func (*Helper[T]) Run ¶ added in v1.6.2
Run receives the messages of every subscription concurrently until ctx is done. Then it pulls no new message, waits for the handlers to finish the ones they hold, and returns. When a subscription cannot be received, for instance because it does not exist, Run stops the others and returns that error, so the app fails instead of running without it.
type Options ¶
type Options struct {
Subscriptions []string
Concurrency int64 // Max concurrent workers
Backoff bool // Enable backoff
BackoffBase time.Duration // Base backoff duration
MaxBackoff time.Duration // Max backoff duration
RetryLimit int // Limit retries, -1 for infinite retries
ProcessTimeout time.Duration // Timeout for processing messages
}
Options can be used to create customized handler.
func DefaultOptions ¶
DefaultOptions returns options based in config.
type Subscriber ¶
type Subscriber[T any] struct { // contains filtered or unexported fields }
Subscriber contains the Pub/Sub client, handler function, and options
func NewSubscriber ¶
func NewSubscriber[T any](client *pubsub.Client, handler function.Handler[T], subscription string, options *Options) *Subscriber[T]
NewSubscriber returns a subscriber listener.