// ReplicaSetMembers gets the members of the current Mongo replica
// set. These are needed to bootstrap the raft cluster in an upgrade
// and using MongoSession directly from an upgrade steps would make
// testing difficult.
423291
func ReplicaSetMembers(pool *StatePool) ([]replicaset.Member, error) {
	return replicaset.CurrentMembers(pool.SystemState().MongoSession())
}
1201422
func (s *Session) GuildMember(guildID, userID string) (st *Member, err error) {

	body, err := s.RequestWithBucketID("GET", EndpointGuildMember(guildID, userID), nil, EndpointGuildMember(guildID, ""))
	if err != nil {
		return
	}

	err = unmarshal(body, &st)
	return
}
585330
func (c *GroupsListCall) ExcludeMembers(excludeMembers bool) *GroupsListCall {
	c.excludeMembers = excludeMembers
	return c
}
453751
func (c *Client) SearchMembers(query string, args Arguments) (members []*Member, err error) {
	args["query"] = query
	err = c.Get("search/members", args, &members)
	return
}
1331767
func (c *Card) GetMembers(args Arguments) (members []*Member, err error) {
	path := fmt.Sprintf("cards/%s/members", c.ID)
	err = c.client.Get(path, args, &members)
	for i := range members {
		members[i].client = c.client
	}
	return
}
64364
func resetReplicaSet(dialInfo *mgo.DialInfo, memberHostPort string) error {
	params := peergrouper.InitiateMongoParams{
		DialInfo:       dialInfo,
		MemberHostPort: memberHostPort,
		User:           dialInfo.Username,
		Password:       dialInfo.Password,
	}
	return peergrouper.InitiateMongoServer(params)
}
662791
func (c *Cluster) Members() map[uint64]*Member {
	members := make(map[uint64]*Member)
	c.mu.RLock()
	for k, v := range c.members {
		members[k] = v
	}
	c.mu.RUnlock()
	return members
}
119067
func (m *memberlist) LocalMember() (member Member) {
	m.members.Lock()
	// copy local member state
	member = *m.local
	m.members.Unlock()
	return
}
71419
func (o *Me) KeyServerMembers(info *bambou.FetchingInfo) (KeyServerMembersList, *bambou.Error) {

	var list KeyServerMembersList
	err := bambou.CurrentSession().FetchChildren(o, KeyServerMemberIdentity, &list, info)
	return list, err
}
68897
func (w *pgWorker) updateReplicaSet() (map[string]*replicaset.Member, error) {
	info, err := w.peerGroupInfo()
	if err != nil {
		return nil, errors.Annotate(err, "creating peer group info")
	}
	desired, err := desiredPeerGroup(info)
	// membersChanged, members, voting, err
	if err != nil {
		return nil, errors.Annotate(err, "computing desired peer group")
	}
	if logger.IsDebugEnabled() {
		if desired.isChanged {
			logger.Debugf("desired peer group members: \n%s", prettyReplicaSetMembers(desired.members))
		} else {
			var output []string
			for id, v := range desired.machineVoting {
				output = append(output, fmt.Sprintf("  %s: %v", id, v))
			}
			logger.Debugf("no change in desired peer group, voting: \n%s", strings.Join(output, "\n"))
		}
	}

	if desired.stepDownPrimary {
		logger.Infof("mongo primary machine needs to be removed, first requesting it to step down")
		if err := w.config.MongoSession.StepDownPrimary(); err != nil {
			// StepDownPrimary should have already handled the io.EOF that mongo might give, so any error we
			// get is unknown
			return nil, errors.Annotate(err, "asking primary to step down")
		}
		// Asking the Primary to step down forces us to disconnect from Mongo, but session.Refresh() should get us
		// reconnected so we can keep operating
		w.config.MongoSession.Refresh()
		// However, we no longer know who the primary is, so we have to error out and have it reevaluated
		return nil, &stepDownPrimaryError{
			error: errors.Errorf("primary is stepping down, must reevaluate peer group"),
		}
	}

	// We cannot change the HasVote flag of a machine in state at exactly
	// the same moment as changing its voting status in the replica set.
	//
	// Thus we need to be careful that a machine which is actually a voting
	// member is not seen to not have a vote, because otherwise
	// there is nothing to prevent the machine being removed.
	//
	// To avoid this happening, we make sure when we call SetReplicaSet,
	// that the voting status of machines is the union of both old
	// and new voting machines - that is the set of HasVote machines
	// is a superset of all the actual voting machines.
	//
	// Only after the call has taken place do we reset the voting status
	// of the machines that have lost their vote.
	//
	// If there's a crash, the voting status may not reflect the
	// actual voting status for a while, but when things come
	// back on line, it will be sorted out, as desiredReplicaSet
	// will return the actual voting status.
	//
	// Note that we potentially update the HasVote status of the machines even
	// if the members have not changed.
	var added, removed []*machineTracker
	// Iterate in obvious order so we don't get weird log messages
	votingIds := make([]string, 0, len(desired.machineVoting))
	for id := range desired.machineVoting {
		votingIds = append(votingIds, id)
	}
	sortAsInts(votingIds)
	for _, id := range votingIds {
		hasVote := desired.machineVoting[id]
		m := info.machines[id]
		switch {
		case hasVote && !m.stm.HasVote():
			added = append(added, m)
		case !hasVote && m.stm.HasVote():
			removed = append(removed, m)
		}
	}
	if err := setHasVote(added, true); err != nil {
		return nil, errors.Annotate(err, "adding new voters")
	}
	// Currently k8s controllers do not support HA, so only update
	// the replicaset config if HA is enabled and there is a change.
	if w.config.SupportsHA && desired.isChanged {
		ms := make([]replicaset.Member, 0, len(desired.members))
		for _, m := range desired.members {
			ms = append(ms, *m)
		}
		if err := w.config.MongoSession.Set(ms); err != nil {
			// We've failed to set the replica set, so revert back
			// to the previous settings.
			if err1 := setHasVote(added, false); err1 != nil {
				logger.Errorf("cannot revert machine voting after failure to change replica set: %v", err1)
			}
			return nil, &replicaSetError{err}
		}
		logger.Infof("successfully updated replica set")
	}
	if err := setHasVote(removed, false); err != nil {
		return nil, errors.Annotate(err, "removing non-voters")
	}

	// Reset machine status for members of the changed peer-group.
	// Any previous peer-group determination errors result in status
	// warning messages.
	for id := range desired.members {
		if err := w.machineTrackers[id].stm.SetStatus(getStatusInfo("")); err != nil {
			return nil, errors.Trace(err)
		}
	}
	for _, tracker := range info.machines {
		if tracker.stm.Life() != state.Alive && !tracker.stm.HasVote() {
			logger.Debugf("removing dying controller machine %s", tracker.Id())
			if err := w.config.State.RemoveControllerMachine(tracker.stm); err != nil {
				logger.Errorf("failed to remove dying machine as a controller after removing its vote: %v", err)
			}
		}
	}
	for _, removedTracker := range removed {
		if removedTracker.stm.Life() == state.Alive {
			logger.Debugf("vote removed from %v but machine is %s", removedTracker.Id(), state.Alive)
		}
	}
	return desired.members, nil
}
772534
func (b *Blob) StaticSetMembers() []blob.Ref {
	if b.Type() != "static-set" {
		return nil
	}

	s := make([]blob.Ref, 0, len(b.ss.Members))
	for _, ref := range b.ss.Members {
		if ref.Valid() {
			s = append(s, ref)
		}
	}
	return s
}
700396
func (n *Node) GetReachableMembers(predicates ...MemberPredicate) []Member {
	predicates = append(predicates, memberIsReachable)
	return n.memberlist.GetMembers(predicates...)
}
845182
func (t *TeamsService) GetMembers(uri *Hyperlink, uriParams M) (
	members []User, result *Result) {
	url, err := ExpandWithDefault(uri, &TeamMembersURL, uriParams)
	if err != nil {
		return []User(nil), &Result{Err: err}
	}
	return t.client.Users(url).All()
}
612132
func (s *DBCluster) SetDBClusterMembers(v []*DBClusterMember) *DBCluster {
	s.DBClusterMembers = v
	return s
}
972705
func (c *EtcdGroupService) GroupMembers(ctx context.Context, groupName string) ([]string, error) {
	prefix := memberKey(groupName, "")
	ctxT, cancel := context.WithTimeout(ctx, transactionTimeout)
	defer cancel()
	etcdRes, err := clientInstance.Txn(ctxT).
		If(clientv3.Compare(clientv3.CreateRevision(groupKey(groupName)), ">", 0)).
		Then(clientv3.OpGet(prefix, clientv3.WithPrefix(), clientv3.WithKeysOnly())).
		Commit()

	if err != nil {
		return nil, err
	}
	if !etcdRes.Succeeded {
		return nil, constants.ErrGroupNotFound
	}

	getRes := etcdRes.Responses[0].GetResponseRange()
	members := make([]string, getRes.GetCount())
	for i, kv := range getRes.GetKvs() {
		members[i] = string(kv.Key)[len(prefix):]
	}
	return members, nil
}
800286
func (s *GetMembersOutput) SetMembers(v []*Member) *GetMembersOutput {
	s.Members = v
	return s
}
1149962
func (db *RedisDB) ZMembers(k string) ([]string, error) {
	db.master.Lock()
	defer db.master.Unlock()
	if !db.exists(k) {
		return nil, ErrKeyNotFound
	}
	if db.t(k) != "zset" {
		return nil, ErrWrongType
	}
	return db.ssetMembers(k), nil
}