Documentation
¶
Index ¶
- Constants
- Variables
- func ChangeState(oldState *State, newState State)
- func IsStateEqual(current State, target State) bool
- type Application
- type MainFunc
- type RecoverFunc
- type Service
- type ServiceKeeper
- type ServiceNotFoundError
- type Stage
- func (c *Stage) Init(ctx context.Context, state *State, keeper *ServiceKeeper) error
- func (c *Stage) Shutdown(ctx context.Context, state *State, shutdown chan struct{}) error
- func (c *Stage) Start(ctx context.Context, state *State, keeper *ServiceKeeper, mainFunc MainFunc, ...) error
- func (c *Stage) Uninit(ctx context.Context, state *State, keeper *ServiceKeeper) error
- type State
Constants ¶
View Source
const ( StateStart = State(iota) // initial state StateInit StateRunning StateShutdown StateUninit StateTerminated )
Variables ¶
View Source
var (
ServiceNotFound = errors.New("service not found")
)
Functions ¶
func ChangeState ¶
ChangeState atomically changes the application state
func IsStateEqual ¶
IsStateEqual compare application state with target state. True if states is equal, false otherwise
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func CreateApplication ¶
func CreateApplication(logger zerolog.Logger, shutdownTimeout time.Duration, initTimeout time.Duration, mainFunc MainFunc, recoverFunc RecoverFunc) Application
CreateApplication create new application
func (*Application) RegisterService ¶
func (app *Application) RegisterService(serviceName string, service Service) *Application
func (*Application) Run ¶
func (app *Application) Run() error
Run application lifecycle. Must be called from main function
func (*Application) SetSysSignals ¶
func (app *Application) SetSysSignals(signals ...syscall.Signal) *Application
SetSysSignals append os signal(s) to application TODO: check if windows. Signals works on windows?
type RecoverFunc ¶
type RecoverFunc func() error
type ServiceKeeper ¶
type ServiceKeeper struct {
Services map[string]*Service
PingPeriod time.Duration
PingTimeout time.Duration
}
func NewServiceKeeper ¶
func (*ServiceKeeper) HealthCheck ¶
func (keeper *ServiceKeeper) HealthCheck() error
type ServiceNotFoundError ¶
func (*ServiceNotFoundError) Error ¶
func (e *ServiceNotFoundError) Error() string
Click to show internal directories.
Click to hide internal directories.