dsf

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

README

dsf: Distributed SingleFlight

Inspired by singleflight, this package provides a similar suppresion mechanism for distributed senerios.

For usage please refer to the examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group interface {
	Do(jobKey string, job Job) (result []byte, shared bool, err error)
	Forget(jobKey string) (err error)
}

func New

func New(opt Option) Group

type Job

type Job func() []byte

type Option

type Option interface{}

type OptionBuilder

type OptionBuilder interface {
	Build() Option

	WithContext(ctx context.Context) OptionBuilder
	WithRedisClient(client RedisClient) OptionBuilder
	WithNamespace(namespace string) OptionBuilder

	WithLockExpiration(exp time.Duration) OptionBuilder
	WithDataExpiration(exp time.Duration) OptionBuilder
	KeepLock(flag bool) OptionBuilder
	WithWaitTime(duration time.Duration) OptionBuilder
	WithInterval(makeInterval func(retryTimes int) time.Duration) OptionBuilder
}

func NewOptionBuilder

func NewOptionBuilder() OptionBuilder

type RedisClient

type RedisClient interface {
	Context(ctx context.Context) RedisClient

	Nil() interface{}
	Get(key string) ([]byte, error)
	Set(key string, val []byte, exp time.Duration) error
	Del(key string) error
	Eval(script string, keys []string, args ...interface{}) (interface{}, error)
}

Jump to

Keyboard shortcuts

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