volume

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TickerDuration is the duration of the internal loop of the volume
	// to recalculate the state
	TickerDuration = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Local

type Local interface {
	Volume

	// Close will try to make a clean shutdown
	io.Closer

	// ID returns the ID of the Volume
	ID() string

	// NextReplica returns the next replica
	// inline. A "not found" error means
	// no replica is needed
	NextReplica(ctx context.Context) (*replica.Replica, error)

	// UpdateReplica updates the rp of the index and the File to include
	// the vID as a volume with the Replica
	UpdateReplica(ctx context.Context, rp *replica.Replica, vID string) error

	// SynchronizeReplicas checks the replicas related with vID and
	// if this volume is the responsible (next after the removed ID on the files)
	// will start replication of those files which have to
	SynchronizeReplicas(ctx context.Context, vID string) error

	// GetState returns the current State of the volume
	GetState(ctx context.Context) (*state.State, error)

	// Reset will clean all the data of the volume and even change the ID
	Reset(ctx context.Context) error
}

Local is the definition of a Local volume which is an extension of the volume.Volume

func New

func New(root string, files file.Repository, idxkeys idxkey.Repository, idxvolumes idxvolume.Repository, rp replica.Repository, sr state.Repository, fileSystem afero.Fs, logger kitlog.Logger, suow uow.StartUnitOfWork) (Local, error)

New returns an implementation of the volume.Local interface using the provided parameters it can return an error because when initialized it also creates the needed directories if they are missing which are $root/file and $root/tmps and also the ID To define a total size of the volume it has to be appended to the root like `/v1:1GB`

type Volume

type Volume interface {
	// CreateFile creates a new file from the reader with the key, there are
	// 4 different use cases to consider:
	// * New key and reader
	// * New key with already known reader
	// * Already known key with new reader
	// * Already known key and reader
	CreateFile(ctx context.Context, key string, reader io.ReadCloser, replica int) error

	// GetFile search for the file with the key
	GetFile(ctx context.Context, key string) (io.ReadCloser, error)

	// HasFile checks if a file with the key exists and returns the volumeID
	// of where is it.
	// It's possible to return a vid but false that means we know which volume
	// has it but it's not this one
	HasFile(ctx context.Context, key string) (string, bool, error)

	// DeleteFile deletes the key, if the key points to a
	// file with 2 keys, then just the key will be deleted
	// and not the content
	DeleteFile(ctx context.Context, key string) error

	// UpdateFileReplica updates the Replica information of the file
	// with the given one basically replacing it
	UpdateFileReplica(ctx context.Context, key string, volumeIDs []string, replica int) error
}

Volume is an interface to deal with the simples actions and basic ones

Jump to

Keyboard shortcuts

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