Documentation ¶
Index ¶
- Variables
- type Config
- type Emitter
- type ServerEmitter
- type Service
- func (s *Service) AddToGRPCServer(gs *grpc.Server)
- func (s *Service) Config() interface{}
- func (s *Service) Desc() string
- func (s *Service) Expose() interface{}
- func (s *Service) ID() string
- func (s *Service) Name() string
- func (s *Service) Run(ctx context.Context, running, stopping func()) error
- func (s *Service) SetConfig(config interface{}) error
Constants ¶
This section is empty.
Variables ¶
var DefaultTimeout = 100 * time.Millisecond
DefaultTimeout is the recommended timeout before dropping messages.
var ( // ErrUnupportedTopic is returned when the topic cannot be parsed. ErrUnupportedTopic = errors.New("topic cannot be parsed") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // WriteTimeout sets how long to wait before dropping a message when listeners are too slow. WriteTimeout string `toml:"write_timeout" comment:"How long to wait before dropping a message when listeners are too slow."` }
Config contains configuration options for the Event service.
type Emitter ¶
type Emitter interface { AddListener(topic string) (<-chan *grpc.Event, error) RemoveListener(<-chan *grpc.Event) GetListenersCount(topic string) int Emit(*grpc.Event) Close() }
Emitter emits events. Listeners can be added and removed.
func NewEmitter ¶
NewEmitter creates a new event emitter.
type ServerEmitter ¶
type ServerEmitter struct {
// contains filtered or unexported fields
}
ServerEmitter is a simple Emitter.
func (*ServerEmitter) AddListener ¶
func (e *ServerEmitter) AddListener(topic string) (<-chan *grpc.Event, error)
AddListener adds an event listener. It returns the channel on which events will be pushed.
func (*ServerEmitter) Close ¶
func (e *ServerEmitter) Close()
Close closes open channels and internal handles.
func (*ServerEmitter) Emit ¶
func (e *ServerEmitter) Emit(ev *grpc.Event)
Emit emits an event to connected listeners.
func (*ServerEmitter) GetListenersCount ¶
func (e *ServerEmitter) GetListenersCount(topic string) int
GetListenersCount returns the number of active listeners on a topic.
func (*ServerEmitter) RemoveListener ¶
func (e *ServerEmitter) RemoveListener(listener <-chan *grpc.Event)
RemoveListener removes an event listener.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Event service.
func (*Service) AddToGRPCServer ¶
AddToGRPCServer adds the service to a gRPC server.
func (*Service) Config ¶
func (s *Service) Config() interface{}
Config returns the current service configuration or creates one with good default values.
func (*Service) Expose ¶
func (s *Service) Expose() interface{}
Expose exposes the event service to other services. It allows services to emit events in a standard way.
Directories ¶
Path | Synopsis |
---|---|
Package mockservice is a generated GoMock package.
|
Package mockservice is a generated GoMock package. |