control

package
v0.0.0-...-817062f Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

README

Controller

The Controller is the core of blobcache, it takes in a set of blobs to store (called Sources) and a set of stores to manage (called Sinks). Then whenever something changes in one of the Sources, the controller checks to see if anything needs to be shuffled around in the Sinks. If something needs to be done, the Controller enqueues an operation to Add or Delete the blob. Eventually the queued operations are flushed to the sink as a batch.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicTarget

type BasicTarget struct {
	Store cadata.Store
}

func (BasicTarget) Actual

func (t BasicTarget) Actual() ReadOnlyStore

func (BasicTarget) Flush

func (t BasicTarget) Flush(ctx context.Context, ops []Op) error

func (BasicTarget) Refresh

func (t BasicTarget) Refresh(ctx context.Context, src ReadOnlyStore, desired ReadOnlySet) error

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller manages where to store blobs

func New

func New(log *logrus.Logger, getSet func(name string) cadata.Set) *Controller

New creates a new Controller getSet will be called to create sets for tracking the desired blobs in each sink.

func (*Controller) AttachSink

func (c *Controller) AttachSink(name string, sink Sink)

func (*Controller) AttachSource

func (c *Controller) AttachSource(name string, source Source)

func (*Controller) Close

func (c *Controller) Close() error

func (*Controller) Flush

func (c *Controller) Flush(ctx context.Context, source string) error

Flush blocks until any blobs pending for source have been persisted by the appropriate sinks.

func (*Controller) Notify

func (c *Controller) Notify(ctx context.Context, id cadata.ID) error

Notify tells the controller than an ID has been added or deleted in one of the sources. Notify blocks while the controller updates the desired sets but does not wait until all sink sets are reconciled.

func (*Controller) Refresh

func (c *Controller) Refresh(ctx context.Context) error

Refresh causes the controller to reprocess all of the blobs in the attached sources.

type Cost

type Cost struct {
	// Post is the cost to Post a blob
	Post float64
	// Get is the cost to retreive a blob
	Get float64
	// Delete is the cost to delete a blob
	Delete float64
	// List is the cost to list n blobs
	List func(n int) float64
	// BlobSecond is the cost to store 1 blob for 1 second
	BlobSecond float64
}

type Op

type Op struct {
	ID  cadata.ID
	Src ReadOnlyStore
}

Op is an operation to be done to a sink

func (*Op) IsDelete

func (op *Op) IsDelete() bool

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

func NewPlanner

func NewPlanner(log *logrus.Logger) *Planner

func (*Planner) AttachSink

func (p *Planner) AttachSink(name string, desired cadata.Set, cost Cost, notify func(cadata.ID, bool))

func (*Planner) AttachSource

func (p *Planner) AttachSource(name string, source Source)

func (*Planner) Refresh

func (p *Planner) Refresh(ctx context.Context) error

Refresh causes the planner to reprocess all of the blobs in the attached sources.

func (*Planner) RefreshSpan

func (p *Planner) RefreshSpan(ctx context.Context, span cadata.Span) error

func (*Planner) SinkChange

func (p *Planner) SinkChange(ctx context.Context, id cadata.ID) error

func (*Planner) SourceChange

func (p *Planner) SourceChange(ctx context.Context, id cadata.ID) error

type ReadOnlySet

type ReadOnlySet interface {
	cadata.Lister
	cadata.Exister
}

ReadOnlySet is a read-only cadata.Set

type ReadOnlyStore

type ReadOnlyStore interface {
	cadata.Getter
	cadata.Lister
}

type Sink

type Sink struct {
	Locus    [32]byte
	MaxCount int64
	Cost     Cost

	// BatchSize is the size of batches passed to flush.
	// If BatchSize == 0. Then there is no batching for the Sink.
	// If BatchSize < 0.  Then the magnitude is interpretted as the maximum number of concurrent operations.
	BatchSize int
	// BatchDelay is the longest an operation should be queued in a batch before pre-emptively
	// flushing a batch below BatchSize.
	BatchDelay time.Duration
	Target     Target
}

Sinks are places where blobs can be stored.

type Source

type Source struct {
	Set              ReadOnlySet
	ExpectedReplicas float64
}

Source provides blobs to be maintained by the controller

type Target

type Target interface {
	// Actual returns a read only store with the actual content of the sink.
	Actual() ReadOnlyStore
	// FlushFunc is called to apply a batch of point operations to the target.
	Flush(ctx context.Context, ops []Op) error
	// Refresh is called to resync a target.
	Refresh(ctx context.Context, src ReadOnlyStore, desired ReadOnlySet) error
}

Jump to

Keyboard shortcuts

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