MCPcopy
hub / github.com/grafana/dskit / joinMembersBatch

Method joinMembersBatch

kv/memberlist/memberlist_client.go:905–922  ·  view source on GitHub ↗

joinMembersBatch returns an error only if it couldn't successfully join any nodes or if ctx is cancelled.

(ctx context.Context, nodes []string)

Source from the content-addressed store, hash-verified

903
904// joinMembersBatch returns an error only if it couldn't successfully join any nodes or if ctx is cancelled.
905func (m *KV) joinMembersBatch(ctx context.Context, nodes []string) (successfullyJoined int, lastErr error) {
906 for nodeIdx := range nodes {
907 if ctx.Err() != nil {
908 return successfullyJoined, fmt.Errorf("joining batch: %w", context.Cause(ctx))
909 }
910 // Attempt to join a single node.
911 // The cost of calling Join shouldn't be different between passing all nodes in one invocation versus passing a single node per invocation.
912 reached, err := m.memberlist.Join(nodes[nodeIdx : nodeIdx+1])
913 successfullyJoined += reached
914 if err != nil {
915 lastErr = err
916 }
917 }
918 if successfullyJoined > 0 {
919 lastErr = nil
920 }
921 return successfullyJoined, lastErr
922}
923
924// Provides a dns-based member discovery to join a memberlist cluster w/o knowning members' addresses upfront.
925// May both return some addresses and an error in case of a partial resolution.

Callers 1

joinMembersInBatchesMethod · 0.95

Calls 2

ErrorfMethod · 0.80
ErrMethod · 0.45

Tested by

no test coverage detected