Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultSubscriberParallelism = 1 DefaultTestParallelism = 1 DefaultShutdownTimeout = 30 * time.Second )
View Source
const ( // ErrorChannelBufferSize is the buffer size for the error channel // Large enough to handle bursts without blocking ErrorChannelBufferSize = 100 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerFunc ¶
HandlerFunc is a function that handles a CloudEvent
type Publisher ¶
type Publisher interface {
// Publish publishes a CloudEvent to the specified topic with context
Publish(ctx context.Context, topic string, event *event.Event) error
// Close closes the underlying publisher
Close() error
}
Publisher defines the interface for publishing CloudEvents
func NewPublisher ¶
NewPublisher creates a new publisher with a required logger and optional configuration. Usage:
- NewPublisher(logger) - uses provided logger and loads config from file
- NewPublisher(logger, configMap) - uses provided logger with config map
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
// Errors returns a channel that receives errors from background operations.
// The channel is buffered to prevent blocking the subscriber.
// The channel is closed when Close() is called.
// Consumers SHOULD drain this channel to prevent memory leaks.
Errors() <-chan *SubscriberError
// Close closes the underlying subscriber
Close() error
}
Subscriber defines the interface for subscribing to CloudEvents
func NewSubscriber ¶
func NewSubscriber(log logger.Logger, subscriptionID string, configMap ...map[string]string) (Subscriber, error)
NewSubscriber creates a new subscriber with a required logger and optional configuration. Usage:
- NewSubscriber(logger, "id") - uses provided logger and loads config from file
- NewSubscriber(logger, "id", configMap) - uses provided logger with config map
type SubscriberError ¶ added in v1.0.0
type SubscriberError struct {
// Op is the operation that failed: "router", "connect", "receive"
Op string
// Topic where the error occurred
Topic string
// SubscriptionID of the subscriber
SubscriptionID string
// Err is the underlying error
Err error
// Timestamp is when the error occurred
Timestamp time.Time
// Fatal indicates if the subscriber has stopped and cannot continue operating.
// If true, the subscriber needs to be recreated.
Fatal bool
}
SubscriberError represents an error that occurred during message processing in background goroutines. These errors are sent via the Errors() channel.
func (*SubscriberError) Error ¶ added in v1.0.0
func (e *SubscriberError) Error() string
Error implements the error interface
func (*SubscriberError) Unwrap ¶ added in v1.0.0
func (e *SubscriberError) Unwrap() error
Unwrap implements the errors.Unwrap interface
Click to show internal directories.
Click to hide internal directories.