idempotence

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout       = 5 * time.Second // 5 seconds
	DefaultSuccessfulTTL = 24 * time.Hour  // 24 hours
	StatusProcessing     = "processing"
	StatusProcessed      = "processed"
)

Variables

View Source
var ErrConflict = errors.New("conflict")

Functions

func WithSuccessfulTTL

func WithSuccessfulTTL(successfulTTL time.Duration) func(opts *IdempotenceImplOptions)

func WithTimeout

func WithTimeout(timeout time.Duration) func(opts *IdempotenceImplOptions)

Types

type Idempotence

type Idempotence interface {
	Exec(ctx context.Context, key string, exec func(context.Context) error) error
}

func New

func New(redisClient *redis.Client, opts ...func(opts *IdempotenceImplOptions)) Idempotence

type IdempotenceImpl

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

func (*IdempotenceImpl) Exec

func (i *IdempotenceImpl) Exec(ctx context.Context, key string, exec func(context.Context) error) error

type IdempotenceImplOptions

type IdempotenceImplOptions struct {
	Timeout       time.Duration
	SuccessfulTTL time.Duration
}

Jump to

Keyboard shortcuts

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