Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewStateMachineFn = NewStateMachine
NewStateMachineFn represents new state machine function.
Functions ¶
func ExploreData ¶ added in v0.2.4
func ExploreData(ctx context.Context, repo state.Repository, stateMachineInfo models.StateMachineInfo) (interface{}, error)
ExploreData explores state repository data by given path.
Types ¶
type Discovery ¶
type Discovery interface { // Discovery starts discovery resources change, includes create/delete/clean, // if init = true, need list all resources before watch path. Discovery(init bool) error // Close stops watch, trigger all resource cleanup callback. Close() }
Discovery represents discovery resources, through watch resource's prefix.
type Factory ¶
type Factory interface { // GetRepo returns the repo of discovery used. GetRepo() state.Repository // CreateDiscovery creates a discovery who will watch the changes with the given prefix. CreateDiscovery(prefix string, listener Listener) Discovery }
Factory represents a discovery create factory.
type Listener ¶
type Listener interface { // OnCreate is resource creation callback. OnCreate(key string, resource []byte) // OnDelete is resource deletion callback. OnDelete(key string) }
Listener represents discovery resource event callback interface, includes create/delete/cleanup operation.
type Registry ¶
type Registry interface { io.Closer // Register registers node info, add it to active node list for discovery. Register(node models.Node) error // Deregister deregister node info, remove it from active list. Deregister(node models.Node) error // IsSuccess returns if registry successfully. IsSuccess() bool }
Registry represents server node register.
func NewRegistry ¶
NewRegistry returns a new registry with prefix and ttl.
type StateMachine ¶
StateMachine represents state changed event state machine. Like node online/offline, database create events etc.
func NewStateMachine ¶
func NewStateMachine(ctx context.Context, stateMachineType StateMachineType, discoveryFactory Factory, watchPath string, needInitialize bool, onCreateFn func(key string, resource []byte), onDeleteFn func(key string), ) (StateMachine, error)
NewStateMachine creates a state machine instance.
type StateMachineEventHandle ¶
type StateMachineEventHandle interface { // EmitEvent emits discovery event when state changed. EmitEvent(event *Event) // Close cleans the resource. Close() }
StateMachineEventHandle represents handle state machine event.
type StateMachineFactory ¶
type StateMachineFactory interface { // Start starts all state machines, do init logic. Start() error // Stop stops all state machines, clean all resources. Stop() }
StateMachineFactory represents maintain all state machines for each role.
type StateMachineType ¶
type StateMachineType int
StateMachineType represents state machine type.
const ( DatabaseConfigStateMachine StateMachineType = iota + 1 ShardAssignmentStateMachine LiveNodeStateMachine StorageStatusStateMachine StorageConfigStateMachine StorageNodeStateMachine BrokerConfigStateMachine BrokerNodeStateMachine DatabaseLimitsStateMachine )
func (StateMachineType) String ¶
func (st StateMachineType) String() string
String returns state machine type desc.