concurrency

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncChannelTransform

func AsyncChannelTransform[In any, Out any](
	ctx context.Context,
	input <-chan *AsyncResult[In],
	bufferCapacity int,
	transform func(In) (Out, error)) <-chan *AsyncResult[Out]

AsyncChannelTransform copies messages from an input channel, transforms them, and sends them to an output channel.

Types

type AsyncResult

type AsyncResult[T any] struct {
	Value T     `json:"value"`
	Err   error `json:"error,omitempty"`
}

AsyncResult holds a value and an error, useful for async operations

func NewAsyncError

func NewAsyncError[T any](err error) *AsyncResult[T]

NewAsyncError creates a new AsyncResult with an error

func NewAsyncResult

func NewAsyncResult[T any](value T, err error) *AsyncResult[T]

NewAsyncResult creates a new AsyncResult with a value and an error

func NewAsyncValue

func NewAsyncValue[T any](value T) *AsyncResult[T]

NewAsyncValue creates a new AsyncResult with a value

func (AsyncResult[T]) MarshalJSON

func (ar AsyncResult[T]) MarshalJSON() ([]byte, error)

MarshalJSON customizes the JSON representation of AsyncResult

func (*AsyncResult[T]) UnmarshalJSON

func (ar *AsyncResult[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON customizes the JSON unmarshalling of AsyncResult

func (*AsyncResult[T]) ValueOrError

func (ar *AsyncResult[T]) ValueOrError() (T, error)

type StripedMap added in v1.2.3

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

func NewStripedMap added in v1.2.3

func NewStripedMap[T any](numStripes int) *StripedMap[T]

func (*StripedMap[T]) Delete added in v1.2.3

func (s *StripedMap[T]) Delete(key string)

func (*StripedMap[T]) Get added in v1.2.3

func (s *StripedMap[T]) Get(key string) (T, bool)

func (*StripedMap[T]) Len added in v1.2.3

func (s *StripedMap[T]) Len() int

func (*StripedMap[T]) LengthsPerStripe added in v1.2.3

func (s *StripedMap[T]) LengthsPerStripe() map[int]int

func (*StripedMap[T]) Put added in v1.2.3

func (s *StripedMap[T]) Put(key string, value T)

Jump to

Keyboard shortcuts

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