ch04

package
v0.0.0-...-a8fff6b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chord

func Chord(sources ...<-chan int) <-chan []int

Types

type Circuit

type Circuit func(context.Context) (string, error)

func Breaker

func Breaker(circuit Circuit, threshold int) Circuit

func DebounceFirst

func DebounceFirst(circuit Circuit, d time.Duration) Circuit

func DebounceLast

func DebounceLast(circuit Circuit, d time.Duration) Circuit

type Effector

type Effector func(context.Context) (string, error)

func Retry

func Retry(effector Effector, retries int, delay time.Duration) Effector

func Throttle

func Throttle(e Effector, max uint, refill uint, d time.Duration) Effector

type Future

type Future interface {
	Result() (string, error)
}

func SlowFunction

func SlowFunction(ctx context.Context) Future

type InnerFuture

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

func (*InnerFuture) Result

func (f *InnerFuture) Result() (string, error)

type Shard

type Shard[K comparable, V any] struct {
	sync.RWMutex // Compose from sync.RWMutex
	// contains filtered or unexported fields
}

type ShardedMap

type ShardedMap[K comparable, V any] []*Shard[K, V]

func NewShardedMap

func NewShardedMap[K comparable, V any](nshards int) ShardedMap[K, V]

NewShardedMap creates and initializes a new ShardedMap with the specified number of shards.

func (ShardedMap[K, V]) Delete

func (m ShardedMap[K, V]) Delete(key K)

Delete removes a value from the map. If key doesn't exist in the map, this method is a no-op.

func (ShardedMap[K, V]) Get

func (m ShardedMap[K, V]) Get(key K) V

Get retrieves and returns a value from the map. If the value doesn't exist, nil is returned.

func (ShardedMap[K, V]) Keys

func (m ShardedMap[K, V]) Keys() []K

Keys returns a list of all keys in the sharded map.

func (ShardedMap[K, V]) Set

func (m ShardedMap[K, V]) Set(key K, value V)

type TimeoutFunction

type TimeoutFunction func(string) (string, error)

type WithContext

type WithContext func(context.Context, string) (string, error)

func Timeout

func Timeout(f TimeoutFunction) WithContext

Jump to

Keyboard shortcuts

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