Documentation
¶
Index ¶
- func BuildWorkerStorageKey(prefix, hostName, workerName string) string
- func ChangeRole(url string, ctx RolesChangeCtx, action replicaset.RolesChangerAction) error
- func ConnectStorage(opts sdkconnect.URIOpts, username, password string) (storage.Storage, func(), error)
- func Demote(url string, ctx DemoteCtx) error
- func Expel(url string, ctx ExpelCtx) error
- func ParseWorkerPath(urlPath string) (string, string, string, error)
- func Promote(url string, ctx PromoteCtx) error
- func PublishApp(publishCtx PublishCtx, path, instance string) error
- func PublishURI(publishCtx PublishCtx, opts connect.URIOpts) error
- func ShowCluster(showCtx ShowCtx, path, name string) error
- func ShowURI(showCtx ShowCtx, opts connect.URIOpts) error
- func Switch(url string, switchCtx SwitchCtx) error
- func SwitchStatus(url string, switchCtx SwitchStatusCtx) error
- func WorkerDelete(deleteCtx WorkerDeleteCtx) error
- func WorkerPublish(publishCtx WorkerPublishCtx) error
- func WorkerShow(showCtx WorkerShowCtx) ([]byte, error)
- type DemoteCtx
- type ExpelCtx
- type PromoteCtx
- type PublishCtx
- type RolesChangeCtx
- type ShowCtx
- type SwitchCtx
- type SwitchStatusCtx
- type WorkerDeleteCtx
- type WorkerPublishCtx
- type WorkerShowCtx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildWorkerStorageKey ¶
BuildWorkerStorageKey builds the storage key for a worker configuration. The format is: /<prefix>/instances/<host-name>/<worker-name>.
func ChangeRole ¶
func ChangeRole(url string, ctx RolesChangeCtx, action replicaset.RolesChangerAction) error
ChangeRole adds/removes a role by patching the cluster config.
func ConnectStorage ¶
func ConnectStorage(opts sdkconnect.URIOpts, username, password string, ) (storage.Storage, func(), error)
ConnectStorage connects to etcd or Tarantool configuration storage.
func ParseWorkerPath ¶
ParseWorkerPath parses a URL path and extracts prefix, hostName and workerName. The expected format is: /prefix/host-name/worker-name where the last two segments are host-name and worker-name, and everything before them is the prefix.
Example: /tdb-workers/tdb-cluster/host1/http-server-1 → prefix="/tdb-workers/tdb-cluster", hostName="host1", workerName="http-server-1".
func Promote ¶
func Promote(url string, ctx PromoteCtx) error
Promote promotes an instance by patching the cluster config.
func PublishApp ¶
func PublishApp(publishCtx PublishCtx, path, instance string) error
PublishApp publishes a configuration into the cluster config of the pair of an application, the file at path: into the config storage the file points to with config.etcd or config.storage, with the endpoints, the prefix, the credentials and the TLS settings it gives, and into the file itself when it points to none.
A file that points to a storage is left as it is. Written over with the whole config, it would no longer point there: its instances would leave the storage for the file at their next start, while the storage kept the config they left. The instances the file declares itself next to the reference stay in the topology the config is checked with (PublishCtx.CheckTopology), as the file wins over the storage.
A file that cannot be read as a cluster config points to no storage tarantool could follow either, and the config goes into it, mending it; what kept it from being read is told.
func PublishURI ¶
func PublishURI(publishCtx PublishCtx, opts connect.URIOpts) error
PublishURI publishes a configuration to URI.
func ShowCluster ¶
ShowCluster shows a full cluster configuration for a configuration path.
func SwitchStatus ¶
func SwitchStatus(url string, switchCtx SwitchStatusCtx) error
SwitchStatus shows master switching status.
func WorkerDelete ¶
func WorkerDelete(deleteCtx WorkerDeleteCtx) error
WorkerDelete deletes a worker configuration from storage. Without Force flag, it atomically checks that the key exists and deletes the configuration. If the key does not exist, an error is returned. With Force flag, it deletes the configuration unconditionally.
func WorkerPublish ¶
func WorkerPublish(publishCtx WorkerPublishCtx) error
WorkerPublish publishes a worker configuration to storage. Without Force flag, it atomically checks that the key does not exist and publishes the configuration. If the key already exists, an error is returned. With Force flag, it overwrites the existing configuration unconditionally.
func WorkerShow ¶
func WorkerShow(showCtx WorkerShowCtx) ([]byte, error)
WorkerShow shows a worker configuration from storage. It returns an error if the configuration is not found.
Types ¶
type DemoteCtx ¶
type DemoteCtx struct {
// InstName is an instance name to demote.
InstName string
// Publishers is data publisher factory.
Publishers sdkcluster.Factory
// Collectors is data collector factory.
Collectors sdkcluster.Factory
// Username defines a username for connection.
Username string
// Password defines a password for connection.
Password string
// Force true if the key selection for patching the config
// should be skipped.
Force bool
}
DemoteCtx describes the context to demote an instance.
type ExpelCtx ¶
type ExpelCtx struct {
// InstName is an instance name to demote.
InstName string
// Publishers is data publisher factory.
Publishers sdkcluster.Factory
// Collectors is data collector factory.
Collectors sdkcluster.Factory
// Username defines a username for connection.
Username string
// Password defines a password for connection.
Password string
// Force true if the key selection for patching the config
// should be skipped.
Force bool
}
ExpelCtx describes the context to expel an instance.
type PromoteCtx ¶
type PromoteCtx struct {
// InstName is an instance name to promote.
InstName string
// Publishers is data publisher factory.
Publishers sdkcluster.Factory
// Collectors is data collector factory.
Collectors sdkcluster.Factory
// Username defines a username for connection.
Username string
// Password defines a password for connection.
Password string
// Force true if the key selection for patching the config
// should be skipped.
Force bool
}
PromoteCtx describes the context to promote an instance.
type PublishCtx ¶
type PublishCtx struct {
// Username defines a username for connection.
Username string
// Password defines a password for connection.
Password string
// Force defines whether the publish should be forced and a validation step
// is omitted.
Force bool
// Publishers defines a used data publishers factory.
Publishers sdkcluster.Factory
// Collectors defines a used data collectors factory.
Collectors sdkcluster.Factory
// Src is raw YAML data to publish.
Src []byte
// Config is the decoded payload from Src (map[string]any from YAML
// unmarshal). Used by the per-instance publish path.
Config map[string]any
// Group is a group name for a new instance configuration publishing.
Group string
// Replicaset is a replicaset name for a new instance configuration publishing.
Replicaset string
// CheckTopology, when set, checks the names of the instances of the
// cluster config about to be published, whole, before it is written: the
// pair of an application refuses a config that leaves out an instance of
// its description. nil checks nothing, as for a config storage given by
// its URI.
CheckTopology func(topology []string) error
// Source names the file Src is read from, for the messages.
Source string
// Confirm, when set, is asked whether to publish, with a question that
// says what is published where, once what is to be published has been
// checked and before anything is written: false cancels the publication
// with nothing written. nil publishes without asking.
Confirm func(question string) (bool, error)
}
PublishCtx contains information about cluster publish command execution context.
type RolesChangeCtx ¶
type RolesChangeCtx struct {
// InstName is an instance name in which add/remove role.
InstName string
// GroupName is an replicaset name in which add/remove role.
GroupName string
// ReplicasetName is an replicaset 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 name of role to add/remove.
RoleName string
// Publishers is data publisher factory.
Publishers sdkcluster.Factory
// Collectors is data collector factory.
Collectors sdkcluster.Factory
// Username defines a username for connection.
Username string
// Password defines a password for connection.
Password string
// Force true if the key selection for patching the config
// should be skipped.
Force bool
}
RolesChangeCtx describes the context to add/remove role.
type ShowCtx ¶
type ShowCtx struct {
// Username defines a username for connection.
Username string
// Password defines a password for connection.
Password string
// Collectors defines a used data collectors factory for URI-based show.
Collectors sdkcluster.Factory
// Integrity holds the integrity context used for file-based show.
Integrity integrity.IntegrityCtx
// Validate defines whether the command will check the showed
// configuration.
Validate bool
}
ShowCtx contains information about cluster show command execution context.
type SwitchCtx ¶
type SwitchCtx struct {
// InstName is an instance name to switch the master.
InstName string
// Username defines a username for connection.
Username string
// Password defines a password for connection.
Password string
// Wait for the command to complete execution.
Wait bool
// Timeout for command execution.
Timeout uint64
}
SwitchCtx describes the context to switch the master instance.
type SwitchStatusCtx ¶
type SwitchStatusCtx struct {
// Task ID.
TaskID string
}
SwitchStatusCtx describes the context to the master switching status.
type WorkerDeleteCtx ¶
type WorkerDeleteCtx struct {
// Storage is the storage instance for the operation.
Storage storage.Storage
// Key is the key in storage for the worker configuration.
Key string
// Force defines whether the delete should be forced (skip existence check).
Force bool
}
WorkerDeleteCtx contains information about cluster worker delete command execution context.
type WorkerPublishCtx ¶
type WorkerPublishCtx struct {
// Storage is the storage instance for the operation.
Storage storage.Storage
// Key is the key in storage for the worker configuration.
Key string
// Src is a raw data to publish.
Src []byte
// Force defines whether the publish should be forced.
Force bool
}
WorkerPublishCtx contains information about cluster worker publish command execution context.
type WorkerShowCtx ¶
type WorkerShowCtx struct {
// Storage is the storage instance for the operation.
Storage storage.Storage
// Key is the key in storage for the worker configuration.
Key string
}
WorkerShowCtx contains information about cluster worker show command execution context.