package
1.7.0
Repository: https://github.com/eapache/go-resiliency.git
Documentation: pkg.go.dev

# README

semaphore

Golang CI GoDoc Code of Conduct

The semaphore resiliency pattern for golang.

Creating a semaphore takes two parameters:

  • ticket count (how many tickets to give out at once)
  • timeout (how long to wait for a ticket if none are currently available)
sem := semaphore.New(3, 1*time.Second)

if err := sem.Acquire(); err != nil {
	// could not acquire semaphore
	return err
}
defer sem.Release()

# Functions

New constructs a new Semaphore with the given ticket-count and timeout.

# Variables

ErrNoTickets is the error returned by Acquire when it could not acquire a ticket from the semaphore within the configured timeout.

# Structs

Semaphore implements the semaphore resiliency pattern.