mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-30 14:41:20 +00:00
update comment [ci skip] [circleci skip]
This commit is contained in:
parent
c46ffe39a8
commit
dec518eb06
69
service.go
69
service.go
@ -1,13 +1,40 @@
|
|||||||
/*
|
package common
|
||||||
|
|
||||||
Classical-inheritance-style service declarations.
|
import (
|
||||||
Services can be started, then stopped, then optionally restarted.
|
"sync/atomic"
|
||||||
Users can override the OnStart/OnStop methods.
|
|
||||||
By default, these methods are guaranteed to be called at most once.
|
"github.com/tendermint/log15"
|
||||||
A call to Reset will panic, unless OnReset is overwritten, allowing OnStart/OnStop to be called again.
|
)
|
||||||
Caller must ensure that Start() and Stop() are not called concurrently.
|
|
||||||
It is ok to call Stop() without calling Start() first.
|
type Service interface {
|
||||||
Services cannot be re-started unless OnReset is overwritten to allow it.
|
Start() (bool, error)
|
||||||
|
OnStart() error
|
||||||
|
|
||||||
|
Stop() bool
|
||||||
|
OnStop()
|
||||||
|
|
||||||
|
Reset() (bool, error)
|
||||||
|
OnReset() error
|
||||||
|
|
||||||
|
IsRunning() bool
|
||||||
|
|
||||||
|
String() string
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Classical-inheritance-style service declarations. Services can be started, then
|
||||||
|
stopped, then optionally restarted.
|
||||||
|
|
||||||
|
Users can override the OnStart/OnStop methods. In the absence of errors, these
|
||||||
|
methods are guaranteed to be called at most once. If OnStart returns an error,
|
||||||
|
service won't be marked as started, so the user can call Start again.
|
||||||
|
|
||||||
|
A call to Reset will panic, unless OnReset is overwritten, allowing
|
||||||
|
OnStart/OnStop to be called again.
|
||||||
|
|
||||||
|
The caller must ensure that Start and Stop are not called concurrently.
|
||||||
|
|
||||||
|
It is ok to call Stop without calling Start first.
|
||||||
|
|
||||||
Typical usage:
|
Typical usage:
|
||||||
|
|
||||||
@ -35,31 +62,7 @@ func (fs *FooService) OnStop() error {
|
|||||||
// close/destroy private fields
|
// close/destroy private fields
|
||||||
// stop subroutines, etc.
|
// stop subroutines, etc.
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package common
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync/atomic"
|
|
||||||
|
|
||||||
"github.com/tendermint/log15"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
Start() (bool, error)
|
|
||||||
OnStart() error
|
|
||||||
|
|
||||||
Stop() bool
|
|
||||||
OnStop()
|
|
||||||
|
|
||||||
Reset() (bool, error)
|
|
||||||
OnReset() error
|
|
||||||
|
|
||||||
IsRunning() bool
|
|
||||||
|
|
||||||
String() string
|
|
||||||
}
|
|
||||||
|
|
||||||
type BaseService struct {
|
type BaseService struct {
|
||||||
log log15.Logger
|
log log15.Logger
|
||||||
name string
|
name string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user