// ConnectionEstablished returns whether a connection to Vault has been
// established and any error that potentially caused it to be false
492443
func (v *vaultClient) ConnectionEstablished() (bool, error) {
	v.l.Lock()
	defer v.l.Unlock()
	return v.connEstablished, v.connEstablishedErr
}
765204
func (c *Connection) isClosed() error {
	if c.conn == nil {
		return client.ErrConnectionClosed
	}
	return nil
}
538807
func (nc *Conn) IsClosed() bool {
	nc.mu.RLock()
	defer nc.mu.RUnlock()
	return nc.isClosed()
}
1367150
func (c *consulClient) Connected() <-chan struct{} {
	ch := make(chan struct{})
	go func() {
		for {
			// TODO find out if there's a better way to do this for consul
			_, _, err := c.Session().Info(c.lease, &consulAPI.QueryOptions{})
			if err == nil {
				break
			}
			time.Sleep(100 * time.Millisecond)
		}
		close(ch)
	}()
	return ch
}
41159
func (obj *Global) IsValidConnectionStringRaw(ctx context.Context, connection interface{}) (bool, error) {
	result := &struct {
		Return bool	`json:"qReturn"`
	} {}
	err := obj.rpc(ctx, "IsValidConnectionString", result, ensureEncodable(connection))
	return result.Return, err 
}
537391
func (c *Connection) TransactionActive() bool {
	c.dbMu.RLock()
	defer c.dbMu.RUnlock()
	if c.db == nil {
		return false
	}
	return c.db.TransactionActive()
}
96140
func (c *Client) IsExported(
	ctx context.Context, name string) (bool, int, error) {

	export, err := c.GetExportByName(ctx, name)
	if err != nil {
		return false, 0, err
	}
	if export == nil {
		return false, 0, nil
	}
	return true, export.ID, nil
}
870979
func (obj *Global) IsValidConnectionString(ctx context.Context, connection *Connection) (bool, error) {
	result := &struct {
		Return bool	`json:"qReturn"`
	} {}
	err := obj.rpc(ctx, "IsValidConnectionString", result, connection)
	return result.Return, err 
}
128817
func IsGranted(scope string, c echo.Context) bool {
	parts := strings.Split(scope, ":")
	switch parts[0] {
	case "profile_messages", "project_messages":
		return IsGranted("messages:"+parts[1], c)

	case "profile_comments":
		return IsGranted("profile_messages:"+parts[1], c)

	case "project_comments":
		return IsGranted("project_messages:"+parts[1], c)
	}

	scopes := c.Get("scopes").([]string)
	i := sort.SearchStrings(scopes, scope)
	if i < len(scopes) && scopes[i] == scope {
		return true
	}

	scope = "base:" + parts[1]
	i = sort.SearchStrings(scopes, scope)
	return i < len(scopes) && scopes[i] == scope
}
1104560
func newAuthenticatedConnection(conn driver.Connection, auth httpAuthentication) (driver.Connection, error) {
	if conn == nil {
		return nil, driver.WithStack(driver.InvalidArgumentError{Message: "conn is nil"})
	}
	if auth == nil {
		return nil, driver.WithStack(driver.InvalidArgumentError{Message: "auth is nil"})
	}
	return &authenticatedConnection{
		conn: conn,
		auth: auth,
	}, nil
}
1225691
func (nc *Conn) Buffered() (int, error) {
	nc.mu.RLock()
	defer nc.mu.RUnlock()
	if nc.isClosed() || nc.bw == nil {
		return -1, ErrConnectionClosed
	}
	return nc.bw.Buffered(), nil
}
1134657
func (c *Connection) authenticated() bool {
	if c.StorageUrl == "" || c.AuthToken == "" {
		return false
	}
	if c.Expires.IsZero() {
		return true
	}
	timeUntilExpiry := c.Expires.Sub(time.Now())
	return timeUntilExpiry >= 60*time.Second
}
1308211
func (p *Plugin) NewAsyncPublisherToPartition(connectionName string, topic string, partition int32, successClb func(messaging.ProtoMessage), errorClb func(messaging.ProtoMessageErr)) (messaging.ProtoPublisher, error) {
	return p.NewProtoManualConnection(connectionName).NewAsyncPublisherToPartition(topic, partition, successClb, errorClb)
}
252917
func (pgb *ChainDB) AddressRowsMerged(address string) ([]dbtypes.AddressRowMerged, error) {
	// Try the address cache.
	hash := pgb.BestBlockHash()
	rowsCompact, validBlock := pgb.AddressCache.Rows(address)
	cacheCurrent := validBlock != nil && validBlock.Hash == *hash && rowsCompact != nil
	if cacheCurrent {
		log.Tracef("AddressRows: rows cache HIT for %s.", address)
		return dbtypes.MergeRowsCompact(rowsCompact), nil
	}

	log.Tracef("AddressRows: rows cache MISS for %s.", address)

	// Update or wait for an update to the cached AddressRows.
	rows, _, err := pgb.updateAddressRows(address)
	if err != nil {
		if err.Error() == "retry" {
			// Try again, starting with cache.
			return pgb.AddressRowsMerged(address)
		}
		return nil, err
	}

	// We have a result.
	return dbtypes.MergeRows(rows)
}
73592
func parseDestination(data []byte) (*btcec.PublicKey, error) {
	// As BOLT-11 states, a reader must skip over the destination field
	// if it does not have a length of 53, so avoid returning an error.
	if len(data) != pubKeyBase32Len {
		return nil, nil
	}

	base256Data, err := bech32.ConvertBits(data, 5, 8, false)
	if err != nil {
		return nil, err
	}

	return btcec.ParsePubKey(base256Data, btcec.S256())
}
924596
func (s *server) OnClientConnectionClosed(callback func(c *Client, err error)) {
	s.onClientConnectionClosed = callback
}
1213281
func (nd *Node) newConnection(overrideThreshold bool) (*Connection, error) {
	// if connection count is limited and enough connections are already created, don't create a new one
	cc := nd.connectionCount.IncrementAndGet()
	if nd.cluster.clientPolicy.LimitConnectionsToQueueSize && cc > nd.cluster.clientPolicy.ConnectionQueueSize {
		nd.connectionCount.DecrementAndGet()
		atomic.AddInt64(&nd.stats.ConnectionsPoolEmpty, 1)

		return nil, ErrTooManyConnectionsForNode
	}

	// Check for opening connection threshold
	if !overrideThreshold && nd.cluster.clientPolicy.OpeningConnectionThreshold > 0 {
		ct := nd.cluster.connectionThreshold.IncrementAndGet()
		if ct > nd.cluster.clientPolicy.OpeningConnectionThreshold {
			nd.cluster.connectionThreshold.DecrementAndGet()

			return nil, ErrTooManyOpeningConnections
		}

		defer nd.cluster.connectionThreshold.DecrementAndGet()
	}

	atomic.AddInt64(&nd.stats.ConnectionsAttempts, 1)
	conn, err := NewConnection(&nd.cluster.clientPolicy, nd.host)
	if err != nil {
		nd.connectionCount.DecrementAndGet()
		atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)
		return nil, err
	}
	conn.node = nd

	// need to authenticate
	if err = conn.login(nd.sessionToken()); err != nil {
		atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)

		// Socket not authenticated. Do not put back into pool.
		conn.Close()
		return nil, err
	}

	atomic.AddInt64(&nd.stats.ConnectionsSuccessful, 1)

	return conn, nil
}