Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is an in-process event bus for cross-service communication within cloudmock.
func (*Bus) HasSubscribers ¶
HasSubscribers returns true if there is at least one subscription. Useful for callers to skip event construction when nobody is listening.
func (*Bus) Publish ¶
Publish fans out an event to all matching subscriptions asynchronously. Each matching handler is invoked in its own goroutine. Errors from handlers are silently discarded (fire-and-forget semantics).
func (*Bus) PublishSync ¶
PublishSync fans out an event to all matching subscriptions synchronously. This is useful in tests where you need to wait for delivery to complete.
func (*Bus) Subscribe ¶
func (b *Bus) Subscribe(sub *Subscription) string
Subscribe registers a subscription on the bus. Returns the subscription ID. If sub.ID is empty, a random ID is generated.
func (*Bus) Unsubscribe ¶
Unsubscribe removes the subscription with the given ID.
type Event ¶
type Event struct {
Source string // service that produced the event, e.g. "s3"
Type string // event type, e.g. "s3:ObjectCreated:Put"
Detail map[string]any // event payload
Time time.Time
Region string
AccountID string
}
Event represents an internal cross-service event within cloudmock.
type EventHandler ¶
EventHandler is a callback invoked when a matching event is published.
type Subscription ¶
type Subscription struct {
ID string
Source string // filter by source service
Types []string // filter by event types (supports prefix matching with *)
Handler EventHandler
}
Subscription describes a listener registered on the event bus.