service

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2018 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeout = 100 * time.Millisecond

DefaultTimeout is the recommended timeout before dropping messages.

View Source
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

func NewEmitter(timeout time.Duration) Emitter

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

func (s *Service) AddToGRPCServer(gs *grpc.Server)

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) Desc

func (s *Service) Desc() string

Desc returns a description of what the service does.

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.

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

func (*Service) Name

func (s *Service) Name() string

Name returns the human friendly name of the service.

func (*Service) Run

func (s *Service) Run(ctx context.Context, running, stopping func()) error

Run starts the service.

func (*Service) SetConfig

func (s *Service) SetConfig(config interface{}) error

SetConfig configures the service handler.

Directories

Path Synopsis
Package mockservice is a generated GoMock package.
Package mockservice is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL