Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBus ¶
type EventBus interface { Publish(ctx context.Context, topic string, event cloudevents.Event) error Subscribe(topic string, handler func(ctx context.Context, event cloudevents.Event), opts ...SubscriptionOption) error Close() error // Clean up resources }
EventBus defines the interface for publishing and subscribing to events
var DefaultEventBus EventBus
type EventWithCtx ¶
type EventWithCtx struct {
// contains filtered or unexported fields
}
EventWithCtx couples an event with its associated context.
type MemoryEventBus ¶
type MemoryEventBus struct {
// contains filtered or unexported fields
}
MemoryEventBus is an in-memory implementation of the EventBus using channels.
func NewMemoryEventBus ¶
func NewMemoryEventBus() (*MemoryEventBus, error)
NewEventBus creates a new MemoryEventBus.
func (*MemoryEventBus) Close ¶
func (b *MemoryEventBus) Close() error
Close shuts down the event bus and cleans up all channels.
func (*MemoryEventBus) Publish ¶
func (b *MemoryEventBus) Publish(ctx context.Context, topic string, event cloudevents.Event) error
Publish sends an event to all subscribers of the specified event type asynchronously.
func (*MemoryEventBus) Subscribe ¶
func (b *MemoryEventBus) Subscribe(topic string, handler func(ctx context.Context, event cloudevents.Event), opts ...SubscriptionOption) error
Subscribe registers a handler for the specified event type. It returns an error if the bus is closed.
type SubscriptionOption ¶ added in v0.13.1
type SubscriptionOption func(opts *SubscriptionOptions)
SubscriptionOption defines a function to set subscription options.
func WithConsumerGroup ¶ added in v0.13.1
func WithConsumerGroup(group string) SubscriptionOption
WithConsumerGroup specifies the consumer group.
func WithConsumerName ¶ added in v0.13.1
func WithConsumerName(name string) SubscriptionOption
WithConsumerName specifies the consumer name.
type SubscriptionOptions ¶ added in v0.13.1
SubscriptionOptions holds configuration for subscription.