// setupSemaphore is used to setup a new Semaphore given the // API client, key prefix, session name, and slot holder limit. func (c *LockCommand) setupSemaphore(client *api.Client, limit int, prefix, name string) (*LockUnlock, error) { if c.verbose { c.Ui.Info(fmt.Sprintf("Setting up semaphore (limit %d) at prefix: %s", limit, prefix)) } opts := api.SemaphoreOptions{ Prefix: prefix, Limit: limit, SessionName: name, } s, err := client.SemaphoreOpts(&opts) if err != nil { return nil, err } lu := &LockUnlock{ lockFn: s.Acquire, unlockFn: s.Release, cleanupFn: s.Destroy, inUseErr: api.ErrSemaphoreInUse, } return lu, nil }