Documentation ¶
Overview ¶
Package bucket implements a rolling bucket system.
Index ¶
Constants ¶
View Source
const (
// QueueName is identity of the queue.
QueueName = "block-queue-cleanup"
)
Variables ¶
View Source
var ( // ErrInvalidParameter denotes input parameters are invalid. ErrInvalidParameter = errors.New("parameters are invalid") // ErrNoMoreBucket denotes the bucket volume reaches the limitation. ErrNoMoreBucket = errors.New("no more buckets") )
View Source
var (
// DummyReporter is a special Reporter to avoid nil errors.
DummyReporter = &dummyReporter{}
)
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { Current() (Reporter, error) Next() (Reporter, error) OnMove(prev, next Reporter) }
Controller defines the provider of a Reporter.
type OnAddRecentFn ¶ added in v0.2.0
type OnAddRecentFn func() error
OnAddRecentFn is a notifier on adding an item into the recent queue.
type Queue ¶
type Queue interface { Touch(id fmt.Stringer) bool Push(ctx context.Context, id fmt.Stringer, fn OnAddRecentFn) error Remove(id fmt.Stringer) Len() int Volume() int All() []fmt.Stringer }
Queue is a LRU queue.
type Reporter ¶
type Reporter interface { // TODO: refactor Report to return a status. It's too complicated to return a channel Report() (Channel, error) String() string }
Reporter allows reporting status to its supervisor.
type Strategy ¶
type Strategy struct {
// contains filtered or unexported fields
}
Strategy controls Reporters with Controller's help.
func NewStrategy ¶
func NewStrategy(ctrl Controller, options ...StrategyOptions) (*Strategy, error)
NewStrategy returns a Strategy.
type StrategyOptions ¶
type StrategyOptions func(*Strategy)
StrategyOptions sets how to create a Strategy.
func WithLogger ¶
func WithLogger(logger *logger.Logger) StrategyOptions
WithLogger sets a logger.Logger.
func WithNextThreshold ¶
func WithNextThreshold(r ratio) StrategyOptions
WithNextThreshold sets a ratio to creat the next Reporter.
Click to show internal directories.
Click to hide internal directories.