flowcontrol

package
v0.0.0-...-4a6ce05 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Jitter

func Jitter(d time.Duration) time.Duration

func RunWorker

func RunWorker[T comparable](ctx context.Context, queue *Queue[T], fn func(T) error)

Types

type Loop

type Loop struct {
	Handler LoopTickHandler
	// contains filtered or unexported fields
}

func (*Loop) Kick

func (l *Loop) Kick()

Kick makes the handler run NOW (if it isn't already running)

func (*Loop) Run

func (l *Loop) Run(ctx context.Context)

type LoopTickHandler

type LoopTickHandler func(context.Context) time.Duration

func RetryHandler

func RetryHandler(interval time.Duration, fn func(context.Context) bool) LoopTickHandler

type Queue

type Queue[T comparable] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T comparable]() *Queue[T]

func (*Queue[T]) Add

func (q *Queue[T]) Add(key T)

func (*Queue[T]) Done

func (q *Queue[T]) Done(key T)

func (*Queue[T]) Get

func (q *Queue[T]) Get() T

func (*Queue[T]) Retry

func (q *Queue[T]) Retry(key T)

func (*Queue[T]) Run

func (q *Queue[T]) Run(ctx context.Context)

type QueueItem

type QueueItem[T comparable] struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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