Documentation ¶
Overview ¶
Package semaphore implements the semaphore resiliency pattern for Go.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoTickets = errors.New("could not aquire semaphore ticket")
ErrNoTickets is the error returned by Acquire when it could not acquire a ticket from the semaphore within the configured timeout.
Functions ¶
This section is empty.
Types ¶
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
Semaphore implements the semaphore resiliency pattern
Example ¶
sem := New(3, 1*time.Second) for i := 0; i < 10; i++ { go func() { if err := sem.Acquire(); err != nil { return //could not acquire semaphore } defer sem.Release() // do something semaphore-guarded }() }
Output:
Click to show internal directories.
Click to hide internal directories.