Documentation
¶
Index ¶
- Constants
- Variables
- func NewStateMachine(_ context.Context, opts NewStateMachineOpts) *fsm.FSM
- type Backoff
- type EndpointManager
- func (m *EndpointManager) ElectionKey(ctx context.Context) string
- func (m *EndpointManager) Endpoint() models.Endpoint
- func (m *EndpointManager) Failover(ctx context.Context) error
- func (m *EndpointManager) SetHealthChecks(ctx context.Context, cfg config.Config, healthChecks []models.HealthCheck)
- func (m *EndpointManager) Start(ctx context.Context)
- func (m *EndpointManager) Status() string
- func (m *EndpointManager) Stop(ctx context.Context) error
- type Manager
- type NewStateMachineOpts
Constants ¶
View Source
const ( ACTIVATED = "ACTIVATED" STANDBY = "STANDBY" FAILING = "FAILING" BOOTING = "BOOTING" )
View Source
const ( FaultEvent = "fault" ElectedEvent = "elected" DemotedEvent = "demoted" HealthCheckFailEvent = "health_check_fail" HealthCheckSuccessEvent = "health_check_success" )
Variables ¶
View Source
var ( // ErrIsNotMaster is an error sent by Failover when the node is not currently master ErrIsNotMaster = errors.New("this node is not master of this endpoint") // ErrNoOtherHosts is an error sent by Failover when there is no other node to fail over. ErrNoOtherHosts = errors.New("no other nodes are listening for this endpoint") // ErrReallocationTimedOut is an error returned by waitForReallocation if the reallocation did not happen in less than KeepAliveInterval ErrReallocationTimedOut = errors.New("reallocation timed out") )
Functions ¶
func NewStateMachine ¶
func NewStateMachine(_ context.Context, opts NewStateMachineOpts) *fsm.FSM
Types ¶
type EndpointManager ¶
type EndpointManager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*EndpointManager) ElectionKey ¶
func (m *EndpointManager) ElectionKey(ctx context.Context) string
func (*EndpointManager) Endpoint ¶
func (m *EndpointManager) Endpoint() models.Endpoint
Endpoint returns the endpoint model linked to this manager
func (*EndpointManager) Failover ¶
func (m *EndpointManager) Failover(ctx context.Context) error
Failover forces a change of the master. It can only be run on the current master instance for an endpoint. If there is another node available for this endpoint, it steps down as a master and ensure that another node becomes master. This function refuses to trigger a failover if the node is not master or if there are no other nodes. To trigger the failover, we unlock the endpoint (remove the lock key) and update the link between the host and the endpoint. Updating the link notifies watchers on this endpoint and other hosts will try to get the endpoint.
func (*EndpointManager) SetHealthChecks ¶
func (m *EndpointManager) SetHealthChecks(ctx context.Context, cfg config.Config, healthChecks []models.HealthCheck)
func (*EndpointManager) Start ¶
func (m *EndpointManager) Start(ctx context.Context)
func (*EndpointManager) Status ¶
func (m *EndpointManager) Status() string
Status returns the current state of the state machine
Source Files
¶
Click to show internal directories.
Click to hide internal directories.