cluster

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

View Source
var ErrConfigFile = errors.New("cannot read the cluster config file")

ErrConfigFile is wrapped by the error of OpenConfigStorage for a cluster config file that cannot be read as one.

Functions

func BuildGoConfigFromBytes

func BuildGoConfigFromBytes(ctx context.Context, data []byte) (goconfig.Config, error)

BuildGoConfigFromBytes parses YAML bytes into a goconfig.Config with inheritance configured to match the Tarantool cluster hierarchy (Global → groups → replicasets → instances). No validation is performed.

A nil or empty slice produces an empty but fully-configured Config.

func BuildMutableFromBytes

func BuildMutableFromBytes(ctx context.Context, data []byte) (*goconfig.MutableConfig, error)

BuildMutableFromBytes parses YAML bytes into a *goconfig.MutableConfig with inheritance configured to match the Tarantool cluster hierarchy. No validation is performed (WithoutValidation), so Set calls never roll back.

A nil or empty slice produces an empty but fully-configured MutableConfig.

func CollectDataBytes

func CollectDataBytes(ctx context.Context, collector sdkcluster.DataCollector) ([]byte, error)

CollectDataBytes collects raw []Data from a DataCollector, merges the YAML documents with first-wins priority (mirrors the former YamlDataMergeCollector behaviour), and returns the merged YAML bytes.

func DescribeStorage

func DescribeStorage(storageType string, endpoints []string, prefix, key string) string

DescribeStorage names a config storage for a message: its type, as sdkcluster names it, the endpoints, and the prefix and the key of the cluster config, when there are, such as `etcd http://127.0.0.1:2379, prefix "/tt"`. The credentials an endpoint may carry are hidden.

func FindGroupByReplicaset

func FindGroupByReplicaset(cfg goconfig.Config, replicaset string) (string, bool)

FindGroupByReplicaset scans EffectiveAll() keys and returns the group that contains the given replicaset name.

func FindInstance

func FindInstance(cfg goconfig.Config, name string) (string, string, bool)

FindInstance scans EffectiveAll() keys to locate the instance with the given name, returning its containing group and replicaset names.

func GetClusterConfig

func GetClusterConfig(
	ctx context.Context,
	path string,
	integ integrity.IntegrityCtx,
) (*goconfig.MutableConfig, error)

GetClusterConfig returns a cluster configuration loaded from a path to a config file. It uses a config file, etcd and default environment variables as sources. The function returns a cluster config as is, without merging of settings from scopes: global, group, replicaset, instance.

The documented Tarantool config priority is `TT_*` > file > centralized (etcd / config storage) > `TT_*_DEFAULT`. gcttarantool.Builder folds `TT_*_DEFAULT` into its lowest slot, alongside the file pass, and the fill-only merge strategy means a single Build() call would let `TT_*_DEFAULT` block the post-Build centralized merge. To honor the documented order without taking the TT-1011 storage-handle path, the env-default layer is split out via two builds and applied last.

func GetInstanceConfig

func GetInstanceConfig(
	cfg *goconfig.MutableConfig,
	instance string,
) (goconfig.Config, error)

GetInstanceConfig returns a goconfig.Config view for the named instance within the given cluster config. It delegates to cluster.InstanceConfig.

func HasInstance

func HasInstance(cfg goconfig.Config, name string) bool

HasInstance reports whether an instance with the given name exists in cfg.

func InstanceConfig

func InstanceConfig(cfg goconfig.Config, name string) (goconfig.Config, error)

InstanceConfig returns the inheritance-resolved configuration of the instance named name in cfg: sdk.InstanceConfig. An unknown instance wraps sdk.ErrNotFound.

func Instances

func Instances(cfg goconfig.Config) ([]string, error)

Instances returns a sorted list of instance names found in cfg: sdk.Instances.

func NewBytesSource

func NewBytesSource(name string, data []byte) (goconfig.Collector, error)

