concurrencylimiter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemporarilyRelease

func TemporarilyRelease(ctx context.Context, f func())

TemporarilyRelease temporarily releases a concurrency limiter token (if any) while calling a long-running but no-resource-using function f.

func With

func With(ctx context.Context, limit int) context.Context

With attaches a new limiter to the context with the given limit.

Types

type ReleaseFunc

type ReleaseFunc func()

A ReleaseFunc releases a concurrency limiter token.

func Acquire

func Acquire(ctx context.Context) (context.Context, ReleaseFunc)

Acquire acquires a concurrency limiter token. If the context is canceled or if there is no concurrency limit associated with the context it succeeds immediately and returns a no-op release function.

The returned release function is idempotent.

Jump to

Keyboard shortcuts

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