replicaset

package
v3.0.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalAny

func EvalAny(instances []running.InstanceCtx, iEvaler InstanceEvaler) error

EvalAny calls evaler once for one connectable instance.

func EvalForeach

func EvalForeach(instances []running.InstanceCtx, iEvaler InstanceEvaler) error

EvalForeach calls evaler for each instance.

func EvalForeachAlive

func EvalForeachAlive(instances []running.InstanceCtx, iEvaler InstanceEvaler) error

EvalForeachAlive calls evaler for each connectable instance.

func Rebootstrap

func Rebootstrap(cmdCtx cmdcontext.CmdCtx, rbCtx RebootstrapCtx) error

Rebootstrap re-bootstraps the instance by stopping it, removing its artifacts, and starting it again.

Types

type BootstrapCtx

type BootstrapCtx struct {
	// Timeout describes a timeout in seconds.
	// We keep int as it can be passed to the target instance.
	Timeout int
	// BootstrapVShard is true when the vshard must be bootstrapped.
	BootstrapVShard bool
	// Instance is an instance name to bootstrap.
	Instance string
	// Replicaset is a replicaset name for an instance bootstrapping.
	Replicaset string
}

BootstrapCtx describes the context to bootstrap an instance/application.

type Bootstrapper

type Bootstrapper interface {
	// Bootstrap bootstraps an instance/application.
	Bootstrap(ctx BootstrapCtx) error
}

Bootstrapper is an interface to bootstrap an instance/application.

type CConfigApplication

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

CConfigApplication is an application with the centralized config orchestrator.

func NewCConfigApplication

func NewCConfigApplication(
	runningCtx running.RunningCtx,
	collectors sdkcluster.Factory,
	publishers sdkcluster.Factory,
	integ integrityPkg.IntegrityCtx,
) *CConfigApplication

NewCConfigApplication creates a new CConfigApplication object.

func (*CConfigApplication) Bootstrap

func (c *CConfigApplication) Bootstrap(BootstrapCtx) error

Bootstrap is not supported for an application by the centralized config orchestrator.

func (*CConfigApplication) BootstrapVShard

func (c *CConfigApplication) BootstrapVShard(ctx VShardBootstrapCtx) error

BootstrapVShard bootstraps vshard for an application by the centralized config orchestrator.

func (*CConfigApplication) Demote

func (c *CConfigApplication) Demote(ctx DemoteCtx) error

Demote demotes an instance in the application.

func (*CConfigApplication) Discovery

func (c *CConfigApplication) Discovery(behavior CacheBehavior) (Replicasets, error)

Discovery discovers via underlying type. If behavior is UseCache and there is a cached result, returns it.

func (*CConfigApplication) Expel

func (c *CConfigApplication) Expel(ctx ExpelCtx) error

Expel expels an instance from the centralized config's replicasets.

func (*CConfigApplication) Promote

func (c *CConfigApplication) Promote(ctx PromoteCtx) error

Promote promotes an instance in the application.

func (*CConfigApplication) RolesChange

func (c *CConfigApplication) RolesChange(ctx RolesChangeCtx,
	changeRoleAction RolesChangerAction,
) error

RolesChange adds/removes role for an application by the centralized config orchestrator.

type CConfigInstance

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

CConfigInstance is an instance with the centralized config orchestrator.

func NewCConfigInstance

func NewCConfigInstance(evaler connector.Evaler) *CConfigInstance

NewCConfigInstance create a new CConfigInstance object for the evaler.

func (*CConfigInstance) Bootstrap

func (c *CConfigInstance) Bootstrap(BootstrapCtx) error

Bootstrap is not supported for a single instance by the centralized config orchestrator.

func (*CConfigInstance) BootstrapVShard

func (c *CConfigInstance) BootstrapVShard(ctx VShardBootstrapCtx) error

BootstrapVShard bootstraps vshard for a single instance by the centralized config orchestrator.

func (*CConfigInstance) Demote

func (c *CConfigInstance) Demote(ctx DemoteCtx) error

