config

package
v1.8.1-0...-0157f87 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnkownStorageType   = errors.New("unknown storage type")
	ErrMissedConfig        = errors.New("missed config")
	ErrMissedConfigProfile = errors.New("missed config profile")
	ErrUnsetConfigPath     = bsoncore.ErrElementNotFound
)

Functions

func AddProfile

func AddProfile(ctx context.Context, m connect.Client, profile *Config) error

func GetConfigVar

func GetConfigVar(ctx context.Context, m connect.Client, key string) (interface{}, error)

GetConfigVar returns value of given config vaiable

func IsPITREnabled

func IsPITREnabled(ctx context.Context, m connect.Client) (bool, bool, error)

func RemoveProfile

func RemoveProfile(ctx context.Context, m connect.Client, name string) error

func SetConfig

func SetConfig(ctx context.Context, m connect.Client, cfg *Config) error

SetConfig stores config doc within the database. It also applies default storage parameters depending on the type of storage and assigns those possible default values to the cfg parameter.

func SetConfigVar

func SetConfigVar(ctx context.Context, m connect.Client, key, val string) error

Types

type BackupConf

type BackupConf struct {
	OplogSpanMin     float64                  `bson:"oplogSpanMin" json:"oplogSpanMin" yaml:"oplogSpanMin"`
	Priority         Priority                 `bson:"priority,omitempty" json:"priority,omitempty" yaml:"priority,omitempty"`
	Timeouts         *BackupTimeouts          `bson:"timeouts,omitempty" json:"timeouts,omitempty" yaml:"timeouts,omitempty"`
	Compression      compress.CompressionType `bson:"compression,omitempty" json:"compression,omitempty" yaml:"compression,omitempty"`
	CompressionLevel *int                     `bson:"compressionLevel,omitempty" json:"compressionLevel,omitempty" yaml:"compressionLevel,omitempty"`

	NumParallelCollections int `bson:"numParallelCollections" json:"numParallelCollections,omitempty" yaml:"numParallelCollections,omitempty"`
}

func (*BackupConf) Clone

func (cfg *BackupConf) Clone() *BackupConf

type BackupTimeouts

type BackupTimeouts struct {
	// Starting is timeout (in seconds) to wait for a backup to start.
	Starting *uint32 `bson:"startingStatus,omitempty" json:"startingStatus,omitempty" yaml:"startingStatus,omitempty"`
}

func (*BackupTimeouts) StartingStatus

func (t *BackupTimeouts) StartingStatus() time.Duration

StartingStatus returns timeout duration for . If not set or zero, returns default value (WaitBackupStart).

type Config

type Config struct {
	Name      string `bson:"name,omitempty" json:"name,omitempty" yaml:"name,omitempty"`
	IsProfile bool   `bson:"profile,omitempty" json:"profile,omitempty" yaml:"profile,omitempty"`

	Storage StorageConf  `bson:"storage" json:"storage" yaml:"storage"`
	PITR    *PITRConf    `bson:"pitr,omitempty" json:"pitr,omitempty" yaml:"pitr,omitempty"`
	Backup  *BackupConf  `bson:"backup,omitempty" json:"backup,omitempty" yaml:"backup,omitempty"`
	Restore *RestoreConf `bson:"restore,omitempty" json:"restore,omitempty" yaml:"restore,omitempty"`

	Epoch primitive.Timestamp `bson:"epoch" json:"-" yaml:"-"`
}

Config is a pbm config

func GetConfig

func GetConfig(ctx context.Context, m connect.Client) (*Config, error)

func GetProfile

func GetProfile(ctx context.Context, m connect.Client, name string) (*Config, error)

func GetProfiledConfig

func GetProfiledConfig(ctx context.Context, conn connect.Client, profile string) (*Config, error)

func ListProfiles

func ListProfiles(ctx context.Context, m connect.Client) ([]Config, error)

func Parse

func Parse(r io.Reader) (*Config, error)

func (*Config) BackupSlicerInterval

func (c *Config) BackupSlicerInterval() time.Duration

BackupSlicerInterval returns interval for backup slicer routine. If it is not confugured, the function returns general oplog slicer interval.

func (*Config) Clone

func (c *Config) Clone() *Config

func (*Config) OplogSlicerInterval

func (c *Config) OplogSlicerInterval() time.Duration

OplogSlicerInterval returns interval for general oplog slicer routine. If it is not configured, the function returns default (hardcoded) value 10 mins.

