// connectMany creates new connections concurrent.
357249
func (pool *hostConnPool) connectMany(count int) error {
	if count == 0 {
		return nil
	}
	var (
		wg         sync.WaitGroup
		mu         sync.Mutex
		connectErr error
	)
	wg.Add(count)
	for i := 0; i < count; i++ {
		go func() {
			defer wg.Done()
			err := pool.connect()
			pool.logConnectErr(err)
			if err != nil {
				mu.Lock()
				connectErr = err
				mu.Unlock()
			}
		}()
	}
	// wait for all connections are done
	wg.Wait()

	return connectErr
}
27181
func (a *api) connectMaster() (master.ClientInterface, error) {
	if a.master == nil {
		var err error
		a.master, err = master.NewClient(config.GetOptions().Endpoint)
		if err != nil {
			return nil, fmt.Errorf("could not create a client to the master: %s", err)
		}
		a.authenticateHost()
	}
	return a.master, nil
}
863412
func (f FuncHttpsHandler) HandleConnect(host string, ctx *ProxyCtx) (*ConnectAction, string) {
	return f(host, ctx)
}
208488
func (idx *CfIndex) ConnectBlock(dbTx database.Tx, block *btcutil.Block,
	stxos []blockchain.SpentTxOut) error {

	prevScripts := make([][]byte, len(stxos))
	for i, stxo := range stxos {
		prevScripts[i] = stxo.PkScript
	}

	f, err := builder.BuildBasicFilter(block.MsgBlock(), prevScripts)
	if err != nil {
		return err
	}

	return storeFilter(dbTx, block, f, wire.GCSFilterRegular)
}
727807
func frexp10Many(a, b, c *extFloat) (exp10 int) {
	exp10, i := c.frexp10()
	a.Multiply(powersOfTen[i])
	b.Multiply(powersOfTen[i])
	return
}
932750
func (mux *Multiplexer) NewBytesManualConnection(name string) *BytesManualConnectionStr {
	return &BytesManualConnectionStr{BytesConnectionFields{multiplexer: mux, name: name}}
}
1341670
func (c *connections) ForModel(model string) Connections {
	var values []Value
	for _, value := range c.values {
		if value.Model == model {
			values = append(values, value)
		}
	}
	return &connections{model: model, values: values}
}
107874
func (b *Backend) connect() error {
	client, err := b.dial()
	if err != nil {
		return err
	}
	b.client = client

	database := "machinery"

	if b.GetConfig().MongoDB != nil {
		database = b.GetConfig().MongoDB.Database
	}

	b.tasksCollection = b.client.Database(database).Collection("tasks")
	b.groupMetasCollection = b.client.Database(database).Collection("group_metas")

	err = b.createMongoIndexes(database)
	if err != nil {
		return err
	}
	return nil
}
518618
func (n *NotifyRouter) AddConnection(xp rpc.Transporter, ch chan error) ConnectionID {
	if n == nil {
		return 0
	}
	id := n.cm.AddConnection(xp, ch)
	n.setNotificationChannels(id, keybase1.NotificationChannels{})
	return id
}
838333
func (db *SQLStorage) UpdateMany(gun data.GUN, updates []MetaUpdate) error {
	tx, rb, err := db.getTransaction()
	if err != nil {
		return err
	}
	var (
		query *gorm.DB
		added = make(map[uint]bool)
	)
	if err := func() error {
		for _, update := range updates {
			// This looks like the same logic as UpdateCurrent, but if we just
			// called, version ordering in the updates list must be enforced
			// (you cannot insert the version 2 before version 1).  And we do
			// not care about monotonic ordering in the updates.
			query = db.Where("gun = ? and role = ? and version >= ?",
				gun.String(), update.Role.String(), update.Version).First(&TUFFile{})

			if !query.RecordNotFound() {
				return ErrOldVersion{}
			}

			var row TUFFile
			checksum := sha256.Sum256(update.Data)
			hexChecksum := hex.EncodeToString(checksum[:])
			query = tx.Where(map[string]interface{}{
				"gun":     gun.String(),
				"role":    update.Role.String(),
				"version": update.Version,
			}).Attrs("data", update.Data).Attrs("sha256", hexChecksum).FirstOrCreate(&row)

			if query.Error != nil {
				return translateOldVersionError(query.Error)
			}
			// it's previously been added, which means it's a duplicate entry
			// in the same transaction
			if _, ok := added[row.ID]; ok {
				return ErrOldVersion{}
			}
			if update.Role == data.CanonicalTimestampRole {
				if err := db.writeChangefeed(tx, gun, update.Version, hexChecksum); err != nil {
					return err
				}
			}
			added[row.ID] = true
		}
		return nil
	}(); err != nil {
		return rb(err)
	}
	return tx.Commit().Error
}
175467
func (_m *Client) GetMany(uids []string, options groveclient.GetManyOptions) (*groveclient.GetManyOutput, error) {
	ret := _m.Called(uids, options)

	var r0 *groveclient.GetManyOutput
	if rf, ok := ret.Get(0).(func([]string, groveclient.GetManyOptions) *groveclient.GetManyOutput); ok {
		r0 = rf(uids, options)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*groveclient.GetManyOutput)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func([]string, groveclient.GetManyOptions) error); ok {
		r1 = rf(uids, options)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
760327
func (r *movieMemoryRepository) SelectMany(query Query, limit int) (results []datamodels.Movie) {
	r.Exec(query, func(m datamodels.Movie) bool {
		results = append(results, m)
		return true
	}, limit, ReadOnlyMode)

	return
}
1367799
func (r *GormRepository) LoadMany(ctx context.Context, IDs []uuid.UUID) ([]Space, error) {
	defer goa.MeasureSince([]string{"goa", "db", "space", "loadMany"}, time.Now())
	// no need to run the query if the list of IDs is empty :)
	var result []Space
	if len(IDs) == 0 {
		return result, nil
	}
	strIDs := make([]string, len(IDs))
	for i, ID := range IDs {
		strIDs[i] = fmt.Sprintf("'%s'", ID.String())
	}

	db := r.db.Model(Space{}).Select("distinct *").Where(fmt.Sprintf("ID in (%s)", strings.Join(strIDs, ", ")))
	rows, err := db.Rows()
	defer closeable.Close(ctx, rows)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "unable to load multiple spaces by their IDs")
		return nil, errors.NewInternalError(ctx, err)
	}
	// scan the results
	for rows.Next() {
		s := Space{}
		err := db.ScanRows(rows, &s)
		if err != nil {
			log.Error(ctx, map[string]interface{}{
				"err": err.Error(),
			}, "unable to load space")
			return nil, errors.NewInternalError(ctx, err)
		}
		result = append(result, s)
	}
	log.Debug(ctx, map[string]interface{}{
		"count":  len(result),
		"spaces": result,
	}, "loaded multiple spaces by their IDs")
	return result, nil
}
973743
func (q Query) SelectMany(selector func(interface{}) Query) Query {
	return Query{
		Iterate: func() Iterator {
			outernext := q.Iterate()
			var inner interface{}
			var innernext Iterator

			return func() (item interface{}, ok bool) {
				for !ok {
					if inner == nil {
						inner, ok = outernext()
						if !ok {
							return
						}

						innernext = selector(inner).Iterate()
					}

					item, ok = innernext()
					if !ok {
						inner = nil
					}
				}

				return
			}
		},
	}
}
1346478
func (s *Service) FindMany(ctx context.Context, filter platform.DBRPMappingFilter, opt ...platform.FindOptions) ([]*platform.DBRPMapping, int, error) {
	// filter by dbrpMapping id
	if filter.Cluster != nil && filter.Database != nil && filter.RetentionPolicy != nil {
		m, err := s.FindBy(ctx, *filter.Cluster, *filter.Database, *filter.RetentionPolicy)
		if err != nil {
			return nil, 0, err
		}
		return []*platform.DBRPMapping{m}, 1, nil
	}

	filterFunc := func(mapping *platform.DBRPMapping) bool {
		return (filter.Cluster == nil || (*filter.Cluster) == mapping.Cluster) &&
			(filter.Database == nil || (*filter.Database) == mapping.Database) &&
			(filter.RetentionPolicy == nil || (*filter.RetentionPolicy) == mapping.RetentionPolicy) &&
			(filter.Default == nil || (*filter.Default) == mapping.Default)
	}

	mappings, err := s.filterDBRPMappings(ctx, filterFunc)
	if err != nil {
		return nil, 0, err
	}

	return mappings, len(mappings), nil
}
970295
func ConnectionManager(connman ifconnmgr.ConnManager) Option {
	return func(cfg *Config) error {
		if cfg.ConnManager != nil {
			return fmt.Errorf("cannot specify multiple connection managers")
		}
		cfg.ConnManager = connman
		return nil
	}
}
1274715
func (a *api) connectDAO() (dao.ControlPlane, error) {
	if a.dao == nil {
		var err error
		a.dao, err = client.NewControlClient(config.GetOptions().Endpoint)
		if err != nil {
			return nil, fmt.Errorf("could not create a client to the agent: %s", err)
		}
		a.authenticateHost()
	}
	return a.dao, nil
}