throttler

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: AGPL-3.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddKeyToQueueRequest

type AddKeyToQueueRequest struct {
	QueueName    string
	QueueWindow  *int64
	Priority     int64
	CreationTime time.Time
}

type PopDetail

type PopDetail struct {
	QueueName string
	CanPop    bool
	Reason    string
}

type SnapshotObj

type SnapshotObj struct {
	Name             string                     `json:"name"`
	QueueByName      map[string]json.RawMessage `json:"queueByName"`      // queueByName 无法从 keyRelatedQueues 中还原,因为可能存在空队列
	KeyRelatedQueues map[string][]string        `json:"keyRelatedQueues"` // 只关心加入了哪些队列,无需重复引用队列
}

type Throttler

type Throttler interface {
	// Name 节流阀的名字
	Name() string

	// AddQueue 幂等创建队列
	AddQueue(name string, window int64)

	// AddKeyToQueues 幂等将 key 同时插入指定队列;若队列不存在,则会首先幂等创建队列;若不同时插入,则可能直接被调度了
	AddKeyToQueues(key string, reqs []AddKeyToQueueRequest)

	PopPending(key string) (bool, []PopDetail)
	PopProcessing(key string) (bool, []PopDetail)

	snapshot.Snapshot
}

func NewNamedThrottler

func NewNamedThrottler(name string, initQueues map[string]int64) Throttler

Jump to

Keyboard shortcuts

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