func (*Config) String

func (c *Config) String() string

type Epoch

type Epoch primitive.Timestamp

func GetEpoch

func GetEpoch(ctx context.Context, m connect.Client) (Epoch, error)

func ResetEpoch

func ResetEpoch(ctx context.Context, m connect.Client) (Epoch, error)

func (Epoch) TS

func (e Epoch) TS() primitive.Timestamp

type PITRConf

type PITRConf struct {
	Enabled          bool                     `bson:"enabled" json:"enabled" yaml:"enabled"`
	OplogSpanMin     float64                  `bson:"oplogSpanMin,omitempty" json:"oplogSpanMin,omitempty" yaml:"oplogSpanMin,omitempty"`
	OplogOnly        bool                     `bson:"oplogOnly,omitempty" json:"oplogOnly,omitempty" yaml:"oplogOnly,omitempty"`
	Priority         Priority                 `bson:"priority,omitempty" json:"priority,omitempty" yaml:"priority,omitempty"`
	Compression      compress.CompressionType `bson:"compression,omitempty" json:"compression,omitempty" yaml:"compression,omitempty"`
	CompressionLevel *int                     `bson:"compressionLevel,omitempty" json:"compressionLevel,omitempty" yaml:"compressionLevel,omitempty"`
}

PITRConf is a Point-In-Time Recovery options

func (*PITRConf) Clone

func (cfg *PITRConf) Clone() *PITRConf

type Priority

type Priority map[string]float64

Priority contains priority values for cluster members. It is used for specifying Backup and PITR configuration priorities.

type RestoreConf

type RestoreConf struct {
	// Logical restore
	//
	// num of documents to buffer
	BatchSize              int `bson:"batchSize" json:"batchSize,omitempty" yaml:"batchSize,omitempty"`
	NumInsertionWorkers    int `bson:"numInsertionWorkers" json:"numInsertionWorkers,omitempty" yaml:"numInsertionWorkers,omitempty"`
	NumParallelCollections int `bson:"numParallelCollections" json:"numParallelCollections,omitempty" yaml:"numParallelCollections,omitempty"`

	// NumDownloadWorkers sets the num of goroutine would be requesting chunks
	// during the download. By default, it's set to GOMAXPROCS.
	NumDownloadWorkers int `bson:"numDownloadWorkers" json:"numDownloadWorkers,omitempty" yaml:"numDownloadWorkers,omitempty"`
	// MaxDownloadBufferMb sets the max size of the in-memory buffer that is used
	// to download files from the storage.
	MaxDownloadBufferMb int `bson:"maxDownloadBufferMb" json:"maxDownloadBufferMb,omitempty" yaml:"maxDownloadBufferMb,omitempty"`
	DownloadChunkMb     int `bson:"downloadChunkMb" json:"downloadChunkMb,omitempty" yaml:"downloadChunkMb,omitempty"`

	// MongodLocation sets the location of mongod used for internal runs during
	// physical restore. Will try $PATH/mongod if not set.
	MongodLocation    string            `bson:"mongodLocation" json:"mongodLocation,omitempty" yaml:"mongodLocation,omitempty"`
	MongodLocationMap map[string]string `bson:"mongodLocationMap" json:"mongodLocationMap,omitempty" yaml:"mongodLocationMap,omitempty"`
}

RestoreConf is config options for the restore

func (*RestoreConf) Clone

func (cfg *RestoreConf) Clone() *RestoreConf

type StorageConf

type StorageConf struct {
	Type       storage.Type  `bson:"type" json:"type" yaml:"type"`
	S3         *s3.Config    `bson:"s3,omitempty" json:"s3,omitempty" yaml:"s3,omitempty"`
	Azure      *azure.Config `bson:"azure,omitempty" json:"azure,omitempty" yaml:"azure,omitempty"`
	Filesystem *fs.Config    `bson:"filesystem,omitempty" json:"filesystem,omitempty" yaml:"filesystem,omitempty"`
}

StorageConf is a configuration of the backup storage

func (*StorageConf) Cast

func (s *StorageConf) Cast() error

func (*StorageConf) Clone

func (s *StorageConf) Clone() *StorageConf

func (*StorageConf) Equal

func (s *StorageConf) Equal(other *StorageConf) bool

func (*StorageConf) Path

func (s *StorageConf) Path() string

func (*StorageConf) Typ

func (s *StorageConf) Typ() string

Jump to

Keyboard shortcuts

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