Documentation ¶
Index ¶
- type BaseService
- func (bs *BaseService) IsRunning() bool
- func (bs *BaseService) OnReset() error
- func (bs *BaseService) OnStart() error
- func (bs *BaseService) OnStop()
- func (bs *BaseService) Quit() <-chan struct{}
- func (bs *BaseService) Reset() error
- func (bs *BaseService) Start() error
- func (bs *BaseService) Stop() error
- func (bs *BaseService) String() string
- func (bs *BaseService) Wait()
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseService ¶
type BaseService struct {
// contains filtered or unexported fields
}
func NewBaseService ¶
func NewBaseService(name string, impl Service) *BaseService
NewBaseService creates a new BaseService.
func (*BaseService) IsRunning ¶
func (bs *BaseService) IsRunning() bool
IsRunning implements Service by returning true or false depending on the handler's state.
func (*BaseService) OnReset ¶
func (bs *BaseService) OnReset() error
OnReset implements Service by panicking.
func (*BaseService) OnStart ¶
func (bs *BaseService) OnStart() error
OnStart implements Service by doing nothing. NOTE: Do not put anything in here, that way users don't need to call BaseService.OnStart()
func (*BaseService) OnStop ¶
func (bs *BaseService) OnStop()
OnStop implements Service by doing nothing. NOTE: Do not put anything in here, that way users don't need to call BaseService.OnStop()
func (*BaseService) Quit ¶
func (bs *BaseService) Quit() <-chan struct{}
Quit Implements Service by returning a quit channel.
func (*BaseService) Reset ¶
func (bs *BaseService) Reset() error
Reset implements Service by calling OnReset callback (if defined). An error will be returned if the handlers is running.
func (*BaseService) Start ¶
func (bs *BaseService) Start() error
Start implements Service by calling OnStart (if defined). An error will be returned if the handlers is already running or stopped. Not to start the stopped handlers, you need to call Reset.
func (*BaseService) Stop ¶
func (bs *BaseService) Stop() error
Stop implements Service by calling OnStop (if defined) and closing quit channel. An error will be returned if the handlers is already stopped.
func (*BaseService) String ¶
func (bs *BaseService) String() string
String implements Service by returning a string representation of the handlers.
type Service ¶
type Service interface { // Start the handlers. // If it's already started or stopped, will return an error. // If OnStart() returns an error, it's returned by Start() Start() error OnStart() error // Stop the handlers. // If it's already stopped, will return an error. // OnStop must never error. Stop() error OnStop() // Reset the handlers. // Panics by default - must be overwritten to enable reset. Reset() error OnReset() error // IsRunning Return true if the handlers is running IsRunning() bool // Quit returns a channel, which is closed once handlers is stopped. Quit() <-chan struct{} // String representation of the handlers String() string }
Service defines a handlers in a node, everything in ouroboros expect core is a handlers