Demote is not supported for a single instance by the centralized config orchestrator.

func (*CConfigInstance) Discovery

func (c *CConfigInstance) Discovery(behavior CacheBehavior) (Replicasets, error)

Discovery discovers via underlying type. If behavior is UseCache and there is a cached result, returns it.

func (*CConfigInstance) Expel

func (c *CConfigInstance) Expel(ctx ExpelCtx) error

Expel is not supported for a single instance by the centralized config orchestrator.

func (*CConfigInstance) Promote

func (c *CConfigInstance) Promote(ctx PromoteCtx) error

Promote promotes an instance.

func (*CConfigInstance) RolesChange

func (c *CConfigInstance) RolesChange(ctx RolesChangeCtx,
	changeRoleAction RolesChangerAction,
) error

RolesChange is not supported for a single instance by the centralized config orchestrator.

type CConfigSource

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

CConfigSource describes the cluster config source.

func NewCConfigSource

func NewCConfigSource(collector sdkcluster.DataCollector, publisher DataPublisher,
	keyPicker KeyPicker,
) *CConfigSource

NewCConfigSource creates CConfigSource.

func (*CConfigSource) ChangeRole

func (c *CConfigSource) ChangeRole(ctx RolesChangeCtx, action RolesChangerAction) error

ChangeRole patches a config with addition/removing role.

func (*CConfigSource) Demote

func (c *CConfigSource) Demote(ctx DemoteCtx) error

Demote patches a config to demote an instance.

func (*CConfigSource) Expel

func (c *CConfigSource) Expel(ctx ExpelCtx) error

Expel patches a config to expel an instance.

func (*CConfigSource) Promote

func (c *CConfigSource) Promote(ctx PromoteCtx) error

Promote patches a config to promote an instance.

type CacheBehavior

type CacheBehavior bool

CacheBehavior describes a cache behavior.

const (
	UseCache  CacheBehavior = false
	SkipCache               = true
)

type CustomApplication

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

CustomApplication is an application with a custom orchestrator.

func NewCustomApplication

func NewCustomApplication(runningCtx running.RunningCtx) *CustomApplication

NewCustomApplication creates a new CustomApplication object.

func (*CustomApplication) Bootstrap

func (c *CustomApplication) Bootstrap(BootstrapCtx) error

Bootstrap is not supported for an application by the Custom orchestrator.

func (*CustomApplication) BootstrapVShard

func (c *CustomApplication) BootstrapVShard(VShardBootstrapCtx) error

BootstrapVShard is not supported for an application the Custom orchestrator.

func (*CustomApplication) Demote

func (c *CustomApplication) Demote(ctx DemoteCtx) error

Demote is not supported for an application by the Custom orchestrator.

func (*CustomApplication) Discovery

func (c *CustomApplication) Discovery(behavior CacheBehavior) (Replicasets, error)

Discovery discovers via underlying type. If behavior is UseCache and there is a cached result, returns it.

func (*CustomApplication) Expel

func (c *CustomApplication) Expel(ctx ExpelCtx) error

Expel is not supported for an application by the Custom orchestrator.

func (*CustomApplication) Promote

func (c *CustomApplication) Promote(ctx PromoteCtx) error

Promote is not supported for an application by the Custom orchestrator.

func (*CustomApplication) RolesChange

func (c *CustomApplication) RolesChange(_ RolesChangeCtx,
	action RolesChangerAction,
) error

RolesChange is not supported for an application by the Custom orchestrator.

type CustomInstance

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

CustomInstance is an instance with custom/unknown orchestrator. In this case, we can obtain a minimum of information for a replicaset.

func NewCustomInstance

func NewCustomInstance(evaler connector.Evaler) *CustomInstance

NewCustomInstance creates a new CustomInstance object for the evaler.

func (*CustomInstance) Bootstrap

func (c *CustomInstance) Bootstrap(BootstrapCtx) error

Bootstrap is not supported for a single instance by the Custom orchestrator.

func (*CustomInstance) BootstrapVShard

