2021-01-27 19:00:35 +00:00
|
|
|
package loadcontroller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
2021-01-27 19:00:35 +00:00
|
|
|
)
|
|
|
|
|
2022-06-28 07:01:05 +00:00
|
|
|
// UsedSpaceHandler describes the signature of the container.SizeEstimation
|
2021-01-27 19:00:35 +00:00
|
|
|
// 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.
|
2022-06-28 07:01:05 +00:00
|
|
|
type UsedSpaceHandler func(container.SizeEstimation) error
|
2021-01-27 19:00:35 +00:00
|
|
|
|
|
|
|
// UsedSpaceFilter describes the signature of the function for
|
|
|
|
// checking whether a value meets a certain criterion.
|
|
|
|
//
|
|
|
|
// Return of true means conformity, false - vice versa.
|
2022-06-28 07:01:05 +00:00
|
|
|
type UsedSpaceFilter func(container.SizeEstimation) bool
|
2021-01-27 19:00:35 +00:00
|
|
|
|
|
|
|
// Iterator is a group of methods provided by entity
|
2022-06-28 07:01:05 +00:00
|
|
|
// which can iterate over a group of container.SizeEstimation values.
|
2021-01-27 19:00:35 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
// IteratorProvider is a group of methods provided
|
|
|
|
// by entity which generates iterators over
|
2022-06-28 07:01:05 +00:00
|
|
|
// container.SizeEstimation values.
|
2021-01-27 19:00:35 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2022-06-28 07:01:05 +00:00
|
|
|
// Writer describes the interface for storing container.SizeEstimation values.
|
2021-01-27 19:00:35 +00:00
|
|
|
//
|
|
|
|
// This interface is provided by both local storage
|
|
|
|
// of values and remote (wrappers over the RPC).
|
|
|
|
type Writer interface {
|
2022-06-28 07:01:05 +00:00
|
|
|
// Put performs a write operation of container.SizeEstimation value
|
2021-01-27 19:00:35 +00:00
|
|
|
// 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.
|
2022-06-28 07:01:05 +00:00
|
|
|
Put(container.SizeEstimation) error
|
2021-01-27 19:00:35 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:29:46 +00:00
|
|
|
// WriterProvider is a group of methods provided
|
2021-01-27 19:00:35 +00:00
|
|
|
// by entity which generates keepers of
|
2022-06-28 07:01:05 +00:00
|
|
|
// container.SizeEstimation values.
|
2021-01-27 19:00:35 +00:00
|
|
|
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)
|
|
|
|
}
|