Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GoFunc ¶
type GoFunc[T any] func(ctx context.Context, region *LimitedRegion, t T) error
GoFunc represents a function that can be invoked by Go.
type LimitedRegion ¶
type LimitedRegion struct {
// contains filtered or unexported fields
}
LimitedRegion provides a way to bound concurrent access to a code block.
func LimitRegion ¶
func LimitRegion(ctx context.Context, limiter *semaphore.Weighted) *LimitedRegion
LimitRegion creates a new LimitedRegion.
func (*LimitedRegion) End ¶
func (lr *LimitedRegion) End()
End ends the region with concurrency limit.
func (*LimitedRegion) Start ¶
func (lr *LimitedRegion) Start() error
Start starts the region with concurrency limit.
type Merge ¶
type Merge[T any] struct { // contains filtered or unexported fields }
Merge represents merge operations on items. The state transfer is shown as below:
+----------+ | Start +--------+-------------+ +----+-----+ | | | | | v v v +----+-----+ +----+----+ +----+----+ +-------+ Prepare +<--+ Pending +-->+ Waiting | | +----+-----+ +---------+ +----+----+ | | | | v | | + ---+---- + | On Error | Resolve | | | + ---+---- + | | | | | v | | +----+-----+ | +------>+ Complete +<---------------------+ +----+-----+ | v +----+-----+ | End | +----------+
type Once ¶
type Once struct {
// contains filtered or unexported fields
}
Once is an object that will perform exactly one action. Unlike sync.Once, this Once allowes the action to have return values.
func (*Once) Do ¶
Do calls the function f if and only if Do is being called first time or all previous function calls are cancelled, deadline exceeded, or panicking. When `once.Do(ctx, f)` is called multiple times, the return value of the first call of the function f is stored, and is directly returned for other calls. Besides the return value of the function f, including the error, Do returns true if the function f passed is called first and is not cancelled, deadline exceeded, or panicking. Otherwise, returns false.
type Pool ¶
type Pool[T any] struct { // New optionally specifies a function to generate a value when Get would // otherwise return nil. // It may not be changed concurrently with calls to Get. New func() T // contains filtered or unexported fields }
Pool is a scalable pool with items identified by keys.