utils

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyPrefix is prefix for keys inserted in etcd as a part of etcd-backup-restore tests.
	KeyPrefix = "/etcdbr/test/key-"
	// ValuePrefix is prefix for value inserted in etcd as a part of etcd-backup-restore tests.
	ValuePrefix = "val-"
	// EmbeddedEtcdPortNo defines PortNo which can be used to start EmbeddedEtcd.
	EmbeddedEtcdPortNo = "12379"
	// DefaultEtcdName defines the default etcd name used to start EmbeddedEtcd.
	DefaultEtcdName = "default"
)

Variables

This section is empty.

Functions

func CheckDataConsistency

func CheckDataConsistency(ctx context.Context, dir string, keyTo int, logger *logrus.Entry) error

CheckDataConsistency starts an embedded etcd and checks for correctness of the values stored in etcd against the keys 'keyFrom' through 'keyTo'

func ContextWithGracePeriod

func ContextWithGracePeriod(parent context.Context, gracePeriod time.Duration) context.Context

ContextWithGracePeriod returns a new context, whose Done channel is closed when parent context is closed with additional <gracePeriod>.

func ContextWithWaitGroup

func ContextWithWaitGroup(parent context.Context, wg *sync.WaitGroup) context.Context

ContextWithWaitGroup returns a copy of parent with a new Done channel. The returned context's Done channel is closed when the the passed waitGroup's Wait function is called or when the parent context's Done channel is closed, whichever happens first.

func ContextWithWaitGroupFollwedByGracePeriod

func ContextWithWaitGroupFollwedByGracePeriod(parent context.Context, wg *sync.WaitGroup, gracePeriod time.Duration) context.Context

ContextWithWaitGroupFollwedByGracePeriod returns a new context, whose Done channel is closed when parent context is closed or wait of waitGroup is over, with additional <gracePeriod>.

func PopulateEtcd

func PopulateEtcd(ctx context.Context, logger *logrus.Entry, endpoints []string, keyFrom, keyTo int, response *EtcdDataPopulationResponse)

PopulateEtcd sequentially puts key-value pairs into the embedded etcd, from key <keyFrom> (including) to <keyTo> (excluding). Every key divisible by 10 will be be added and deleted immediately. So, for such key you will observer two events on etcd PUT and DELETE and key not being present in etcd at end.

func PopulateEtcdWithWaitGroup

func PopulateEtcdWithWaitGroup(ctx context.Context, wg *sync.WaitGroup, logger *logrus.Entry, endpoints []string, resp *EtcdDataPopulationResponse)

PopulateEtcdWithWaitGroup sequentially puts key-value pairs into the embedded etcd, until stopped via context. Use `wg.Wait()` to make sure that etcd population has stopped completely.

func RunSnapshotter

func RunSnapshotter(logger *logrus.Entry, snapstoreConfig brtypes.SnapstoreConfig, deltaSnapshotPeriod time.Duration, endpoints []string, stopCh <-chan struct{}, startWithFullSnapshot bool, compressionConfig *compressor.CompressionConfig) error

RunSnapshotter creates a snapshotter object and runs it for a duration specified by 'snapshotterDurationSeconds'

func StartEmbeddedEtcd

func StartEmbeddedEtcd(ctx context.Context, etcdDir string, logger *logrus.Entry, name string, port string) (*embed.Etcd, error)

StartEmbeddedEtcd starts the embedded etcd for test purpose with minimal configuration at a given port. To get the exact client endpoints it is listening on, use returns etcd.Clients[0].Addr().String()

Types

type EtcdDataPopulationResponse

type EtcdDataPopulationResponse struct {
	KeyTo       int
	EndRevision int64
	Err         error
}

EtcdDataPopulationResponse is response about etcd data population

Jump to

Keyboard shortcuts

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