config

package
v1.1.0-alpha-4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2017 License: Apache-2.0 Imports: 14 Imported by: 40

Documentation

Index

Constants

View Source
const (
	VdiskTypeBoot  = propDeduped | propPersistent | propTlogSupport | propTemplateSupport
	VdiskTypeDB    = propPersistent | propTlogSupport | propTemplateSupport
	VdiskTypeCache = propPersistent
	VdiskTypeTmp   = propTemporary
)

valid vdisk types based on /docs/README.md#zero-os-0-disk

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StorageClusters map[string]StorageClusterConfig `yaml:"storageClusters" valid:"required"`
	Vdisks          map[string]VdiskConfig          `yaml:"vdisks" valid:"required"`
	// contains filtered or unexported fields
}

Config for the zerodisk backends

func FromBytes

func FromBytes(bytes []byte, user User) (*Config, error)

FromBytes creates a config based on given YAML 1.2 content

func ReadConfig

func ReadConfig(path string, user User) (*Config, error)

ReadConfig reads the config from a given file

func (*Config) SetUser

func (cfg *Config) SetUser(user User)

SetUser sets the user, information which is used for any future validations of this config.

func (*Config) String

func (cfg *Config) String() string

String returns this config as a YAML marshalled string

func (*Config) Validate

func (cfg *Config) Validate() error

Validate the Config to ensure that all required properties are present, and that all given properties are valid

func (*Config) VdiskClusterConfig

func (cfg *Config) VdiskClusterConfig(vdiskID string) (*VdiskClusterConfig, error)

VdiskClusterConfig returns a VdiskClusterConfig for a given VdiskID if possible WARNING: make sure the config is valid before calling this method

type HotReloader

type HotReloader interface {
	// Subscribe allows you to get notified when a SIGHUP signal has been received,
	// upon which all registered channels receive the newest vdisk cluster config if possible.
	// Right upon calling this function, the given channel will already receive the last
	// available version taken from given configPath or cache.
	Subscribe(c chan<- VdiskClusterConfig, vdiskID string) error
	// Unsubscribe stops a channel from receiving the latest config for a vdisk
	// when receiving the SIGHUP signal.
	Unsubscribe(c chan<- VdiskClusterConfig) error

	// VdiskClusterConfig get the last loaded cluster config for a given VdiskID
	VdiskClusterConfig(vdiskID string) (*VdiskClusterConfig, error)
	// VdiskIdentifiers lists identifiers of the vdisks available
	// in the last loaded config
	VdiskIdentifiers() []string

	// Listen for incoming SIGHUP Signals,
	// upon which the tracked configs will be reloaded from disk,
	// and all channels will be given their new up-to-date vdisk cluster config.
	Listen(ctx context.Context)
	// Close the Listener background thread
	// and any other open resources
	Close() error
}

HotReloader is used to subscribe channels, which will receive an up-to-date vdisk cluster config, each time a SIGHUP signal has been received by the HotReloader.

func NewHotReloader

func NewHotReloader(configPath string, user User) (HotReloader, error)

NewHotReloader returns a HotReloader, which is used to subscribe channels, which will receive an up-to-date vdisk cluster config, each time a SIGHUP signal has been received by the HotReloader.

func NopHotReloader

func NopHotReloader(configPath string, user User) (HotReloader, error)

NopHotReloader returns a placeholder HotReloader, which doesn't hot reload at all, but simply returns a static configuration, usuable for places where a HotReloader is required, but where it doesn't make any sense.

type StorageClusterConfig

type StorageClusterConfig struct {
	DataStorage     []StorageServerConfig `yaml:"dataStorage" valid:"required"`
	MetadataStorage *StorageServerConfig  `yaml:"metadataStorage" valid:"optional"`
}

StorageClusterConfig defines the config for a storageCluster

func (StorageClusterConfig) Clone

func (cfg StorageClusterConfig) Clone() (clone StorageClusterConfig)

Clone this StorageClusterConfig into a new StorageClusterConfig.

type StorageServerConfig

