MCPcopy
hub / github.com/benbjohnson/wtf / EventService

Interface EventService

event.go:46–54  ·  view source on GitHub ↗

EventService represents a service for managing event dispatch and event listeners (aka subscriptions). Events are user-centric in this implementation although a more generic implementation may use a topic-centic model (e.g. "dial_value_changed(id=1)"). The application has frequent reconnects so it'

Source from the content-addressed store, hash-verified

44// The application has frequent reconnects so it's more efficient to subscribe
45// for a single user instead of resubscribing to all their related topics.
46type EventService interface {
47 // Publishes an event to a user's event listeners.
48 // If the user is not currently subscribed then this is a no-op.
49 PublishEvent(userID int, event Event)
50
51 // Creates a subscription for the current user's events.
52 // Caller must call Subscription.Close() when done with the subscription.
53 Subscribe(ctx context.Context) (Subscription, error)
54}
55
56// NopEventService returns an event service that does nothing.
57func NopEventService() EventService { return &nopEventService{} }

Callers 7

publishDialEventFunction · 0.65
handleEventsMethod · 0.65
TestEventServiceFunction · 0.95
TestEventServiceFunction · 0.95
CloseMethod · 0.80
PublishEventMethod · 0.95
UnsubscribeMethod · 0.95

Implementers 3

EventServiceinmem/event.go
EventServicemock/event.go

Calls

no outgoing calls

Tested by

no test coverage detected