Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewID = func() string {
return ulid.MustNew(ulid.Now(), entropy).String()
}
NewID creates a new, random, sequential id.
Functions ¶
This section is empty.
Types ¶
type RetryPolicy ¶
A RetryPolicy configures how messages in the queue should be retried.
func (*RetryPolicy) BackoffDuration ¶
func (retryPolicy *RetryPolicy) BackoffDuration(retries int) time.Duration
BackoffDuration returns the backoff duration for the given number of retries.
type SubscribeConfig ¶
type SubscribeConfig struct {
RetryPolicy RetryPolicy
}
The SubscribeConfig customizes how subscription works.
func NewSubscribeConfig ¶
func NewSubscribeConfig(opts ...SubscribeOption) *SubscribeConfig
NewSubscribeConfig creates a new SubscribeConfig from the given options.
type SubscribeHandler ¶
type SubscribeHandler = func(ctx context.Context, msg SubscriberMessage)
A SubscribeHandler is a function invoked for pub/sub messages sent to a topic.
type SubscribeOption ¶
type SubscribeOption = func(config *SubscribeConfig)
A SubscribeOption customizes the SubscribeConfig.
func WithMaxAttempts ¶
func WithMaxAttempts(maxAttempts int) SubscribeOption
WithMaxAttempts sets the max attempts in the subscribe config.
func WithMaxBackoff ¶
func WithMaxBackoff(maxBackoff time.Duration) SubscribeOption
WithMaxBackoff sets the max backoff in the subscribe config.
func WithMinBackoff ¶
func WithMinBackoff(minBackoff time.Duration) SubscribeOption
WithMinBackoff sets the min backoff in the subscribe config.
type SubscriberMessage ¶
type SubscriberMessage interface { Message // Ack signals completion of a message which will then be removed from the pub/sub topic. Ack() // Nack signals failure of message processing. The message will be retried according to // the retry policy of the subscription. Nack() }
A SubscriberMessage is a pub sub message with Ack and Nack methods.
type Subscription ¶
type Subscription interface { // Receive receives messages sent to the subscription. The given handler // will be invoked for each message in a goroutine. To stop `Receive` // cancel the context. Receive(ctx context.Context, handler SubscribeHandler) error }
A Subscription is a single subscription to a topic.
type Topic ¶
type Topic interface { // Publish publishes a message to the topic. Publish(ctx context.Context, msg Message) error // Subscribe creates (or resumes) a subscription to a topic. All messages // published to the topic will be sent to all subscribers. Subscribe(ctx context.Context, name string, opts ...SubscribeOption) (Subscription, error) }
A Topic is a named, logical channel which messages can be published to.
Directories ¶
Path | Synopsis |
---|---|
providers
|
|
google
Package google implements a Pub/Sub queue using Google Cloud Pub/Sub.
|
Package google implements a Pub/Sub queue using Google Cloud Pub/Sub. |
memory
Package memory contains an in-memory implementation of a pub/sub queue.
|
Package memory contains an in-memory implementation of a pub/sub queue. |