Victor Farazdagi 745c3a46c1 Updates vendors
2016-10-12 01:59:43 +03:00
..
2016-10-12 01:59:43 +03:00
2016-10-12 01:59:43 +03:00

semaphore

Build Status 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()