type StorageServerConfig struct {
	Address  string `yaml:"address" valid:"dialstring,required"`
	Database int    `yaml:"db" valid:"optional"`
}

StorageServerConfig defines the config for a storage server

func ParseCSStorageServerConfigStrings

func ParseCSStorageServerConfigStrings(dialCSConfigString string) (configs []StorageServerConfig, err error)

ParseCSStorageServerConfigStrings allows you to parse a slice of raw dial config strings. Dial Config Strings are a simple format used to specify ardb connection configs easily as a command line argument. The format is as follows: `<ip>:<port>[@<db_index>][,<ip>:<port>[@<db_index>]]`, where the db_index is optional, and you can give multiple configs by seperating them with a comma.

type StorageType

type StorageType uint8

StorageType represents the type of storage of a vdisk

const (
	StorageNil     StorageType = 0
	StorageDeduped StorageType = 1 << iota
	StorageNondeduped
)

Different types of storage

func (StorageType) String

func (st StorageType) String() string

String returns the name of the storage type

func (StorageType) UInt8

func (st StorageType) UInt8() uint8

UInt8 returns the storage type as an uint8 value

type User

type User uint8

User defines the user of the config

const (
	Global    User = NBDServer | TlogServer
	NBDServer User = 1 << iota
	TlogServer
)

Supported Config Users

type VdiskClusterConfig

type VdiskClusterConfig struct {
	Vdisk       VdiskConfig
	DataCluster *StorageClusterConfig
	RootCluster *StorageClusterConfig
	TlogCluster *StorageClusterConfig
}

VdiskClusterConfig combines the vdisk config and its cluster configs

type VdiskConfig

type VdiskConfig struct {
	BlockSize           uint64    `yaml:"blockSize" valid:"optional"`
	ReadOnly            bool      `yaml:"readOnly" valid:"optional"`
	Size                uint64    `yaml:"size" valid:"optional"`
	StorageCluster      string    `yaml:"storageCluster" valid:"optional"`
	SlaveStorageCluster string    `yaml:"slaveStorageCluster" valid:"optional"`
	RootStorageCluster  string    `yaml:"rootStorageCluster" valid:"optional"`
	RootVdiskID         string    `yaml:"rootVdiskID" valid:"optional"`
	TlogStorageCluster  string    `yaml:"tlogStorageCluster" valid:"optional"`
	TlogSlaveSync       bool      `yaml:"tlogSlaveSync" valid:"optional"` // true if tlog need to sync ardb slave
	Type                VdiskType `yaml:"type" valid:"optional"`
}

VdiskConfig defines the config for a vdisk

func (*VdiskConfig) StorageType

func (cfg *VdiskConfig) StorageType() StorageType

StorageType returns the type of storage this vdisk uses

func (*VdiskConfig) TemplateSupport

func (cfg *VdiskConfig) TemplateSupport() bool

TemplateSupport returns whether or not this vdisk supports a template (root) server, to get the data in case the data isn't available on the normal (local) storage cluster. TODO: use this to add the option of template support,

both in the deduped as well as the nondeduped storage
see: https://github.com/zero-os/0-Disk/issues/223

func (*VdiskConfig) TlogSupport

func (cfg *VdiskConfig) TlogSupport() bool

TlogSupport returns whether or not the data of this vdisk has to send to the tlog server, to log its transactions.

type VdiskType

type VdiskType uint8

VdiskType represents the type of a vdisk

func (VdiskType) MarshalYAML

func (t VdiskType) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.MarshalYAML

func (*VdiskType) SetString

func (t *VdiskType) SetString(s string) error

SetString allows you to set this VdiskType using the correct string representation

func (VdiskType) String

func (t VdiskType) String() string

String returns the storage type as a string value

func (*VdiskType) UnmarshalYAML

func (t *VdiskType) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

UnmarshalYAML implements yaml.Unmarshaler.UnmarshalYAML

func (VdiskType) Validate

func (t VdiskType) Validate() error

Validate this vdisk type

Jump to

Keyboard shortcuts

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