storelimit

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SmallRegionThreshold is used to represent a region which can be regarded as a small region once the size is small than it.
	SmallRegionThreshold int64 = 20
	// Unlimited is used to control the store limit. Here uses a big enough number to represent unlimited.
	Unlimited = float64(100000000)
)

Variables

View Source
var RegionInfluence = map[Type]int64{
	AddPeer:    1000,
	RemovePeer: 1000,
}

RegionInfluence represents the influence of a operator step, which is used by store limit.

View Source
var SmallRegionInfluence = map[Type]int64{
	AddPeer:    200,
	RemovePeer: 200,
}

SmallRegionInfluence represents the influence of a operator step when the region size is smaller than smallRegionThreshold, which is used by store limit.

View Source
var TypeNameValue = map[string]Type{
	"add-peer":    AddPeer,
	"remove-peer": RemovePeer,
}

TypeNameValue indicates the name of store limit type and the enum value

Functions

This section is empty.

Types

type Scene

type Scene struct {
	Idle   int
	Low    int
	Normal int
	High   int
}

Scene defines the store limitation on difference scenes Idle/Low/Normal/High indicates the load of the cluster, it is defined in cluster.State. See the details there for how to calculate the load. The values here defines the store-limit for each load. For example: Idle = 60, means that change the store-limit to 60 when the cluster is idle.

func DefaultScene

func DefaultScene(limitType Type) *Scene

DefaultScene returns Scene object with default values

type StoreLimit

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

StoreLimit limits the operators of a store

func NewStoreLimit

func NewStoreLimit(ratePerSec float64, regionInfluence int64) *StoreLimit

NewStoreLimit returns a StoreLimit object

func (*StoreLimit) Available

func (l *StoreLimit) Available() int64

Available returns the number of available tokens

func (*StoreLimit) Rate

func (l *StoreLimit) Rate() float64

Rate returns the fill rate of the bucket, in tokens per second.

func (*StoreLimit) Take

func (l *StoreLimit) Take(count int64) time.Duration

Take takes count tokens from the bucket without blocking.

type Type

type Type int

Type indicates the type of store limit

const (
	// AddPeer indicates the type of store limit that limits the adding peer rate
	AddPeer Type = iota
	// RemovePeer indicates the type of store limit that limits the removing peer rate
	RemovePeer
)

func (Type) String

func (t Type) String() string

String returns the representation of the Type

Jump to

Keyboard shortcuts

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