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'
| 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. |
| 46 | type 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. |
| 57 | func NopEventService() EventService { return &nopEventService{} } |
no outgoing calls
no test coverage detected