cluster

package
v0.0.0-...-7f7efcf Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SimpleOperationTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func ConnectToInstance

func ConnectToInstance(instanceName string, ctx *context.Ctx) (*connector.Conn, error)

func ConnectToMembership

func ConnectToMembership(conn *connector.Conn, runningInstancesNames map[string]string,
	instancesConf *InstancesConf) error

func ConnectToSomeJoinedInstance

func ConnectToSomeJoinedInstance(ctx *context.Ctx) (*connector.Conn, error)

ConnectToSomeJoinedInstance connects to some instance joined to cluster. It's used for actions with joined cluster, e.g. setting replicaset parameters.

func ConnectToSomeRunningInstance

func ConnectToSomeRunningInstance(ctx *context.Ctx) (*connector.Conn, error)

ConnectToSomeRunningInstance connects to some running instance. It's used for some actions that can be performed via any instance socket, no matter if this instance is joined to cluster or not. For example, to get known roles or vhsard groups list.

func GetJoinedInstanceName

func GetJoinedInstanceName(instancesConf *InstancesConf, ctx *context.Ctx) (string, error)

GetJoinedInstanceName returns a name of local instance that is already joined to cluster. It gets all local membership instances and checks if there is some instance that has UUID (it means that this instance is joined to cluster). The main reason of using membership here is that instances that aren't joined can see joined instances only if they are connected to the one membership.

func GetRandomInstanceName

func GetRandomInstanceName(instances map[string]string) string

GetRandomInstanceName returns random instance name from the map. Empty string is returned if the map is empty.

func HealthCheckIsNeeded

func HealthCheckIsNeeded(conn *connector.Conn) (bool, error)

Types

type InstanceConf

type InstanceConf struct {
	URI string `yaml:"advertise_uri"`
}

type InstancesConf

type InstancesConf map[string]*InstanceConf

func GetInstancesConf

func GetInstancesConf(ctx *context.Ctx) (*InstancesConf, error)

type InstancesFilter

type InstancesFilter func(*MembershipInstances, map[string]string)

type MembershipInstance

type MembershipInstance struct {
	URI string

	Alias  string
	UUID   string
	Status string
}

func (*MembershipInstance) DecodeMsgpack

func (membershipInstance *MembershipInstance) DecodeMsgpack(d *msgpack.Decoder) error

type MembershipInstances

type MembershipInstances map[string]*MembershipInstance

func GetMembershipInstances

func GetMembershipInstances(instancesConf *InstancesConf, ctx *context.Ctx,
	filters ...InstancesFilter) (*MembershipInstances, error)

GetMembershipInstances returns MembershipInstances for currently configured instances First, it connects all instances to membership (probes all running instances by one of them). Then, it gets all membership instances members. filters are an Options pattern to perform modifications of the instances container.

func GetMembershipInstancesFromConn

func GetMembershipInstancesFromConn(conn *connector.Conn) (*MembershipInstances, error)

Jump to

Keyboard shortcuts

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