Documentation
¶
Overview ¶
Package mempubsub provides an in-memory pubsub implementation. Use NewTopic to construct a *pubsub.Topic, and/or NewSubscription to construct a *pubsub.Subscription.
mempubsub should not be used for production: it is intended for local development and testing.
URLs ¶
For pubsub.OpenTopic and pubsub.OpenSubscription, mempubsub registers for the scheme "mem". To customize the URL opener, or for more details on the URL format, see URLOpener. See https://gocloud.dev/concepts/urls/ for background information.
Message Delivery Semantics ¶
mempubsub supports at-least-once semantics; applications must call Message.Ack after processing a message, or it will be redelivered. See https://godoc.org/gocloud.dev/pubsub#hdr-At_most_once_and_At_least_once_Delivery for more background.
As ¶
mempubsub does not support any types for As.
Index ¶
- Constants
- func NewSubscription(pstopic *pubsub.Topic, ackDeadline time.Duration) *pubsub.Subscription
- func NewSubscriptionWithOptions(pstopic *pubsub.Topic, ackDeadline time.Duration, opts *SubscriptionOptions) *pubsub.Subscription
- func NewTopic() *pubsub.Topic
- func NewTopicWithOptions(opts *TopicOptions) *pubsub.Topic
- type SubscriptionOptions
- type TopicOptions
- type URLOpener
Examples ¶
Constants ¶
const Scheme = "mem"
Scheme is the URL scheme mempubsub registers its URLOpeners under on pubsub.DefaultMux.
Variables ¶
This section is empty.
Functions ¶
func NewSubscription ¶
NewSubscription creates a new subscription for the given topic. It panics if the given topic did not come from mempubsub. If a message is not acked within in the given ack deadline from when it is received, then it will be redelivered.
func NewSubscriptionWithOptions ¶ added in v0.28.0
func NewSubscriptionWithOptions(pstopic *pubsub.Topic, ackDeadline time.Duration, opts *SubscriptionOptions) *pubsub.Subscription
NewSubscriptionWithOptions is similar to NewSubscription, but supports SubscriptionOptions.
func NewTopicWithOptions ¶ added in v0.28.0
func NewTopicWithOptions(opts *TopicOptions) *pubsub.Topic
NewTopicWithOptions is similar to NewTopic, but supports TopicOptions.
Types ¶
type SubscriptionOptions ¶ added in v0.28.0
type SubscriptionOptions struct { // ReceiveBatcherOptions adds constraints to the default batching done for receives. ReceiveBatcherOptions batcher.Options // AckBatcherOptions adds constraints to the default batching done for acks. AckBatcherOptions batcher.Options }
SubscriptionOptions will contain configuration for subscriptions.
type TopicOptions ¶ added in v0.28.0
type TopicOptions struct { // BatcherOptions adds constraints to the default batching done for sends. BatcherOptions batcher.Options }
TopicOptions contains configuration options for topics.
type URLOpener ¶ added in v0.12.0
type URLOpener struct {
// contains filtered or unexported fields
}
URLOpener opens mempubsub URLs like "mem://topic".
The URL's host+path is used as the topic to create or subscribe to.
Query parameters:
- ackdeadline: The ack deadline for OpenSubscription, in time.ParseDuration formats. Defaults to 1m.
func (*URLOpener) OpenSubscriptionURL ¶ added in v0.12.0
func (o *URLOpener) OpenSubscriptionURL(ctx context.Context, u *url.URL) (*pubsub.Subscription, error)
OpenSubscriptionURL opens a pubsub.Subscription based on u.