Documentation ¶
Index ¶
- type BaseService
- func (bas *BaseService) CheckRateLimit()
- func (bas *BaseService) Description() string
- func (bas *BaseService) Done() <-chan struct{}
- func (bas *BaseService) HandlesReq(req interface{}) bool
- func (bas *BaseService) Input() chan interface{}
- func (bas *BaseService) OnStart() error
- func (bas *BaseService) OnStop() error
- func (bas *BaseService) Output() chan interface{}
- func (bas *BaseService) SetRateLimit(persec int)
- func (bas *BaseService) Start() error
- func (bas *BaseService) Stop() error
- func (bas *BaseService) String() string
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseService ¶
BaseService provides common mechanisms to all services implementing the Service interface.
func NewBaseService ¶
func NewBaseService(srv Service, name string) *BaseService
NewBaseService returns an initialized BaseService object.
func (*BaseService) CheckRateLimit ¶
func (bas *BaseService) CheckRateLimit()
CheckRateLimit implements the Service interface.
func (*BaseService) Description ¶
func (bas *BaseService) Description() string
Description implements the Service interface.
func (*BaseService) Done ¶
func (bas *BaseService) Done() <-chan struct{}
Done implements the Service interface.
func (*BaseService) HandlesReq ¶ added in v0.3.0
func (bas *BaseService) HandlesReq(req interface{}) bool
HandlesReq implements the Service interface.
func (*BaseService) Input ¶ added in v0.2.0
func (bas *BaseService) Input() chan interface{}
Input implements the Service interface.
func (*BaseService) OnStart ¶
func (bas *BaseService) OnStart() error
OnStart implements the Service interface.
func (*BaseService) OnStop ¶
func (bas *BaseService) OnStop() error
OnStop implements the Service interface.
func (*BaseService) Output ¶ added in v0.2.0
func (bas *BaseService) Output() chan interface{}
Output implements the Service interface.
func (*BaseService) SetRateLimit ¶
func (bas *BaseService) SetRateLimit(persec int)
SetRateLimit implements the Service interface.
func (*BaseService) Start ¶
func (bas *BaseService) Start() error
Start implements the Service interface.
func (*BaseService) Stop ¶
func (bas *BaseService) Stop() error
Stop implements the Service interface.
func (*BaseService) String ¶
func (bas *BaseService) String() string
String implements the Stringer interface.
type Service ¶
type Service interface { fmt.Stringer // Description returns a greeting message from the service. Description() string // Start requests that the service be started. Start() error // OnStart is called when the Start method requests the service be started. OnStart() error // Stop requests that the service be stopped. Stop() error // OnStop is called when the Stop method requests the service be stopped. OnStop() error // Done returns a channel that is closed when the service is stopped. Done() <-chan struct{} // Input returns a channel that the service receives requests on. Input() chan interface{} // HandlesReq returns true when the provided request is processed by the service. HandlesReq(req interface{}) bool // Output returns a channel that the service send results on. Output() chan interface{} // SetRateLimit sets the number of calls to the OnRequest method each second. SetRateLimit(persec int) // CheckRateLimit blocks until the minimum wait duration since the last call. CheckRateLimit() }
Service handles queued requests at an optional rate limit.