func (c *CustomInstance) BootstrapVShard(VShardBootstrapCtx) error

BootstrapVShard is not supported for a single instance by the Custom orchestrator.

func (*CustomInstance) Demote

func (c *CustomInstance) Demote(ctx DemoteCtx) error

Demote is not supported for a single instance by the Custom orchestrator.

func (*CustomInstance) Discovery

func (c *CustomInstance) Discovery(behavior CacheBehavior) (Replicasets, error)

Discovery discovers via underlying type. If behavior is UseCache and there is a cached result, returns it.

func (*CustomInstance) Expel

func (c *CustomInstance) Expel(ctx ExpelCtx) error

Expel is not supported for a single instance by the Custom orchestrator.

func (*CustomInstance) Promote

func (c *CustomInstance) Promote(ctx PromoteCtx) error

Promote is not supported for a single instance by the Custom orchestrator.

func (*CustomInstance) RolesChange

func (c *CustomInstance) RolesChange(_ RolesChangeCtx, action RolesChangerAction) error

RolesChange is not supported for a single instance by the Custom orchestrator.

type DataPublisher

type DataPublisher interface {
	// Publish publishes the config.
	Publish(key string, revision int64, data []byte) error
}

DataPublisher can publish the config by the specified key, which contains the prefix.

type DemoteCtx

type DemoteCtx struct {
	// InstName is an instance name to demote.
	InstName string
	// Force is true when demoting can skip
	// some non-critical checks.
	Force bool
	// Timeout is a timeout for demoting waitings in seconds.
	// Keep int, because it can be passed to the target instance.
	Timeout int
}

DemoteCtx describes a context for an instance demoting.

type Demoter

type Demoter interface {
	// Demote demotes an instance.
	Demote(ctx DemoteCtx) error
}

Demoter is an interface to demote an instance in the replicaset.

type Discoverer

type Discoverer interface {
	// Discovery returns replicasets information or an error.
	Discovery(behavior CacheBehavior) (Replicasets, error)
}

Discoverer is an interface for discovering information about replicasets.

type ElectionMode

type ElectionMode int

ElectionMode defines an enumeration of election types.

const (
	// ElectionModeUnknown is unknown election mode type.
	ElectionModeUnknown ElectionMode = iota // unknown
	// ElectionModeOff is a "off" election_mode for centralized config.
	ElectionModeOff // off
	// ElectionModeVoter is a "voter" election_mode for centralized config.
	ElectionModeVoter // voter
	// ElectionModeCandidate is a "candidate" election_mode for centralized config.
	ElectionModeCandidate // candidate
	// ElectionModeManual is a "manual" election_mode for centralized config.
	ElectionModeManual // manual
)

func ParseElectionMode

func ParseElectionMode(str string) ElectionMode

ParseElectionMode returns an election type from a string representation.

func (ElectionMode) String

func (i ElectionMode) String() string

type ExpelCtx

type ExpelCtx struct {
	// InstName is an instance name to expel.
	InstName string
	// Force is true when expelling can skip
	// some non-critical checks.
	Force bool
	// Timeout is a timeout for expelling waitings in seconds.
	// Keep int, because it can be passed to the target instance.
	Timeout int
}

ExpelCtx describes a context for an instance expelling.

type Expeller

type Expeller interface {
	// Expel expels instance from a replicasets by its name.
	Expel(ctx ExpelCtx) error
}

Expeller is an interface for expelling instances from a replicaset.

type Failover

type Failover int

Failover defines an enumeration of failover types.

const (
	// FailoverUnknown is unknown type of a failover.
	FailoverUnknown Failover = iota // unknown
	// FailoverOff is a disabled failover.
	// Is is a "off" failover type for the centralized config.
	FailoverOff // off
	// FailoverManual is a "manual" failover type for the centralized config.
	FailoverManual // manual
	// FailoverElection uses a RAFT based algorithm for the leader election.
	// Is is a "election" failover type for the centralized config.
	FailoverElection // election
	// FailoverSupervised is a "supervised" failover type for the centralized config.
	FailoverSupervised // supervised
)

