Documentation
¶
Overview ¶
Package lifecycx 定义组件生命周期和顺序启动/逆序停止管理器。
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 管理一组 Component 的有序启动和逆序停止。 Manager 非并发安全:Start 和 Stop 应由单个所有者调用。
func NewManager ¶
Example ¶
package main
import (
"context"
"github.com/ZoneCNH/kernel/lifecycx"
)
type lifecycleExampleComponent struct{}
func (lifecycleExampleComponent) Name() string { return "example" }
func (lifecycleExampleComponent) Start(context.Context) error { return nil }
func (lifecycleExampleComponent) Stop(context.Context) error { return nil }
func main() {
manager := lifecycx.NewManager(lifecycleExampleComponent{})
_ = manager.Start(context.Background())
_ = manager.Stop(context.Background())
}
Output:
func (*Manager) Components ¶
Click to show internal directories.
Click to hide internal directories.