idempotency

package
v0.0.0-...-6d4bf48 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package idempotency provides a duplicate function call suppression mechanism. It is a lightly modified version of groupcache's singleflight package that does not forget keys until explicitly told to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

Group represents a class of work and forms a namespace in which units of work can be executed with duplicate suppression.

func (*Group) Forget

func (g *Group) Forget(key string)

Forget forgets a key, allowing the next call for the key to execute the function.

func (*Group) Once

func (g *Group) Once(key string, fn func() (interface{}, error)) (interface{}, error)

Once executes and returns the results of the given function, making sure that only one execution for a given key happens until the key is explicitly forgotten. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results.

Jump to

Keyboard shortcuts

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