semaphore

package
v0.0.0-...-1c6f4db Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WeightedSemaphore

type WeightedSemaphore struct {
	MaxSize int64  // max size of the semaphore
	Name    string // name of the semaphore
	// contains filtered or unexported fields
}

func NewDefaultWeightedSemaphore

func NewDefaultWeightedSemaphore(maxSize int64, name string) *WeightedSemaphore

Inits a new WeightedSemaphore with max size

max wait for getting a lock is retryCount * singleTryWait(30s), then will error out

func NewWeightedSemaphore

func NewWeightedSemaphore(maxSize int64, name string, wait time.Duration) *WeightedSemaphore

Inits a new WeightedSemaphore with max size

max wait for getting a lock is retryCount * wait, then will error out

func (*WeightedSemaphore) Release

func (s *WeightedSemaphore) Release(n int64)

Release n resources from the semaphore

func (*WeightedSemaphore) TryAcquire

func (s *WeightedSemaphore) TryAcquire(size int64) error

func (*WeightedSemaphore) TryAcquireWithBackoff

func (s *WeightedSemaphore) TryAcquireWithBackoff(size int64, retryCount int, jobId interface{}) error

Wrapper around semaphore.Acquire using contexts and retries for better visibility

Tries to acquire size from the semaphore. sid is used as a indetifier for log statments

Returns error if sempahore was not acquired at the end or if never possible to acquire needed size

Jump to

Keyboard shortcuts

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