flightcontrol

package
v0.15.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 210

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedGroup added in v0.15.0

type CachedGroup[T any] struct {
	// CacheError defines if error results should also be cached.
	// It is not safe to change this value after the first call to Do.
	// Context cancellation errors are never cached.
	CacheError bool
	// contains filtered or unexported fields
}

Group is a flightcontrol synchronization group that memoizes the results of a function and returns the cached result if the function is called with the same key. Don't use with long-running groups as the results are cached indefinitely.

func (*CachedGroup[T]) Do added in v0.15.0

func (g *CachedGroup[T]) Do(ctx context.Context, key string, fn func(ctx context.Context) (T, error)) (T, error)

Do executes a context function syncronized by the key or returns the cached result for the key.

type Group

type Group[T any] struct {
	// contains filtered or unexported fields
}

Group is a flightcontrol synchronization group

func (*Group[T]) Do

func (g *Group[T]) Do(ctx context.Context, key string, fn func(ctx context.Context) (T, error)) (v T, err error)

Do executes a context function syncronized by the key

Jump to

Keyboard shortcuts

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