Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller represents main handler for starting and interrupting container volume estimation.
It binds the interfaces of the local value stores to the target storage points. Controller is abstracted from the internal storage device and the network location of the connecting components. At its core, it is a high-level start-stop trigger for calculations.
For correct operation, the controller must be created using the constructor (New) based on the required parameters and optional components. After successful creation, the constructor is immediately ready to work through API of external control of calculations and data transfer.
func New ¶
func New(prm Prm, opts ...Option) *Controller
New creates a new instance of the Controller.
Panics if at least one value of the parameters is invalid.
The created Controller does not require additional initialization and is completely ready for work
func (*Controller) Start ¶
func (c *Controller) Start(prm StartPrm)
Start starts the processing of container.SizeEstimation values.
Single Start operation overtakes all data from LocalMetrics to LocalAnnouncementTarget (Controller's parameters). No filter by epoch is used for the iterator, since it is expected that the source of metrics does not track the change of epochs.
Each call acquires an announcement context for an Epoch parameter. At the very end of the operation, the context is released.
func (*Controller) Stop ¶
func (c *Controller) Stop(prm StopPrm)
Stop interrupts the processing of container.SizeEstimation values.
Single Stop operation releases an announcement context and overtakes all data from AnnouncementAccumulator to ResultReceiver (Controller's parameters). Only values for the specified Epoch parameter are processed.
Each call acquires a report context for an Epoch parameter. At the very end of the operation, the context is released.
type Iterator ¶
type Iterator interface { // Iterate must start an iterator over values that // meet the filter criterion (returns true). // For each such value should call a handler, the error // of which should be directly returned from the method. // // Internal failures of the iterator are also signaled via // an error. After a successful call to the last value // handler, nil should be returned. Iterate(UsedSpaceFilter, UsedSpaceHandler) error }
Iterator is a group of methods provided by entity which can iterate over a group of container.SizeEstimation values.
type IteratorProvider ¶
type IteratorProvider interface { // InitIterator should return an initialized Iterator. // // Initialization problems are reported via error. // If no error was returned, then the Iterator must not be nil. // // Implementations can have different logic for different // contexts, so specific ones may document their own behavior. InitIterator(context.Context) (Iterator, error) }
IteratorProvider is a group of methods provided by entity which generates iterators over container.SizeEstimation values.
func SimpleIteratorProvider ¶
func SimpleIteratorProvider(i Iterator) IteratorProvider
type Option ¶
type Option func(*options)
Option sets an optional parameter of Controller.
func WithLogger ¶
WithLogger returns option to specify logging component.
type Prm ¶
type Prm struct { // Iterator over the used space values of the containers // collected by the node locally. LocalMetrics IteratorProvider // Place of recording the local values of // the used space of containers. LocalAnnouncementTarget WriterProvider // Iterator over the summarized used space scores // from the various network participants. AnnouncementAccumulator IteratorProvider // Place of recording the final estimates of // the used space of containers. ResultReceiver WriterProvider }
Prm groups the required parameters of the Controller's constructor.
All values must comply with the requirements imposed on them. Passing incorrect parameter values will result in constructor failure (error or panic depending on the implementation).
type StartPrm ¶
type StartPrm struct { // Epoch number by which you want to select // the values of the used space of containers. Epoch uint64 }
StartPrm groups the required parameters of the Controller.Start method.
type StopPrm ¶
type StopPrm struct { // Epoch number the analysis of the values of which must be interrupted. Epoch uint64 }
StopPrm groups the required parameters of the Controller.Stop method.
type UsedSpaceFilter ¶
type UsedSpaceFilter func(container.SizeEstimation) bool
UsedSpaceFilter describes the signature of the function for checking whether a value meets a certain criterion.
Return of true means conformity, false - vice versa.
type UsedSpaceHandler ¶
type UsedSpaceHandler func(container.SizeEstimation) error
UsedSpaceHandler describes the signature of the container.SizeEstimation value handling function.
Termination of processing without failures is usually signaled with a zero error, while a specific value may describe the reason for failure.
type Writer ¶
type Writer interface { // Put performs a write operation of container.SizeEstimation value // and returns any error encountered. // // All values after the Close call must be flushed to the // physical target. Implementations can cache values before // Close operation. // // Put must not be called after Close. Put(container.SizeEstimation) error // Close exits with method-providing Writer. // // All cached values must be flushed before // the Close's return. // // Methods must not be called after Close. io.Closer }
Writer describes the interface for storing container.SizeEstimation values.
This interface is provided by both local storage of values and remote (wrappers over the RPC).
type WriterProvider ¶
type WriterProvider interface { // InitWriter should return an initialized Writer. // // Initialization problems are reported via error. // If no error was returned, then the Writer must not be nil. // // Implementations can have different logic for different // contexts, so specific ones may document their own behavior. InitWriter(context.Context) (Writer, error) }
WriterProvider is a group of methods provided by entity which generates keepers of container.SizeEstimation values.
func SimpleWriterProvider ¶
func SimpleWriterProvider(w Writer) WriterProvider