Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamToClient ¶
func StreamToClient[Topic any, Payload any, Response any]( ctx context.Context, streamer SyncStreamer[Topic, Payload], filter TopicFilter[Topic], convert func([]Payload) *Response, send func(*Response) error, opts *BulkOptions, ) error
StreamToClient bridges a SyncStreamer to a client sending function. It handles the subscription and the continuous loop. It supports batching events before sending to the client.
Types ¶
type BulkOptions ¶
type BulkOptions struct {
MaxBatchSize int
FlushInterval time.Duration
Ready chan<- struct{} // Closed after subscription is active (for test synchronization)
}
BulkOptions configures the batching behavior for StreamToClient.
type Event ¶
Event is the message delivered to subscribers. It contains the topic metadata alongside the payload so handlers can reason about ordering and provenance.
type SyncStreamer ¶
type SyncStreamer[Topic any, Payload any] interface { Publish(topic Topic, payloads ...Payload) Subscribe(ctx context.Context, filter TopicFilter[Topic]) (<-chan Event[Topic, Payload], error) Shutdown() }
SyncStreamer defines a generic interface for real-time streaming of domain events. Publishers provide a Topic and Payload when emitting changes. Subscribers specify a filter that decides which topics they are interested in.
type TopicFilter ¶
TopicFilter is used to decide whether a subscriber should receive an event published on the given topic. Returning true delivers the event to the subscriber.