Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultDeduplicateKey = "deduplicate_key"
Variables ¶
This section is empty.
Functions ¶
func SubscriptionInterceptor ¶
func SubscriptionInterceptor(mutexer Mutexer, opt ...Option) pm.SubscriptionInterceptor
SubscriptionInterceptor process only the first event and discards the others with the same de-duplicate key. To make this interceptor work, you need to set the de-duplicate key in the attributes when publishing message like below. If the key is not set, messageID will be used as the de-duplicate key.
// publisher msg := pubsub.Message{Data: []byte("something"), Attributes: map[string]string{pm_effectively_once.DeduplicateKey: "unique-key"}} pubsub.Topic{}.Publish(ctx, msg)
// subscriber pubsubSubscriber := pm.NewSubscriber(
pubsubClient, pm.WithSubscriptionInterceptor( pm_effectively_once.SubscriptionInterceptor(pm_effectively_once.NewRedisMutexer(redisClient)), ), )
Types ¶
Click to show internal directories.
Click to hide internal directories.