broker

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSubscriberParallelism = 1
	DefaultTestParallelism       = 1
	DefaultShutdownTimeout       = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerFunc

type HandlerFunc func(ctx context.Context, event *event.Event) error

HandlerFunc is a function that handles a CloudEvent

type Publisher

type Publisher interface {
	// Publish publishes a CloudEvent to the specified topic
	Publish(topic string, event *event.Event) error
	// Close closes the underlying publisher
	Close() error
}

Publisher defines the interface for publishing CloudEvents

func NewPublisher

func NewPublisher(configMap ...map[string]string) (Publisher, error)

NewPublisher creates a new publisher based on the configuration. If configMap is provided, it will be used instead of loading from file. Providing a configMap is meant to be used for testing purposes only. Config keys should use dot notation (e.g., "broker.type", "broker.rabbitmq.url").

type Subscriber

type Subscriber interface {
	// Subscribe subscribes to a topic and processes messages with the provided handler
	Subscribe(ctx context.Context, topic string, handler HandlerFunc) error
	// Close closes the underlying subscriber
	Close() error
}

Subscriber defines the interface for subscribing to CloudEvents

func NewSubscriber

func NewSubscriber(subscriptionID string, configMap ...map[string]string) (Subscriber, error)

NewSubscriber creates a new subscriber based on the configuration. subscriptionID determines whether subscribers share messages (same ID = shared, different IDs = separate). If configMap is provided, it will be used instead of loading from file. Config keys should use dot notation (e.g., "broker.type", "broker.rabbitmq.url").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL