timewheel

package module
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 9 Imported by: 0

README

timewheel-redis

介绍

  • 基于redis的时间轮实现
  • 可多机部署

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddTimerOption

type AddTimerOption func(*addTimerOptions)

func WithForce

func WithForce() AddTimerOption

will delete old target if exists

func WithPayload

func WithPayload(payload []byte) AddTimerOption

type Callback added in v0.3.0

type Callback func(*Timer) bool

type OptionFunc

type OptionFunc func(*TimeWheel)

func WithConcurrent added in v0.3.3

func WithConcurrent(concurrent int) OptionFunc

func WithContext

func WithContext(ctx context.Context) OptionFunc

func WithEnableEvalRO

func WithEnableEvalRO(enableEvalRO bool) OptionFunc

func WithInterval

func WithInterval(interval time.Duration) OptionFunc

func WithRetryMax added in v0.3.4

func WithRetryMax(retryMax int) OptionFunc

retryMax == 0 means never retry retryMax < 0 means always retry

func WithRetrySleep added in v0.3.3

func WithRetrySleep(retrySleep time.Duration) OptionFunc

func WithSlotNums

func WithSlotNums(slotNums int64) OptionFunc

type TimeWheel

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

func NewTimeWheel

func NewTimeWheel(client *redis.Client, name string, callback Callback, opts ...OptionFunc) *TimeWheel

func (*TimeWheel) AddTimer

func (wheel *TimeWheel) AddTimer(id string, delay time.Duration, opts ...AddTimerOption) error

func (*TimeWheel) GetTimer added in v0.3.2

func (wheel *TimeWheel) GetTimer(id string) (time.Duration, error)

func (*TimeWheel) RemoveTimer

func (wheel *TimeWheel) RemoveTimer(id string) error

func (*TimeWheel) ResetTimer added in v0.3.2

func (wheel *TimeWheel) ResetTimer(id string, delay time.Duration) error

func (*TimeWheel) Run

func (wheel *TimeWheel) Run()

func (*TimeWheel) Stop

func (wheel *TimeWheel) Stop()

type Timer

type Timer struct {
	Id      string
	Payload []byte
}

Jump to

Keyboard shortcuts

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