throttler

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

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