// AcquirePlaybook will return the check playbook
424898
func (e SensuEvent) AcquirePlaybook() string {
	if e.Check.Playbook != "" {
		return "<" + e.Check.Playbook + "|" + e.Check.Name + ">"
	}
	return "No playbook is available"
}
243523
func DeployChequebook(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Chequebook, error) {
	parsed, err := abi.JSON(strings.NewReader(ChequebookABI))
	if err != nil {
		return common.Address{}, nil, nil, err
	}
	address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ChequebookBin), backend)
	if err != nil {
		return common.Address{}, nil, nil, err
	}
	return address, tx, &Chequebook{ChequebookCaller: ChequebookCaller{contract: contract}, ChequebookTransactor: ChequebookTransactor{contract: contract}, ChequebookFilterer: ChequebookFilterer{contract: contract}}, nil
}
481027
func (c *Client) NextPlaylistResults(s *SearchResult) error {
	if s.Playlists == nil || s.Playlists.Next == "" {
		return ErrNoMorePages
	}
	return c.get(s.Playlists.Next, s)
}
363909
func RetrieveTicketIDByHashNoCancel(db *sql.DB, ticketHash string) (id uint64, err error) {
	err = db.QueryRow(internal.SelectTicketIDByHash, ticketHash).Scan(&id)
	return
}
82075
func (l *ConnectionsLimiter) AcquireConnection(token string) error {
	l.Lock()
	defer l.Unlock()

	if l.maxConnections == 0 {
		return nil
	}

	numberOfConnections, exists := l.connections[token]
	if !exists {
		l.connections[token] = 1
		return nil
	}
	if numberOfConnections >= l.maxConnections {
		return trace.LimitExceeded(
			"too many connections from %v: %v, max is %v",
			token, numberOfConnections, l.maxConnections)
	}
	l.connections[token] = numberOfConnections + 1
	return nil
}
1325865
func (s *Server) checkDisplayAmount(ctx context.Context, arg stellar1.SendCLILocalArg) error {
	if arg.DisplayAmount == "" {
		return nil
	}

	exchangeRate, err := s.remoter.ExchangeRate(ctx, arg.DisplayCurrency)
	if err != nil {
		return err
	}

	xlmAmount, err := stellarnet.ConvertOutsideToXLM(arg.DisplayAmount, exchangeRate.Rate)
	if err != nil {
		return err
	}

	currentAmt, err := stellarnet.ParseStellarAmount(xlmAmount)
	if err != nil {
		return err
	}

	argAmt, err := stellarnet.ParseStellarAmount(arg.Amount)
	if err != nil {
		return err
	}

	if percentageAmountChange(currentAmt, argAmt) > 1.0 {
		s.G().Log.CDebugf(ctx, "large exchange rate delta: argAmt: %d, currentAmt: %d", argAmt, currentAmt)
		return errors.New("current exchange rates have changed more than 1%")
	}

	return nil
}
841576
func (remote *RemoteDebugger) CaptureScreenshot(format string, quality int, fromSurface bool) ([]byte, error) {
	if format == "" {
		format = "png"
	}

	res, err := remote.SendRequest("Page.captureScreenshot", Params{
		"format":      format,
		"quality":     quality,
		"fromSurface": fromSurface,
	})

	if err != nil {
		return nil, err
	}

	if res == nil {
		return nil, ErrorNoResponse
	}

	return base64.StdEncoding.DecodeString(res["data"].(string))
}
1258620
func (db *Database) Acquire(sid string, expires time.Duration) sessions.LifeTime {
	txn := db.Service.NewTransaction(true)
	defer txn.Commit(nil)

	bsid := makePrefix(sid)
	item, err := txn.Get(bsid)
	if err == nil {
		// found, return the expiration.
		return sessions.LifeTime{Time: time.Unix(int64(item.ExpiresAt()), 0)}
	}

	// not found, create an entry with ttl and return an empty lifetime, session manager will do its job.
	if err != nil {
		if err == badger.ErrKeyNotFound {
			// create it and set the expiration, we don't care about the value there.
			err = txn.SetWithTTL(bsid, bsid, expires)
		}
	}

	if err != nil {
		golog.Error(err)
	}

	return sessions.LifeTime{} // session manager will handle the rest.
}
1245277
func (s *Semaphore) AcquireMany(n int) {
	if n > s.permits {
		n = s.permits
	}

	for ; n > 0; n-- {
		s.Acquire()
	}
}
335870
func (bk *Backend) AcquireLock(token string, ttl time.Duration) (err error) {
	bk.log.Debugf("AcquireLock(%s)", token)

	if err = legacy.ValidateLockTTL(ttl); err != nil {
		return trace.Wrap(err)
	}

	bucket := []string{locksBucket}
	for {
		// GetVal will clear TTL on a lock
		bk.GetVal(bucket, token)

		// CreateVal is atomic:
		err = bk.CreateVal(bucket, token, []byte{1}, ttl)
		if err == nil {
			break // success
		}
		if trace.IsAlreadyExists(err) { // locked? wait and repeat:
			bk.Clock().Sleep(250 * time.Millisecond)
			continue
		}
		return trace.ConvertSystemError(err)
	}

	return nil
}
1232382
func (c *Client) GetPlaylistTracks(playlistID ID) (*PlaylistTrackPage, error) {
	return c.GetPlaylistTracksOpt(playlistID, nil, "")
}
287923
func (mysqld *Mysqld) EnableBinlogPlayback() error {
	// Get a connection.
	conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
	if err != nil {
		return err
	}
	defer conn.Recycle()

	// See if we have a command to run, and run it.
	cmd := conn.EnableBinlogPlaybackCommand()
	if cmd == "" {
		return nil
	}
	if err := mysqld.ExecuteSuperQuery(context.TODO(), cmd); err != nil {
		log.Errorf("EnableBinlogPlayback: cannot run query '%v': %v", cmd, err)
		return fmt.Errorf("EnableBinlogPlayback: cannot run query '%v': %v", cmd, err)
	}

	log.Info("EnableBinlogPlayback: successfully ran %v", cmd)
	return nil
}
991067
func (latches *Latches) acquire(lock *Lock) acquireResult {
	if lock.IsStale() {
		return acquireStale
	}
	for lock.acquiredCount < len(lock.requiredSlots) {
		status := latches.acquireSlot(lock)
		if status != acquireSuccess {
			return status
		}
	}
	return acquireSuccess
}
288539
func (lobby *Lobby) IsPlayerReady(player *player.Player) (bool, error) {
	var ready bool
	err := db.DB.DB().QueryRow("SELECT ready FROM lobby_slots WHERE lobby_id = $1 AND player_id = $2", lobby.ID, player.ID).Scan(&ready)
	return ready, err
}
421828
func (sem *Semaphore) Acquire() bool {
	if sem.timeout == 0 {
		<-sem.slots
		return true
	}
	tm := time.NewTimer(sem.timeout)
	defer tm.Stop()
	select {
	case <-sem.slots:
		return true
	case <-tm.C:
		return false
	}
}
110679
func (cp *callPool) Acquire(id uint64) *Call {
	cp.Lock()
	c := cp.free
	if c == nil {
		c = cp.build()
	} else {
		cp.free = c.next
	}
	c.req.Head.ID = id
	cp.pending[id] = c
	cp.Unlock()
	return c
}
559421
func (p *GzipPool) AcquireGzipWriter(w io.Writer) *gzip.Writer {
	v := p.Get()
	if v == nil {
		gzipWriter, err := gzip.NewWriterLevel(w, p.Level)
		if err != nil {
			return nil
		}
		return gzipWriter
	}
	gzipWriter := v.(*gzip.Writer)
	gzipWriter.Reset(w)
	return gzipWriter
}