locker

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock struct to abstract bsm/redis-lock

func (*Lock) Run

func (l *Lock) Run(key string, timeout time.Duration, handler func())

Run runs a callback handler with a Redis lock.

type Locker

type Locker interface {
	Run(key string, timeout time.Duration, handler func())
}

Locker interface to abstract bsm/redis-lock

func New

func New(opts ...Option) Locker

New creates instance of Locker

type Option

type Option func(*Options)

Option closure

func Logger

func Logger(l logger.Logger) Option

Logger closure to set field in Options

func Redis

func Redis(r *redis.Client) Option

Redis closure to set field in Options

type Options

type Options struct {
	Redis  *redis.Client
	Logger logger.Logger
}

Options for creating Locker instance

Jump to

Keyboard shortcuts

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