NewBytesSource creates a goconfig Collector backed by the given YAML bytes. name is used as the source name (for diagnostics). The returned Collector can be passed to goconfig.Builder.AddCollector.

func NewCollectorAndPublisherFactories

func NewCollectorAndPublisherFactories(
	integ integrity.IntegrityCtx, privateKey string,
) (sdkcluster.Factory, sdkcluster.Factory, error)

NewCollectorAndPublisherFactories returns separate collector- and publisher-oriented factories. They differ only in integrity options: collectors carry verifiers, publishers carry signer/verifiers.

func NewCollectorFactory

func NewCollectorFactory(integ integrity.IntegrityCtx) (sdkcluster.Factory, error)

NewCollectorFactory creates a cluster Factory configured for collecting data — integrity-aware (with verifiers) when integ has integrity configured. Returns a plain factory and nil error when integrity is not configured.

func NewPublisherFactory

func NewPublisherFactory(privateKey string) (sdkcluster.Factory, error)

NewPublisherFactory creates a cluster Factory configured for publishing data — integrity-aware (with signer/verifiers) when privateKey is set.

func StorageReference

func StorageReference(cfg goconfig.Config) (string, bool)

StorageReference returns the section of cfg, the file part of a cluster config, that points to a config storage, config.etcd or config.storage, and false when it has neither: the cluster config is then the file itself. A section without endpoints counts as well, since tarantool takes it for one.

func Validate

func Validate(cfg goconfig.Config) error

Validate validates a goconfig.Config as a cluster configuration against the embedded JSON Schema for the newest known Tarantool version. Every key is checked on the level it stands on: "leader" and "bootstrap_leader" are accepted in a replicaset only, as Tarantool accepts them, and are refused globally, in a group and in an instance.

func ValidateInstance

func ValidateInstance(cfg goconfig.Config) error

ValidateInstance validates a goconfig.Config as the configuration of one instance, the one sdk.InstanceConfig resolves: the global section, the group, the replicaset and the instance folded into one.

The folded config holds what only a replicaset may set, "leader" and "bootstrap_leader", next to what any level may, so it is checked against the schema of the cluster config with those keys of the replicaset added. On which level a key stands is not left in the folded config: Validate of the cluster config checks that, and a key on a wrong level is refused there. A key unknown to Tarantool and a value of a wrong type are refused here as well.

Types

type ConfigStorage

type ConfigStorage struct {
	// Collector reads the cluster config kept in the storage.
	Collector sdkcluster.DataCollector
	// Publisher writes it.
	Publisher sdkcluster.DataPublisher
	// FileInstances are the instances the file declares itself, next to the
	// reference to the storage: they are in the topology whatever the
	// storage holds, as the file wins over the storage.
	FileInstances []string
	// Where names the storage for a message (DescribeStorage), with the
	// endpoint connected to and the reference of the file it comes from,
	// such as `etcd http://127.0.0.1:2379, prefix "/tt" (config.etcd of
	// /path/config.yaml)`.
	Where string
	// contains filtered or unexported fields
}

ConfigStorage is the config storage a cluster config file points to, connected (OpenConfigStorage).

func OpenConfigStorage

func OpenConfigStorage(ctx context.Context, path string,
	collectors, publishers sdkcluster.Factory,
) (*ConfigStorage, bool, error)

OpenConfigStorage connects to the config storage that the cluster config file at path points to with config.etcd or config.storage, as tarantool reads them from the file and the TT_ environment: its endpoints, prefix, credentials and TLS settings. It returns false when the file points to no storage. A Tarantool config storage is served by the first of its endpoints that can be connected to.

The collector and the publisher come from collectors and publishers, as for a storage given by its URI. A file that names a storage without endpoints is an error: there is nowhere to publish to, and writing the file over would drop its reference to the storage.

func (*ConfigStorage) Close

func (s *ConfigStorage) Close()

Close closes the connection to the storage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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