Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Complete ¶
func Complete()
Complete stops the event stream, cleaning up its resources using the default subject.
func Next ¶
Next emits an event to the given topic using the default subject. If a connection is provided, the event will only be delivered to that specific client.
func Unsubscribe ¶
func Unsubscribe(sub Subscription)
Unsubscribe unsubscribes the given Subscription from its topic using the default subject.
Types ¶
type NextFunc ¶
type NextFunc interface{}
NextFunc is the function called when an event is emitted. It can optionally receive a net.Conn as its last parameter.
type NoOpBroker ¶
type NoOpBroker struct{}
NoOpBroker is a no-op implementation of the pubsub.Broker interface for when NATS is not available
func (*NoOpBroker) CreateStream ¶
func (b *NoOpBroker) CreateStream(streamName, subject string, dedupWindow time.Duration) error
type ReplaySubject ¶
type ReplaySubject struct {
Subject
// contains filtered or unexported fields
}
ReplaySubject caches the last N events and re-emits them to new subscribers.
func NewReplaySubject ¶
func NewReplaySubject(cacheSize int) *ReplaySubject
NewReplaySubject creates a new ReplaySubject with a specified cache size.
func (*ReplaySubject) Subscribe ¶
func (rs *ReplaySubject) Subscribe(topic string, next NextFunc, replayEvents bool) Subscription
type Subject ¶
type Subject struct {
// contains filtered or unexported fields
}
func (*Subject) Unsubscribe ¶
func (s *Subject) Unsubscribe(sub Subscription)
type Subscription ¶
type Subscription struct {
Topic string
CreatedAt int64
Next NextFunc
ID string // Add a unique identifier
}
Subscription represents a handler subscribed to a specific topic.
func Subscribe ¶
func Subscribe(topic string, next NextFunc) Subscription
Subscribe subscribes a NextFunc to the given topic using the default subject. A Subscription is returned that can be used to unsubscribe from the topic.