Documentation
¶
Index ¶
- Variables
- func LogErrFunc(err error)
- func SequenceTickerLoop(ctx context.Context, errFn ErrFunc, duration time.Duration, exitMsg string, ...)
- func SleepCanClose(sleepTime time.Duration, closeCh chan struct{})
- func TickerLoop(ctx context.Context, errFn ErrFunc, duration time.Duration, ...)
- type ErrFunc
- type GoroutineStopper
- type Item
- type PriorityQueue
- type StopableFunc
- type Trigger
- type TriggerCallback
- type TriggerEvent
- type TriggerOption
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func LogErrFunc ¶
func LogErrFunc(err error)
func SequenceTickerLoop ¶
func SleepCanClose ¶
Types ¶
type GoroutineStopper ¶
type GoroutineStopper struct {
// contains filtered or unexported fields
}
GoroutineStopper 提出container和shard的公共属性 抽象数据结构,也会引入数据结构之间的耦合
func (*GoroutineStopper) Close ¶
func (stopper *GoroutineStopper) Close()
func (*GoroutineStopper) Wrap ¶
func (stopper *GoroutineStopper) Wrap(fn StopableFunc)
type Item ¶
type Item struct { Value string // The value of the item; arbitrary. Priority int64 // The priority of the item in the queue. // The index is needed by update and is maintained by the heap.Interface methods. Index int // The index of the item in the heap. }
An Item is something we manage in a priority queue.
type PriorityQueue ¶
type PriorityQueue []*Item
A PriorityQueue implements heap.Interface and holds Items.
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)
type StopableFunc ¶
type Trigger ¶
type Trigger interface { Register(key string, callback TriggerCallback) error Put(event *TriggerEvent) error ForEach(visitor func(it interface{}) error) error Close() }
func NewTrigger ¶
func NewTrigger(opts ...TriggerOption) (Trigger, error)
type TriggerCallback ¶
TriggerCallback 把event的value给到调用方
type TriggerEvent ¶
type TriggerEvent struct { Key string Value interface{} }
type TriggerOption ¶
type TriggerOption func(options *triggerOptions)
func WithWorkerSize ¶
func WithWorkerSize(v int) TriggerOption
Click to show internal directories.
Click to hide internal directories.