iotex-core: github.com/iotexproject/iotex-core/pkg/lifecycle Index | Files

package lifecycle

import "github.com/iotexproject/iotex-core/pkg/lifecycle"

Package lifecycle provides application models' lifecycle management.

Index

Package Files

lifecycle.go

type Lifecycle Uses

type Lifecycle struct {
    // contains filtered or unexported fields
}

Lifecycle manages lifecycle for models. Currently a Lifecycle has two phases: Start and Stop. Currently Lifecycle doesn't support soft dependency models and multi-err, so all models in Lifecycle require to be succeed on both phases.

func (*Lifecycle) Add Uses

func (lc *Lifecycle) Add(m Model)

Add adds a model into LifeCycle.

func (*Lifecycle) AddModels Uses

func (lc *Lifecycle) AddModels(m ...Model)

AddModels adds multiple models into LifeCycle.

func (*Lifecycle) OnStart Uses

func (lc *Lifecycle) OnStart(ctx context.Context) error

OnStart runs models OnStart function if models implmented it. All OnStart functions will be run in parallel. context passed into models' OnStart method will be canceled on the first time a model's OnStart function return non-nil error.

func (*Lifecycle) OnStop Uses

func (lc *Lifecycle) OnStop(ctx context.Context) error

OnStop runs models Start function if models implmented it. All OnStop functions will be run in parallel. context passed into models' OnStop method will be canceled on the first time a model's OnStop function return non-nil error.

type Model Uses

type Model interface{}

Model is application model which may require to start and stop in application lifecycle.

type StartStopper Uses

type StartStopper interface {
    Starter
    Stopper
}

StartStopper is the interface that groups Start and Stop.

type Starter Uses

type Starter interface {
    // Start runs on lifecycle start phase.
    Start(context.Context) error
}

Starter is Model has a Start method.

type Stopper Uses

type Stopper interface {
    // Stop runs on lifecycle stop phase.
    Stop(context.Context) error
}

Stopper is Model has a Stop method.

Package lifecycle imports 2 packages (graph) and is imported by 10 packages. Updated 2019-07-27. Refresh now. Tools for package owners.