Documentation ¶
Overview ¶
Package lifecycle is a generated GoMock package.
Index ¶
- type Lifecycle
- type MockLifecycle
- func (m *MockLifecycle) EXPECT() *MockLifecycleMockRecorder
- func (m *MockLifecycle) RegisterServices(modular ...Service)
- func (m *MockLifecycle) Signals(sigs ...os.Signal) Lifecycle
- func (m *MockLifecycle) StartServices(ctx context.Context) Lifecycle
- func (m *MockLifecycle) StopServices(ctx context.Context)
- func (m *MockLifecycle) Wait(ctx context.Context)
- type MockLifecycleMockRecorder
- func (mr *MockLifecycleMockRecorder) RegisterServices(modular ...interface{}) *gomock.Call
- func (mr *MockLifecycleMockRecorder) Signals(sigs ...interface{}) *gomock.Call
- func (mr *MockLifecycleMockRecorder) StartServices(ctx interface{}) *gomock.Call
- func (mr *MockLifecycleMockRecorder) StopServices(ctx interface{}) *gomock.Call
- func (mr *MockLifecycleMockRecorder) Wait(ctx interface{}) *gomock.Call
- type MockService
- type MockServiceMockRecorder
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lifecycle ¶
type Lifecycle interface { // RegisterServices registers service to ServiceLifecycle for managing. RegisterServices(modular ...Service) // StartServices starts all registered services by calling Service.Start method. StartServices(ctx context.Context) Lifecycle // StopServices stops all registered services by calling Service.Stop method. StopServices(ctx context.Context) // Signals listens the system signals for gracefully stop the registered services. Signals(sigs ...os.Signal) Lifecycle // Wait waits the signal for stopping the ServiceLifecycle, before stopping // the ServiceLifecycle will call StopServices stops all registered services. Wait(ctx context.Context) }
Lifecycle is an interface to describe how service is managed. The Lifecycle tracks the Service lifecycle, listens for signals from the process to ensure a graceful shutdown.
All managed services must firstly call RegisterServices to register with Lifecycle.
type MockLifecycle ¶ added in v0.2.4
type MockLifecycle struct {
// contains filtered or unexported fields
}
MockLifecycle is a mock of Lifecycle interface.
func NewMockLifecycle ¶ added in v0.2.4
func NewMockLifecycle(ctrl *gomock.Controller) *MockLifecycle
NewMockLifecycle creates a new mock instance.
func (*MockLifecycle) EXPECT ¶ added in v0.2.4
func (m *MockLifecycle) EXPECT() *MockLifecycleMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLifecycle) RegisterServices ¶ added in v0.2.4
func (m *MockLifecycle) RegisterServices(modular ...Service)
RegisterServices mocks base method.
func (*MockLifecycle) Signals ¶ added in v0.2.4
func (m *MockLifecycle) Signals(sigs ...os.Signal) Lifecycle
Signals mocks base method.
func (*MockLifecycle) StartServices ¶ added in v0.2.4
func (m *MockLifecycle) StartServices(ctx context.Context) Lifecycle
StartServices mocks base method.
func (*MockLifecycle) StopServices ¶ added in v0.2.4
func (m *MockLifecycle) StopServices(ctx context.Context)
StopServices mocks base method.
func (*MockLifecycle) Wait ¶ added in v0.2.4
func (m *MockLifecycle) Wait(ctx context.Context)
Wait mocks base method.
type MockLifecycleMockRecorder ¶ added in v0.2.4
type MockLifecycleMockRecorder struct {
// contains filtered or unexported fields
}
MockLifecycleMockRecorder is the mock recorder for MockLifecycle.
func (*MockLifecycleMockRecorder) RegisterServices ¶ added in v0.2.4
func (mr *MockLifecycleMockRecorder) RegisterServices(modular ...interface{}) *gomock.Call
RegisterServices indicates an expected call of RegisterServices.
func (*MockLifecycleMockRecorder) Signals ¶ added in v0.2.4
func (mr *MockLifecycleMockRecorder) Signals(sigs ...interface{}) *gomock.Call
Signals indicates an expected call of Signals.
func (*MockLifecycleMockRecorder) StartServices ¶ added in v0.2.4
func (mr *MockLifecycleMockRecorder) StartServices(ctx interface{}) *gomock.Call
StartServices indicates an expected call of StartServices.
func (*MockLifecycleMockRecorder) StopServices ¶ added in v0.2.4
func (mr *MockLifecycleMockRecorder) StopServices(ctx interface{}) *gomock.Call
StopServices indicates an expected call of StopServices.
func (*MockLifecycleMockRecorder) Wait ¶ added in v0.2.4
func (mr *MockLifecycleMockRecorder) Wait(ctx interface{}) *gomock.Call
Wait indicates an expected call of Wait.
type MockService ¶ added in v0.2.4
type MockService struct {
// contains filtered or unexported fields
}
MockService is a mock of Service interface.
func NewMockService ¶ added in v0.2.4
func NewMockService(ctrl *gomock.Controller) *MockService
NewMockService creates a new mock instance.
func (*MockService) EXPECT ¶ added in v0.2.4
func (m *MockService) EXPECT() *MockServiceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockService) Name ¶ added in v0.2.4
func (m *MockService) Name() string
Name mocks base method.
type MockServiceMockRecorder ¶ added in v0.2.4
type MockServiceMockRecorder struct {
// contains filtered or unexported fields
}
MockServiceMockRecorder is the mock recorder for MockService.
func (*MockServiceMockRecorder) Name ¶ added in v0.2.4
func (mr *MockServiceMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name.
func (*MockServiceMockRecorder) Start ¶ added in v0.2.4
func (mr *MockServiceMockRecorder) Start(ctx interface{}) *gomock.Call
Start indicates an expected call of Start.
func (*MockServiceMockRecorder) Stop ¶ added in v0.2.4
func (mr *MockServiceMockRecorder) Stop(ctx interface{}) *gomock.Call
Stop indicates an expected call of Stop.
type Service ¶
type Service interface { // Name describe service name Name() string // Start a service, this method should be used in non-block form Start(ctx context.Context) error // Stop a service, this method should be used in non-block form Stop(ctx context.Context) error }
Service provides abstract methods to control the lifecycle of a service Every service must implement Service interface.