Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
// Subscribe registers a named subscriber for the given topic and returns
// a channel that will receive messages published to matching topics.
Subscribe(name string, topic string) (<-chan entity.PubsubMessage, error)
// GetSubscribers returns the names of all subscribers matching the given topic,
// including those subscribed to parent topics.
GetSubscribers(topic string) []string
// Unsubscribe removes a subscriber from receiving events for the given topic.
// The subscriber's channel is closed.
Unsubscribe(name string, topic string) error
// Publish dispatches an event to local subscribers and handles
// cross-instance delivery (e.g., via Redis).
// The from parameter is the publisher's name, used to skip self-delivery.
// ctx applies only to the cross-instance hop; local fan-out runs to
// completion regardless, so partial delivery is possible if ctx is
// canceled mid-publish.
Publish(ctx context.Context, from string, topic string, kind string, payload any) error
// lifecycle
common.Daemon
}
Driver defines the interface for subscription storage and event delivery.
type OnFull ¶ added in v0.4.9
type OnFull int
OnFull selects what a driver does when a subscriber's pending queue is full, meaning the subscriber is not draining its channel fast enough.
const ( // DropMessage discards the message and keeps the subscription. The // subscriber never learns that it missed a message. DropMessage OnFull = iota // DropSubscriber closes the subscriber's channel and removes it from the // topic. A subscriber that reconnects and resumes from its own cursor // loses nothing; one that is silently skipped loses a message forever. DropSubscriber )
type Option ¶ added in v0.4.9
type Option func(*options)
Option configures a driver.
func WithChannelBuffer ¶ added in v0.4.9
WithChannelBuffer sets the buffer size of the channel handed to subscribers.
func WithOnFull ¶ added in v0.4.9
WithOnFull sets the policy applied when a subscriber's queue is full. The default is DropMessage, which preserves the historical behavior.
func WithQueueCap ¶ added in v0.4.9
WithQueueCap bounds each subscriber's pending queue.
type Stats ¶ added in v0.4.9
type Stats interface {
// Dropped returns the number of messages discarded because a subscriber
// could not keep up.
Dropped() uint64
// Evicted returns the number of subscribers removed because they could
// not keep up.
Evicted() uint64
}
Stats is implemented by drivers that report delivery statistics.
Click to show internal directories.
Click to hide internal directories.