Documentation ¶
Index ¶
- type BufferingEnvelope
- type BufferingPubSub
- func (p *BufferingPubSub[T]) Close(ctx context.Context) (err error)
- func (p *BufferingPubSub[T]) Handle(ctx context.Context, envelope BufferingEnvelope) error
- func (p *BufferingPubSub[T]) Publish(ctx context.Context, message T) error
- func (p *BufferingPubSub[T]) Subscribe(ctx context.Context, subscriber Subscriber[T]) (err error)
- type BufferingPubSubParams
- type ChainedPublisher
- type ChainedSubscriber
- type InMemoryPubSub
- type InMemorySubscriber
- type LoggingSubscriber
- type NoopSubscriber
- type PubSub
- type Publisher
- type PublisherFunc
- type Subscriber
- type SubscriberFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferingEnvelope ¶
type BufferingEnvelope struct { Offsets []int64 `json:"offsets"` Payloads []byte `json:"payloads"` }
func (*BufferingEnvelope) Size ¶
func (e *BufferingEnvelope) Size() int64
Size return the size of the buffered payloads in the envelope
type BufferingPubSub ¶
type BufferingPubSub[T any] struct { // contains filtered or unexported fields }
BufferingPubSub is a PubSub implementation that buffers messages in memory and flushes them to the delegate PubSub when the buffer is full or the buffer age is reached
func NewBufferingPubSub ¶
func NewBufferingPubSub[T any](params BufferingPubSubParams) *BufferingPubSub[T]
func (*BufferingPubSub[T]) Close ¶
func (p *BufferingPubSub[T]) Close(ctx context.Context) (err error)
func (*BufferingPubSub[T]) Handle ¶
func (p *BufferingPubSub[T]) Handle(ctx context.Context, envelope BufferingEnvelope) error
func (*BufferingPubSub[T]) Publish ¶
func (p *BufferingPubSub[T]) Publish(ctx context.Context, message T) error
func (*BufferingPubSub[T]) Subscribe ¶
func (p *BufferingPubSub[T]) Subscribe(ctx context.Context, subscriber Subscriber[T]) (err error)
type BufferingPubSubParams ¶
type BufferingPubSubParams struct { DelegatePubSub PubSub[BufferingEnvelope] MaxBufferSize int64 MaxBufferAge time.Duration }
type ChainedPublisher ¶ added in v1.0.4
type ChainedPublisher[T any] struct { // contains filtered or unexported fields }
func NewChainedPublisher ¶ added in v1.0.4
func NewChainedPublisher[T any](ignoreErrors bool) *ChainedPublisher[T]
func (*ChainedPublisher[T]) Add ¶ added in v1.0.4
func (c *ChainedPublisher[T]) Add(publisher Publisher[T])
Add publisher to the chain
type ChainedSubscriber ¶
type ChainedSubscriber[T any] struct { // contains filtered or unexported fields }
func NewChainedSubscriber ¶
func NewChainedSubscriber[T any](ignoreErrors bool) *ChainedSubscriber[T]
func (*ChainedSubscriber[T]) Add ¶
func (c *ChainedSubscriber[T]) Add(subscriber Subscriber[T])
Add subscriber to the chain
type InMemoryPubSub ¶
type InMemoryPubSub[T any] struct { // contains filtered or unexported fields }
InMemoryPubSub is a simple in-memory pubsub implementation used for testing
func NewInMemoryPubSub ¶
func NewInMemoryPubSub[T any]() *InMemoryPubSub[T]
func (*InMemoryPubSub[T]) Publish ¶
func (p *InMemoryPubSub[T]) Publish(ctx context.Context, message T) error
func (*InMemoryPubSub[T]) Subscribe ¶
func (p *InMemoryPubSub[T]) Subscribe(ctx context.Context, subscriber Subscriber[T]) error
type InMemorySubscriber ¶
type InMemorySubscriber[T any] struct { // contains filtered or unexported fields }
InMemorySubscriber is a simple in-memory subscriber implementation used for testing
func NewInMemorySubscriber ¶
func NewInMemorySubscriber[T any]() *InMemorySubscriber[T]
func (*InMemorySubscriber[T]) Events ¶
func (s *InMemorySubscriber[T]) Events() []T
type LoggingSubscriber ¶ added in v1.0.4
type LoggingSubscriber[T any] struct { // contains filtered or unexported fields }
LoggingSubscriber that just logs the message.
func NewLoggingSubscriber ¶ added in v1.0.4
func NewLoggingSubscriber[T any](level zerolog.Level) *LoggingSubscriber[T]
type NoopSubscriber ¶ added in v1.0.4
type NoopSubscriber[T any] struct { }
NoopSubscriber is a subscriber that does nothing. It is useful for adding subscribers to the pubsub network that only participate in the gossip protocol, but do not actually handle messages. This is useful when the network is small and not enough peers are available to strengthen the network.
func NewNoopSubscriber ¶ added in v1.0.4
func NewNoopSubscriber[T any]() *NoopSubscriber[T]
type PubSub ¶
type PubSub[T any] interface { // Publish a message Publish(ctx context.Context, message T) error // Subscribe to messages Subscribe(ctx context.Context, subscriber Subscriber[T]) error // Close the PubSub and release resources, if any Close(ctx context.Context) error }
PubSub enables publishing messages to subscribers
type PublisherFunc ¶ added in v1.0.4
PublisherFunc is a helper function that implements Publisher interface
type Subscriber ¶
Subscriber handles messages publishes to PubSub