func ParseFailover

func ParseFailover(str string) Failover

ParseFailover returns a failover type from a string representation.

func (Failover) String

func (i Failover) String() string

type Instance

type Instance struct {
	// Alias is a human-readable instance name.
	Alias string `mapstructure:"alias"`
	// UUID of the instance.
	UUID string `mapstructure:"uuid"`
	// URI of the instance.
	URI string `mapstructure:"uri"`
	// Mode of the instance.
	Mode Mode `mapstructure:"mode"`
	// InstanceCtx is an instance application context. It is configured if
	// InstanceCtxFound == true.
	InstanceCtx running.InstanceCtx `mapstructure:"-"`
	// InstanceCtxFound is true if an instance is connectable and could be
	// determined.
	InstanceCtxFound bool `mapstructure:"-"`
}

Instance describes an instance in a replicaset.

type InstanceEvalFunc

type InstanceEvalFunc func(instance running.InstanceCtx,
	evaler connector.Evaler) (bool, error)

InstanceEvalFunc helps to use a function as the InstanceEvaler interface.

func (InstanceEvalFunc) Eval

func (fun InstanceEvalFunc) Eval(instance running.InstanceCtx,
	evaler connector.Evaler,
) (bool, error)

Eval helps to satisfy the InstanceEvaler interface.

type InstanceEvaler

type InstanceEvaler interface {
	// Eval could return true or an error to stop execution.
	Eval(instance running.InstanceCtx, evaler connector.Evaler) (bool, error)
}

InstanceEvaler is the interface that wraps Eval method for an instance.

type KeyPicker

type KeyPicker func(keys []string, force bool, pathMsg string) (int, error)

KeyPicker picks a key to patch.

type Master

type Master int

Master defines an enumeration of master types.

const (
	// MasterUnknown is unknown type of a replicaset.
	MasterUnknown Master = iota // unknown
	// MasterNo is used when no master in a replicaset.
	MasterNo // no
	// MasterSingle is used when there is a single master in a replicaset.
	MasterSingle // single
	// MasterMulti is used when there are > 1 master in a replicaset.
	MasterMulti // multi
)

func (Master) String

func (i Master) String() string

type Mode

type Mode int

Mode defines an enumeration of read-write modes for an instance.

const (
	// ModeUnknown is used when read-write mode is unknown.
	ModeUnknown Mode = iota // unknown
	// ModeRead is used when box.cfg.read_only = true.
	ModeRead // read
	// ModeRW is used when box.cfg.read_only = false.
	ModeRW // rw
)

func (Mode) String

func (i Mode) String() string

type Orchestrator

type Orchestrator int

Orchestrator defines an enumeration of available orchestrators.

const (
	// OrchestratorUnknown is an unknown orchestrator.
	OrchestratorUnknown Orchestrator = iota // unknown
	// OrchestratorCentralizedConfig is centralized config for Tarantool 3.0.
	OrchestratorCentralizedConfig // centralized config
	// OrchestratorCustom is a custom orchestrator.
	OrchestratorCustom // custom
)

func (Orchestrator) String

func (i Orchestrator) String() string

type PromoteCtx

type PromoteCtx struct {
	// InstName is an instance name to promote.
	InstName string
	// Force is true when promoting can skip
	// some non-critical checks.
	Force bool
	// Timeout is a timeout for promoting waitings in seconds.
	// Keep int, because it can be passed to the target instance.
	Timeout int
}

PromoteCtx describes a context for an instance promoting.

type Promoter

type Promoter interface {
	// Promote promotes an instance.
	Promote(ctx PromoteCtx) error
}

Promoter is an interface to promote an instance in the replicaset.

type RebootstrapCtx

type RebootstrapCtx struct {
	// Instance is the instance to re-bootstrap, as the instance commands
	// resolve it.
	Instance running.InstanceCtx
	// Confirmed is true if re-bootstrap confirmation is not required.
	Confirmed bool
}

