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
Click to show internal directories.
Click to hide internal directories.