Documentation
¶
Index ¶
Constants ¶
const (
// EventBufferSize is the buffer size of the channel for each subscription.
EventBufferSize = 16
)
Variables ¶
This section is empty.
Functions ¶
func PublishEvent ¶
func PublishEvent(ctx context.Context, events EventService, event interface{})
Types ¶
type EventService ¶
type EventService interface { // Publishes an event to a user's event listeners. // If the user is not currently subscribed then this is a no-op. PublishEvent(ctx context.Context, event *goaingest.MonitorEvent) // Creates a subscription. Caller must call Subscription.Close() when done // with the subscription. Subscribe(ctx context.Context) (Subscription, error) }
EventService represents a service for managing event dispatch and event listeners (aka subscriptions).
func NewEventServiceRedis ¶
func NewEventServiceRedis(logger logr.Logger, tp trace.TracerProvider, cfg *Config) (EventService, error)
func NopEventService ¶
func NopEventService() EventService
NopEventService returns an event service that does nothing.
type EventServiceInMemImpl ¶
type EventServiceInMemImpl struct {
// contains filtered or unexported fields
}
EventServiceInMemImpl represents a service for managing events in the system.
func NewEventServiceInMemImpl ¶
func NewEventServiceInMemImpl() *EventServiceInMemImpl
NewEventServiceInMemImpl returns a new instance of EventService.
func (*EventServiceInMemImpl) PublishEvent ¶
func (s *EventServiceInMemImpl) PublishEvent(ctx context.Context, event *goaingest.MonitorEvent)
PublishEvent publishes event to all of a user's subscriptions.
If user's channel is full then the user is disconnected. This is to prevent slow users from blocking progress.
func (*EventServiceInMemImpl) Subscribe ¶
func (s *EventServiceInMemImpl) Subscribe(ctx context.Context) (Subscription, error)
Subscribe creates a new subscription.
func (*EventServiceInMemImpl) Unsubscribe ¶
func (s *EventServiceInMemImpl) Unsubscribe(sub *SubscriptionInMemImpl)
Unsubscribe disconnects sub from the service.
type EventServiceRedisImpl ¶
type EventServiceRedisImpl struct {
// contains filtered or unexported fields
}
func (*EventServiceRedisImpl) PublishEvent ¶
func (s *EventServiceRedisImpl) PublishEvent(ctx context.Context, event *goaingest.MonitorEvent)
func (*EventServiceRedisImpl) Subscribe ¶
func (s *EventServiceRedisImpl) Subscribe(ctx context.Context) (Subscription, error)
type Subscription ¶
type Subscription interface { // Event stream for all user's event. C() <-chan *goaingest.MonitorEvent // Closes the event stream channel and disconnects from the event service. Close() error }
Subscription represents a stream of events for a single user.
func NewSubscriptionRedis ¶
type SubscriptionInMemImpl ¶
type SubscriptionInMemImpl struct {
// contains filtered or unexported fields
}
SubscriptionInMemImpl represents a stream of user-related events.
func (*SubscriptionInMemImpl) C ¶
func (s *SubscriptionInMemImpl) C() <-chan *goaingest.MonitorEvent
C returns a receive-only channel of user-related events.
func (*SubscriptionInMemImpl) Close ¶
func (s *SubscriptionInMemImpl) Close() error
Close disconnects the subscription from the service it was created from.
type SubscriptionRedisImpl ¶
type SubscriptionRedisImpl struct {
// contains filtered or unexported fields
}
SubscriptionRedisImpl represents a stream of user-related events.
func (*SubscriptionRedisImpl) C ¶
func (s *SubscriptionRedisImpl) C() <-chan *goaingest.MonitorEvent
C returns a receive-only channel of user-related events.
func (*SubscriptionRedisImpl) Close ¶
func (s *SubscriptionRedisImpl) Close() error
Close disconnects the subscription from the service it was created from.