RebootstrapCtx contains rebootstrap operations arguments.

type Replicaset

type Replicaset struct {
	// UUID is UUID of the replicaset.
	UUID string
	// LeaderUUID is UUID of the leader in the replicaset. Could be "" if there
	// is no configured leader.
	LeaderUUID string
	// Alias is an alias name of the replicaset.
	Alias string
	// Roles is a list of roles of the replicaset.
	Roles []string
	// Master is a current master mode.
	Master Master
	// Failover is a configured failover.
	Failover Failover
	// Instances is a list of instances in the replicaset.
	Instances []Instance
}

Replicaset describes a single replicaset.

type Replicasets

type Replicasets struct {
	// State is a current state.
	State State
	// Orchestrator is a used orchestrator.
	Orchestrator Orchestrator
	// Replicasets is a list of replicasets.
	Replicasets []Replicaset
}

Replicasets describes a set of replicasets.

type RoleAction

type RoleAction uint

RoleAction is a type that describes an action that will happen with Roles. It can be "add" action which corresponds 0 or "remove" which is 1.

const (
	AddAction RoleAction = iota
	RemoveAction
)

type RolesAdder

type RolesAdder struct{}

RolesAdder is a struct that implements addition of role.

func (RolesAdder) Action

func (RolesAdder) Action() RoleAction

Action implements getter of add action.

func (RolesAdder) Change

func (RolesAdder) Change(roles []string, r string) ([]string, error)

Change implements addition of role.

type RolesChangeCtx

type RolesChangeCtx struct {
	// InstName is an instance name in which add/remove role.
	InstName string
	// GroupName is an instance name in which add/remove role.
	GroupName string
	// ReplicasetName is an instance name in which add/remove role.
	ReplicasetName string
	// IsGlobal is an boolean value if role needs to add/remove in global scope.
	IsGlobal bool
	// RoleName is a role name which needs to add/remove into config.
	RoleName string
	// Force is true when promoting can skip
	// some non-critical checks.
	Force bool
	// Timeout is a timeout for promoting waitings in seconds.
	// Keep int, because it can be passed to the target instance.
	Timeout int
}

RolesChangeCtx describes a context for adding/removing roles.

type RolesChanger

type RolesChanger interface {
	// RolesChange adds/removes role for a replicasets by its name.
	RolesChange(ctx RolesChangeCtx, action RolesChangerAction) error
}

RolesChanger is an interface for adding/removing roles for a replicaset.

type RolesChangerAction

type RolesChangerAction interface {
	// ChangeRoleFunc is a function type for addition or removing a role.
	Change(roles []string, role string) ([]string, error)
	// Action is a method that returns RoleAction.
	Action() RoleAction
}

RolesChangerAction implements changing (add or remove) of roles.

type RolesRemover

type RolesRemover struct{}

RolesRemover is a struct that implements removing of role.

func (RolesRemover) Action

func (RolesRemover) Action() RoleAction

Action implements getter of remove action.

func (RolesRemover) Change

func (RolesRemover) Change(roles []string, r string) ([]string, error)

Change implements removing of role.

type State

type State int

State defines an enumeration of available replicaset states.

const (
	// StateUnknown when is unable to get a replicaset configuration.
	StateUnknown State = iota // unknown
	// StateUninitialized when a configuration found, but not bootstrapped yet.
	StateUninitialized // uninitialized
	// StateBootstrapped when a replicaset already bootstrapped.
	StateBootstrapped // bootstrapped
)

func (State) String

func (i State) String() string

type VShardBootstrapCtx

type VShardBootstrapCtx struct {
	// Timeout is a timeout for bootstrapping in seconds.
	// Keep int, because it can be passed to the target instance.
	Timeout int
}

VShardBootstrapCtx describes context to bootstrap vshard.

type VShardBootstrapper

type VShardBootstrapper interface {
	// BootstrapVShard bootstraps vshard in the cluster.
	BootstrapVShard(ctx VShardBootstrapCtx) error
}

VShardBootstrapper performs vshard bootstrapping.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL