// WithStaticConnectors returns a storage with a read-only set of Connectors. Write actions,
// such as updating existing Connectors, will fail.
326201
func WithStaticConnectors(s Storage, staticConnectors []Connector) Storage {
	connectorsByID := make(map[string]Connector, len(staticConnectors))
	for _, c := range staticConnectors {
		connectorsByID[c.ID] = c
	}
	return staticConnectorsStorage{s, staticConnectors, connectorsByID}
}
507887
func FetchStaticChanBackups(chanSource LiveChannelSource) ([]Single, error) {
	// First, we'll query the backup source for information concerning all
	// currently open and available channels.
	openChans, err := chanSource.FetchAllChannels()
	if err != nil {
		return nil, err
	}

	// Now that we have all the channels, we'll use the chanSource to
	// obtain any auxiliary information we need to craft a backup for each
	// channel.
	staticChanBackups := make([]Single, len(openChans))
	for i, openChan := range openChans {
		chanBackup, err := assembleChanBackup(chanSource, openChan)
		if err != nil {
			return nil, err
		}

		staticChanBackups[i] = *chanBackup
	}

	return staticChanBackups, nil
}
176097
func DefaultStaticTokens() StaticTokens {
	return &StaticTokensV2{
		Kind:    KindStaticTokens,
		Version: V2,
		Metadata: Metadata{
			Name:      MetaNameStaticTokens,
			Namespace: defaults.Namespace,
		},
		Spec: StaticTokensSpecV2{
			StaticTokens: []ProvisionTokenV1{},
		},
	}
}
1152463
func NewConnector(config Config, scope metrics.Scope) dosa.Connector {
	return &Connector{
		client:    NewRedigoClient(config.ServerSettings, scope),
		ttl:       config.TTL,
		stats:     metrics.CheckIfNilStats(scope),
		keyPrefix: config.KeyPrefix,
	}
}
388953
func NewConnector(hosts ...string) driver.Connector {
	return &OCI8Connector{
		Logger: log.New(ioutil.Discard, "", 0),
	}
}
1255343
func (s *DBClusterEndpoint) SetStaticMembers(v []*string) *DBClusterEndpoint {
	s.StaticMembers = v
	return s
}
381947
func NewConnector(cfg Config, connectorMap map[string]dosa.Connector) *Connector {
	return &Connector{
		connectors: connectorMap,
		config:     cfg,
	}
}
846106
func (s *Stack) SetStorageConnectors(v []*StorageConnector) *Stack {
	s.StorageConnectors = v
	return s
}
849369
func WithStaticPasswords(s Storage, staticPasswords []Password, logger log.Logger) Storage {
	passwordsByEmail := make(map[string]Password, len(staticPasswords))
	for _, p := range staticPasswords {
		//Enable case insensitive email comparison.
		lowerEmail := strings.ToLower(p.Email)
		if _, ok := passwordsByEmail[lowerEmail]; ok {
			logger.Errorf("Attempting to create StaticPasswords with the same email id: %s", p.Email)
		}
		passwordsByEmail[lowerEmail] = p
	}

	return staticPasswordsStorage{s, staticPasswords, passwordsByEmail, logger}
}
865470
func (cp *connectionPool) connCloser() {
	var connCount uint64

	t := time.NewTimer(ConnCloserInterval)
	defer t.Stop()

	for {
		connCount = cp.connCount

		// we don't exist anymore! bail out!
		select {
		case <-cp.bailOut:
			return
		case <-t.C:
		}
		t.Reset(ConnCloserInterval)

		// no overflow connections open or sustained requests for connections
		// nothing to do until the next cycle
		if len(cp.connections) <= cp.poolSize ||
			ConnCloserInterval/ConnPoolAvailWaitTime < time.Duration(cp.connCount-connCount) {
			continue
		}

		// close overflow connections now that they are not needed
		for c := range cp.connections {
			select {
			case <-cp.bailOut:
				return
			default:
			}

			// bail out if close did not work out
			if !cp.connCleanup(c) {
				return
			}
			if len(cp.connections) <= cp.poolSize {
				break
			}
		}
	}
}
20794
func (s *Server) OpenConnector(conn storage.Connector) (Connector, error) {
	var c connector.Connector

	if conn.Type == LocalConnector {
		c = newPasswordDB(s.storage)
	} else {
		var err error
		c, err = openConnector(s.logger, conn)
		if err != nil {
			return Connector{}, fmt.Errorf("failed to open connector: %v", err)
		}
	}

	connector := Connector{
		ResourceVersion: conn.ResourceVersion,
		Connector:       c,
	}
	s.mu.Lock()
	s.connectors[conn.ID] = connector
	s.mu.Unlock()

	return connector, nil
}
1159887
func NewConnectionsStatsHandler(sub Subsystem, vec *prometheus.GaugeVec) *ConnectionsStatsHandler {
	return &ConnectionsStatsHandler{
		baseStatsHandler: baseStatsHandler{
			subsystem: sub,
			collector: vec,
		},
		vec: vec,
	}
}
525754
func (m *MobileGateway) HasStaticRoutes() bool {
	return m.HasSetting() && m.Settings.MobileGateway.HasStaticRoutes()
}
794899
func (l *LoadBalancer) dropConnections(backend NetAddr) {
	tracker := l.connections[backend]
	for _, conn := range tracker {
		conn.Close()
	}
	delete(l.connections, backend)
}
217710
func (o *oracleInstance) StorageAttachments() []response.Storage {
	o.mutex.Lock()
	defer o.mutex.Unlock()
	return o.machine.Storage_attachments
}
1247197
func (pp *TxPreparedPool) FetchAll() []*TxConnection {
	pp.mu.Lock()
	defer pp.mu.Unlock()
	conns := make([]*TxConnection, 0, len(pp.conns))
	for _, c := range pp.conns {
		conns = append(conns, c)
	}
	pp.conns = make(map[string]*TxConnection, pp.capacity)
	pp.reserved = make(map[string]error)
	return conns
}
1192076
func (s *ClusterConfigurationService) DeleteStaticTokens() error {
	err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, staticTokensPrefix))
	if err != nil {
		if trace.IsNotFound(err) {
			return trace.NotFound("static tokens are not found")
		}
		return trace.Wrap(err)
	}
	return nil
}