id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
21,100 | uber/ringpop-go | swim/state_transitions.go | timer | func (s *stateTransitions) timer(address string) *clock.Timer {
s.Lock()
t, ok := s.timers[address]
s.Unlock()
if !ok {
return nil
}
return t.Timer
} | go | func (s *stateTransitions) timer(address string) *clock.Timer {
s.Lock()
t, ok := s.timers[address]
s.Unlock()
if !ok {
return nil
}
return t.Timer
} | [
"func",
"(",
"s",
"*",
"stateTransitions",
")",
"timer",
"(",
"address",
"string",
")",
"*",
"clock",
".",
"Timer",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"t",
",",
"ok",
":=",
"s",
".",
"timers",
"[",
"address",
"]",
"\n",
"s",
".",
"Unlock",
... | // timer is a testing func to avoid data races | [
"timer",
"is",
"a",
"testing",
"func",
"to",
"avoid",
"data",
"races"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L216-L224 |
21,101 | uber/ringpop-go | swim/labels.go | Get | func (n *NodeLabels) Get(key string) (value string, has bool) {
return n.node.memberlist.GetLocalLabel(key)
} | go | func (n *NodeLabels) Get(key string) (value string, has bool) {
return n.node.memberlist.GetLocalLabel(key)
} | [
"func",
"(",
"n",
"*",
"NodeLabels",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"value",
"string",
",",
"has",
"bool",
")",
"{",
"return",
"n",
".",
"node",
".",
"memberlist",
".",
"GetLocalLabel",
"(",
"key",
")",
"\n",
"}"
] | // Get the value of a label for this node | [
"Get",
"the",
"value",
"of",
"a",
"label",
"for",
"this",
"node"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/labels.go#L164-L166 |
21,102 | uber/ringpop-go | swim/labels.go | Remove | func (n *NodeLabels) Remove(key string) (removed bool, err error) {
if isInternalLabel(key) {
return false, ErrLabelInternalKey
}
return n.node.memberlist.RemoveLocalLabels(key), nil
} | go | func (n *NodeLabels) Remove(key string) (removed bool, err error) {
if isInternalLabel(key) {
return false, ErrLabelInternalKey
}
return n.node.memberlist.RemoveLocalLabels(key), nil
} | [
"func",
"(",
"n",
"*",
"NodeLabels",
")",
"Remove",
"(",
"key",
"string",
")",
"(",
"removed",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"isInternalLabel",
"(",
"key",
")",
"{",
"return",
"false",
",",
"ErrLabelInternalKey",
"\n",
"}",
"\n",
"return... | // Remove a key from the labels | [
"Remove",
"a",
"key",
"from",
"the",
"labels"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/labels.go#L179-L184 |
21,103 | uber/ringpop-go | swim/heal_via_discover_provider.go | Start | func (h *discoverProviderHealer) Start() {
// check if started channel is already filled
// if not, we start a new loop
select {
case h.started <- struct{}{}:
default:
return
}
go func() {
for {
// loop or quit
select {
case <-h.node.clock.After(h.period):
case <-h.quit:
return
}
// a... | go | func (h *discoverProviderHealer) Start() {
// check if started channel is already filled
// if not, we start a new loop
select {
case h.started <- struct{}{}:
default:
return
}
go func() {
for {
// loop or quit
select {
case <-h.node.clock.After(h.period):
case <-h.quit:
return
}
// a... | [
"func",
"(",
"h",
"*",
"discoverProviderHealer",
")",
"Start",
"(",
")",
"{",
"// check if started channel is already filled",
"// if not, we start a new loop",
"select",
"{",
"case",
"h",
".",
"started",
"<-",
"struct",
"{",
"}",
"{",
"}",
":",
"default",
":",
... | // Start the partition healing loop | [
"Start",
"the",
"partition",
"healing",
"loop"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_via_discover_provider.go#L66-L90 |
21,104 | uber/ringpop-go | swim/heal_via_discover_provider.go | Probability | func (h *discoverProviderHealer) Probability() float64 {
// avoid division by zero.
if h.previousHostListSize < h.node.CountReachableMembers() {
h.previousHostListSize = h.node.CountReachableMembers()
}
if h.previousHostListSize < 1 {
h.previousHostListSize = 1
}
return h.baseProbabillity / float64(h.previous... | go | func (h *discoverProviderHealer) Probability() float64 {
// avoid division by zero.
if h.previousHostListSize < h.node.CountReachableMembers() {
h.previousHostListSize = h.node.CountReachableMembers()
}
if h.previousHostListSize < 1 {
h.previousHostListSize = 1
}
return h.baseProbabillity / float64(h.previous... | [
"func",
"(",
"h",
"*",
"discoverProviderHealer",
")",
"Probability",
"(",
")",
"float64",
"{",
"// avoid division by zero.",
"if",
"h",
".",
"previousHostListSize",
"<",
"h",
".",
"node",
".",
"CountReachableMembers",
"(",
")",
"{",
"h",
".",
"previousHostListSi... | // Probability returns the probability when a heal should be attempted
// we want to throttle the heal attempts to alleviate pressure on the
// discover provider. | [
"Probability",
"returns",
"the",
"probability",
"when",
"a",
"heal",
"should",
"be",
"attempted",
"we",
"want",
"to",
"throttle",
"the",
"heal",
"attempts",
"to",
"alleviate",
"pressure",
"on",
"the",
"discover",
"provider",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_via_discover_provider.go#L106-L115 |
21,105 | uber/ringpop-go | swim/heal_via_discover_provider.go | Heal | func (h *discoverProviderHealer) Heal() ([]string, error) {
h.node.EmitEvent(DiscoHealEvent{})
// get list from discovery provider
if h.node.discoverProvider == nil {
return []string{}, errors.New("discoverProvider not available to healer")
}
hostList, err := h.node.discoverProvider.Hosts()
if err != nil {
h... | go | func (h *discoverProviderHealer) Heal() ([]string, error) {
h.node.EmitEvent(DiscoHealEvent{})
// get list from discovery provider
if h.node.discoverProvider == nil {
return []string{}, errors.New("discoverProvider not available to healer")
}
hostList, err := h.node.discoverProvider.Hosts()
if err != nil {
h... | [
"func",
"(",
"h",
"*",
"discoverProviderHealer",
")",
"Heal",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"h",
".",
"node",
".",
"EmitEvent",
"(",
"DiscoHealEvent",
"{",
"}",
")",
"\n",
"// get list from discovery provider",
"if",
"h",
"."... | // Heal iterates over the hostList that the discoverProvider provides. If the
// node encounters a host that is faulty or not in the membership, we pick that
// node as a target to perform a partition heal with.
//
// If heal was attempted, returns identities of the target nodes. | [
"Heal",
"iterates",
"over",
"the",
"hostList",
"that",
"the",
"discoverProvider",
"provides",
".",
"If",
"the",
"node",
"encounters",
"a",
"host",
"that",
"is",
"faulty",
"or",
"not",
"in",
"the",
"membership",
"we",
"pick",
"that",
"node",
"as",
"a",
"tar... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_via_discover_provider.go#L122-L179 |
21,106 | uber/ringpop-go | swim/heal_via_discover_provider.go | del | func del(strs []string, s string) []string {
for i := 0; i < len(strs); i++ {
if strs[i] != s {
continue
}
strs[i] = strs[len(strs)-1]
strs = strs[:len(strs)-1]
i--
}
return strs
} | go | func del(strs []string, s string) []string {
for i := 0; i < len(strs); i++ {
if strs[i] != s {
continue
}
strs[i] = strs[len(strs)-1]
strs = strs[:len(strs)-1]
i--
}
return strs
} | [
"func",
"del",
"(",
"strs",
"[",
"]",
"string",
",",
"s",
"string",
")",
"[",
"]",
"string",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"strs",
")",
";",
"i",
"++",
"{",
"if",
"strs",
"[",
"i",
"]",
"!=",
"s",
"{",
"continue",
... | // del returns a slice where all ocurences of s are filtered out. This modifies
// the original slice. | [
"del",
"returns",
"a",
"slice",
"where",
"all",
"ocurences",
"of",
"s",
"are",
"filtered",
"out",
".",
"This",
"modifies",
"the",
"original",
"slice",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_via_discover_provider.go#L183-L193 |
21,107 | uber/ringpop-go | util/util.go | ShuffleStrings | func ShuffleStrings(strings []string) []string {
newStrings := make([]string, len(strings))
newIndexes := rand.Perm(len(strings))
for o, n := range newIndexes {
newStrings[n] = strings[o]
}
return newStrings
} | go | func ShuffleStrings(strings []string) []string {
newStrings := make([]string, len(strings))
newIndexes := rand.Perm(len(strings))
for o, n := range newIndexes {
newStrings[n] = strings[o]
}
return newStrings
} | [
"func",
"ShuffleStrings",
"(",
"strings",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"newStrings",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"strings",
")",
")",
"\n",
"newIndexes",
":=",
"rand",
".",
"Perm",
"(",
"len",
"(",
"... | // ShuffleStrings takes a slice of strings and returns a new slice containing
// the same strings in a random order. | [
"ShuffleStrings",
"takes",
"a",
"slice",
"of",
"strings",
"and",
"returns",
"a",
"new",
"slice",
"containing",
"the",
"same",
"strings",
"in",
"a",
"random",
"order",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/util/util.go#L176-L185 |
21,108 | uber/ringpop-go | util/util.go | TakeNode | func TakeNode(nodes *[]string, index int) string {
if len(*nodes) == 0 {
return ""
}
var i int
if index >= 0 {
if index >= len(*nodes) {
return ""
}
i = index
} else {
i = rand.Intn(len(*nodes))
}
node := (*nodes)[i]
*nodes = append((*nodes)[:i], (*nodes)[i+1:]...)
return node
} | go | func TakeNode(nodes *[]string, index int) string {
if len(*nodes) == 0 {
return ""
}
var i int
if index >= 0 {
if index >= len(*nodes) {
return ""
}
i = index
} else {
i = rand.Intn(len(*nodes))
}
node := (*nodes)[i]
*nodes = append((*nodes)[:i], (*nodes)[i+1:]...)
return node
} | [
"func",
"TakeNode",
"(",
"nodes",
"*",
"[",
"]",
"string",
",",
"index",
"int",
")",
"string",
"{",
"if",
"len",
"(",
"*",
"nodes",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"i",
"int",
"\n",
"if",
"index",
">=",
"0",... | // TakeNode takes an element from nodes at the given index, or at a random index if
// index < 0. Mutates nodes. | [
"TakeNode",
"takes",
"an",
"element",
"from",
"nodes",
"at",
"the",
"given",
"index",
"or",
"at",
"a",
"random",
"index",
"if",
"index",
"<",
"0",
".",
"Mutates",
"nodes",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/util/util.go#L198-L218 |
21,109 | uber/ringpop-go | util/util.go | SelectDuration | func SelectDuration(opt, def time.Duration) time.Duration {
if opt == time.Duration(0) {
return def
}
return opt
} | go | func SelectDuration(opt, def time.Duration) time.Duration {
if opt == time.Duration(0) {
return def
}
return opt
} | [
"func",
"SelectDuration",
"(",
"opt",
",",
"def",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"if",
"opt",
"==",
"time",
".",
"Duration",
"(",
"0",
")",
"{",
"return",
"def",
"\n",
"}",
"\n",
"return",
"opt",
"\n",
"}"
] | // SelectDuration takes an option and a default value and returns the default value if
// the option is equal to zero, and the option otherwise. | [
"SelectDuration",
"takes",
"an",
"option",
"and",
"a",
"default",
"value",
"and",
"returns",
"the",
"default",
"value",
"if",
"the",
"option",
"is",
"equal",
"to",
"zero",
"and",
"the",
"option",
"otherwise",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/util/util.go#L240-L245 |
21,110 | uber/ringpop-go | util/util.go | Min | func Min(first int, rest ...int) int {
m := first
for _, value := range rest {
if value < m {
m = value
}
}
return m
} | go | func Min(first int, rest ...int) int {
m := first
for _, value := range rest {
if value < m {
m = value
}
}
return m
} | [
"func",
"Min",
"(",
"first",
"int",
",",
"rest",
"...",
"int",
")",
"int",
"{",
"m",
":=",
"first",
"\n",
"for",
"_",
",",
"value",
":=",
"range",
"rest",
"{",
"if",
"value",
"<",
"m",
"{",
"m",
"=",
"value",
"\n",
"}",
"\n",
"}",
"\n",
"retu... | // Min returns the lowest integer and is defined because golang only has a min
// function for floats and not for ints. | [
"Min",
"returns",
"the",
"lowest",
"integer",
"and",
"is",
"defined",
"because",
"golang",
"only",
"has",
"a",
"min",
"function",
"for",
"floats",
"and",
"not",
"for",
"ints",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/util/util.go#L258-L266 |
21,111 | uber/ringpop-go | util/util.go | UnmarshalJSON | func (t *Timestamp) UnmarshalJSON(b []byte) error {
ts, err := strconv.Atoi(string(b))
if err != nil {
return err
}
*t = Timestamp(time.Unix(int64(ts), 0))
return nil
} | go | func (t *Timestamp) UnmarshalJSON(b []byte) error {
ts, err := strconv.Atoi(string(b))
if err != nil {
return err
}
*t = Timestamp(time.Unix(int64(ts), 0))
return nil
} | [
"func",
"(",
"t",
"*",
"Timestamp",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"ts",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"string",
"(",
"b",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\... | // UnmarshalJSON sets the timestamp to the value in the specified JSON. | [
"UnmarshalJSON",
"sets",
"the",
"timestamp",
"to",
"the",
"value",
"in",
"the",
"specified",
"JSON",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/util/util.go#L281-L290 |
21,112 | uber/ringpop-go | swim/join_delayer.go | newDelayOpts | func newDelayOpts() *delayOpts {
return &delayOpts{
initial: defaultInitial,
max: defaultMax,
randomizer: defaultRandomizer,
sleeper: defaultSleeper,
}
} | go | func newDelayOpts() *delayOpts {
return &delayOpts{
initial: defaultInitial,
max: defaultMax,
randomizer: defaultRandomizer,
sleeper: defaultSleeper,
}
} | [
"func",
"newDelayOpts",
"(",
")",
"*",
"delayOpts",
"{",
"return",
"&",
"delayOpts",
"{",
"initial",
":",
"defaultInitial",
",",
"max",
":",
"defaultMax",
",",
"randomizer",
":",
"defaultRandomizer",
",",
"sleeper",
":",
"defaultSleeper",
",",
"}",
"\n",
"}"... | // newDelayOpts creates a delayOpts struct with default values. | [
"newDelayOpts",
"creates",
"a",
"delayOpts",
"struct",
"with",
"default",
"values",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_delayer.go#L66-L73 |
21,113 | uber/ringpop-go | swim/join_delayer.go | newExponentialDelayer | func newExponentialDelayer(joiner string, opts *delayOpts) (*exponentialDelayer, error) {
if opts == nil {
opts = newDelayOpts()
}
randomizer := opts.randomizer
if randomizer == nil {
randomizer = defaultRandomizer
}
sleeper := opts.sleeper
if sleeper == nil {
sleeper = defaultSleeper
}
return &expone... | go | func newExponentialDelayer(joiner string, opts *delayOpts) (*exponentialDelayer, error) {
if opts == nil {
opts = newDelayOpts()
}
randomizer := opts.randomizer
if randomizer == nil {
randomizer = defaultRandomizer
}
sleeper := opts.sleeper
if sleeper == nil {
sleeper = defaultSleeper
}
return &expone... | [
"func",
"newExponentialDelayer",
"(",
"joiner",
"string",
",",
"opts",
"*",
"delayOpts",
")",
"(",
"*",
"exponentialDelayer",
",",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"newDelayOpts",
"(",
")",
"\n",
"}",
"\n\n",
"randomizer",
... | // newExponentialDelayer creates a new exponential delayer. joiner is required.
// opts is optional. | [
"newExponentialDelayer",
"creates",
"a",
"new",
"exponential",
"delayer",
".",
"joiner",
"is",
"required",
".",
"opts",
"is",
"optional",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_delayer.go#L112-L137 |
21,114 | uber/ringpop-go | swim/join_delayer.go | delay | func (d *exponentialDelayer) delay() time.Duration {
// Convert durations to time in millis
initialDelayMs := float64(util.MS(d.initialDelay))
maxDelayMs := float64(util.MS(d.maxDelay))
// Compute uncapped exponential delay (exponent is the number of join
// attempts so far). Then, make sure the computed delay is... | go | func (d *exponentialDelayer) delay() time.Duration {
// Convert durations to time in millis
initialDelayMs := float64(util.MS(d.initialDelay))
maxDelayMs := float64(util.MS(d.maxDelay))
// Compute uncapped exponential delay (exponent is the number of join
// attempts so far). Then, make sure the computed delay is... | [
"func",
"(",
"d",
"*",
"exponentialDelayer",
")",
"delay",
"(",
")",
"time",
".",
"Duration",
"{",
"// Convert durations to time in millis",
"initialDelayMs",
":=",
"float64",
"(",
"util",
".",
"MS",
"(",
"d",
".",
"initialDelay",
")",
")",
"\n",
"maxDelayMs",... | // delay delays a join attempt by sleeping for an amount of time. The
// amount of time is computed as an exponential backoff based on the number
// of join attempts that have been made at the time of the function call;
// the number of attempts is 0-based. It returns a time.Duration equal to the
// amount of delay app... | [
"delay",
"delays",
"a",
"join",
"attempt",
"by",
"sleeping",
"for",
"an",
"amount",
"of",
"time",
".",
"The",
"amount",
"of",
"time",
"is",
"computed",
"as",
"an",
"exponential",
"backoff",
"based",
"on",
"the",
"number",
"of",
"join",
"attempts",
"that",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_delayer.go#L144-L191 |
21,115 | uber/ringpop-go | examples/ping-thrift-gen/gen-go/ping/ringpop-ping.go | Ping | func (a *RingpopPingPongServiceAdapter) Ping(ctx thrift.Context, request *Ping) (r *Pong, err error) {
// check if the function should be called locally
if a.config.Ping == nil || forward.DeleteForwardedHeader(ctx) {
return a.impl.Ping(ctx, request)
}
// find the key to shard on
ringpopKey, err := a.config.Ping... | go | func (a *RingpopPingPongServiceAdapter) Ping(ctx thrift.Context, request *Ping) (r *Pong, err error) {
// check if the function should be called locally
if a.config.Ping == nil || forward.DeleteForwardedHeader(ctx) {
return a.impl.Ping(ctx, request)
}
// find the key to shard on
ringpopKey, err := a.config.Ping... | [
"func",
"(",
"a",
"*",
"RingpopPingPongServiceAdapter",
")",
"Ping",
"(",
"ctx",
"thrift",
".",
"Context",
",",
"request",
"*",
"Ping",
")",
"(",
"r",
"*",
"Pong",
",",
"err",
"error",
")",
"{",
"// check if the function should be called locally",
"if",
"a",
... | // Ping satisfies the TChanPingPongService interface. This function uses the configuration for Ping to determine the host to execute the call on. When it decides the call needs to be executed in the current process it will forward the invocation to its local implementation. | [
"Ping",
"satisfies",
"the",
"TChanPingPongService",
"interface",
".",
"This",
"function",
"uses",
"the",
"configuration",
"for",
"Ping",
"to",
"determine",
"the",
"host",
"to",
"execute",
"the",
"call",
"on",
".",
"When",
"it",
"decides",
"the",
"call",
"needs... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/examples/ping-thrift-gen/gen-go/ping/ringpop-ping.go#L100-L122 |
21,116 | uber/ringpop-go | logging/named.go | WithField | func (l *namedLogger) WithField(key string, value interface{}) bark.Logger {
newSize := len(l.fields) + 1
newFields := make(map[string]interface{}, newSize) // Hold the updated copy
for k, v := range l.fields {
newFields[k] = v
}
newFields[key] = value // Set the new key.
return &namedLogger{
name: l.na... | go | func (l *namedLogger) WithField(key string, value interface{}) bark.Logger {
newSize := len(l.fields) + 1
newFields := make(map[string]interface{}, newSize) // Hold the updated copy
for k, v := range l.fields {
newFields[k] = v
}
newFields[key] = value // Set the new key.
return &namedLogger{
name: l.na... | [
"func",
"(",
"l",
"*",
"namedLogger",
")",
"WithField",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"bark",
".",
"Logger",
"{",
"newSize",
":=",
"len",
"(",
"l",
".",
"fields",
")",
"+",
"1",
"\n",
"newFields",
":=",
"make",
"("... | // WithField creates a new namedLogger that retains the name but has an updated
// copy of the fields. | [
"WithField",
"creates",
"a",
"new",
"namedLogger",
"that",
"retains",
"the",
"name",
"but",
"has",
"an",
"updated",
"copy",
"of",
"the",
"fields",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/named.go#L72-L85 |
21,117 | uber/ringpop-go | logging/named.go | WithError | func (l *namedLogger) WithError(err error) bark.Logger {
return &namedLogger{
name: l.name,
forwardTo: l.forwardTo,
err: err,
fields: l.Fields(),
}
} | go | func (l *namedLogger) WithError(err error) bark.Logger {
return &namedLogger{
name: l.name,
forwardTo: l.forwardTo,
err: err,
fields: l.Fields(),
}
} | [
"func",
"(",
"l",
"*",
"namedLogger",
")",
"WithError",
"(",
"err",
"error",
")",
"bark",
".",
"Logger",
"{",
"return",
"&",
"namedLogger",
"{",
"name",
":",
"l",
".",
"name",
",",
"forwardTo",
":",
"l",
".",
"forwardTo",
",",
"err",
":",
"err",
",... | // Return a new named logger with the error set to be included in a subsequent
// normal logging call | [
"Return",
"a",
"new",
"named",
"logger",
"with",
"the",
"error",
"set",
"to",
"be",
"included",
"in",
"a",
"subsequent",
"normal",
"logging",
"call"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/named.go#L109-L116 |
21,118 | uber/ringpop-go | swim/ping_sender.go | sendPing | func sendPing(node *Node, target string, timeout time.Duration) (*ping, error) {
changes, bumpPiggybackCounters := node.disseminator.IssueAsSender()
res, err := sendPingWithChanges(node, target, changes, timeout)
if err != nil {
return res, err
}
// when ping was successful
bumpPiggybackCounters()
return re... | go | func sendPing(node *Node, target string, timeout time.Duration) (*ping, error) {
changes, bumpPiggybackCounters := node.disseminator.IssueAsSender()
res, err := sendPingWithChanges(node, target, changes, timeout)
if err != nil {
return res, err
}
// when ping was successful
bumpPiggybackCounters()
return re... | [
"func",
"sendPing",
"(",
"node",
"*",
"Node",
",",
"target",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"ping",
",",
"error",
")",
"{",
"changes",
",",
"bumpPiggybackCounters",
":=",
"node",
".",
"disseminator",
".",
"IssueAsSender",... | // sendPing sends a ping to target node that times out after timeout | [
"sendPing",
"sends",
"a",
"ping",
"to",
"target",
"node",
"that",
"times",
"out",
"after",
"timeout"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/ping_sender.go#L44-L56 |
21,119 | uber/ringpop-go | swim/ping_sender.go | sendPingWithChanges | func sendPingWithChanges(node *Node, target string, changes []Change, timeout time.Duration) (*ping, error) {
req := ping{
Checksum: node.memberlist.Checksum(),
Changes: changes,
Source: node.Address(),
SourceIncarnation: node.Incarnation(),
App: node.app,
}
nod... | go | func sendPingWithChanges(node *Node, target string, changes []Change, timeout time.Duration) (*ping, error) {
req := ping{
Checksum: node.memberlist.Checksum(),
Changes: changes,
Source: node.Address(),
SourceIncarnation: node.Incarnation(),
App: node.app,
}
nod... | [
"func",
"sendPingWithChanges",
"(",
"node",
"*",
"Node",
",",
"target",
"string",
",",
"changes",
"[",
"]",
"Change",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"ping",
",",
"error",
")",
"{",
"req",
":=",
"ping",
"{",
"Checksum",
":",
"... | // sendPingWithChanges sends a special ping to the target with the given changes.
// In normal pings the disseminator is consulted to create issue the changes,
// this is not the case in this function. Only the given changes are transmitted. | [
"sendPingWithChanges",
"sends",
"a",
"special",
"ping",
"to",
"the",
"target",
"with",
"the",
"given",
"changes",
".",
"In",
"normal",
"pings",
"the",
"disseminator",
"is",
"consulted",
"to",
"create",
"issue",
"the",
"changes",
"this",
"is",
"not",
"the",
"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/ping_sender.go#L61-L122 |
21,120 | uber/ringpop-go | hashring/rbtree.go | Child | func (n *redBlackNode) Child(right bool) *redBlackNode {
if right {
return n.right
}
return n.left
} | go | func (n *redBlackNode) Child(right bool) *redBlackNode {
if right {
return n.right
}
return n.left
} | [
"func",
"(",
"n",
"*",
"redBlackNode",
")",
"Child",
"(",
"right",
"bool",
")",
"*",
"redBlackNode",
"{",
"if",
"right",
"{",
"return",
"n",
".",
"right",
"\n",
"}",
"\n",
"return",
"n",
".",
"left",
"\n",
"}"
] | // Child returns the left or right node of the redBlackTree | [
"Child",
"returns",
"the",
"left",
"or",
"right",
"node",
"of",
"the",
"redBlackTree"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L50-L55 |
21,121 | uber/ringpop-go | hashring/rbtree.go | Insert | func (t *redBlackTree) Insert(key keytype, value valuetype) (ret bool) {
if t.root == nil {
t.root = &redBlackNode{
key: key,
value: value,
}
ret = true
} else {
var head = &redBlackNode{}
var dir = true
var last = true
var parent *redBlackNode // parent
var gparent *redBlackNode // grandpa... | go | func (t *redBlackTree) Insert(key keytype, value valuetype) (ret bool) {
if t.root == nil {
t.root = &redBlackNode{
key: key,
value: value,
}
ret = true
} else {
var head = &redBlackNode{}
var dir = true
var last = true
var parent *redBlackNode // parent
var gparent *redBlackNode // grandpa... | [
"func",
"(",
"t",
"*",
"redBlackTree",
")",
"Insert",
"(",
"key",
"keytype",
",",
"value",
"valuetype",
")",
"(",
"ret",
"bool",
")",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"t",
".",
"root",
"=",
"&",
"redBlackNode",
"{",
"key",
":",
"key... | // Insert inserts a value and string into the tree
// Returns true on succesful insertion, false if duplicate exists | [
"Insert",
"inserts",
"a",
"value",
"and",
"string",
"into",
"the",
"tree",
"Returns",
"true",
"on",
"succesful",
"insertion",
"false",
"if",
"duplicate",
"exists"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L89-L166 |
21,122 | uber/ringpop-go | hashring/rbtree.go | Delete | func (t *redBlackTree) Delete(key keytype) bool {
if t.root == nil {
return false
}
var head = &redBlackNode{red: true} // fake red node to push down
var node = head
var parent *redBlackNode //parent
var gparent *redBlackNode //grandparent
var found *redBlackNode
var dir = true
node.right = t.root
for ... | go | func (t *redBlackTree) Delete(key keytype) bool {
if t.root == nil {
return false
}
var head = &redBlackNode{red: true} // fake red node to push down
var node = head
var parent *redBlackNode //parent
var gparent *redBlackNode //grandparent
var found *redBlackNode
var dir = true
node.right = t.root
for ... | [
"func",
"(",
"t",
"*",
"redBlackTree",
")",
"Delete",
"(",
"key",
"keytype",
")",
"bool",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"var",
"head",
"=",
"&",
"redBlackNode",
"{",
"red",
":",
"true",
"}",
... | // Delete removes the entry for key from the redBlackTree. Returns true on
// succesful deletion, false if the key is not in tree | [
"Delete",
"removes",
"the",
"entry",
"for",
"key",
"from",
"the",
"redBlackTree",
".",
"Returns",
"true",
"on",
"succesful",
"deletion",
"false",
"if",
"the",
"key",
"is",
"not",
"in",
"tree"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L170-L248 |
21,123 | uber/ringpop-go | hashring/rbtree.go | traverseWhile | func (n *redBlackNode) traverseWhile(condition func(*redBlackNode) bool) bool {
if n == nil {
// the end of the tree does not signal the end of walking, but we can't
// walk this node (nil) nor left or right anymore
return true
}
// walk left first
if !n.left.traverseWhile(condition) {
// stop if walker in... | go | func (n *redBlackNode) traverseWhile(condition func(*redBlackNode) bool) bool {
if n == nil {
// the end of the tree does not signal the end of walking, but we can't
// walk this node (nil) nor left or right anymore
return true
}
// walk left first
if !n.left.traverseWhile(condition) {
// stop if walker in... | [
"func",
"(",
"n",
"*",
"redBlackNode",
")",
"traverseWhile",
"(",
"condition",
"func",
"(",
"*",
"redBlackNode",
")",
"bool",
")",
"bool",
"{",
"if",
"n",
"==",
"nil",
"{",
"// the end of the tree does not signal the end of walking, but we can't",
"// walk this node (... | // traverseWhile traverses the nodes in the tree in-order invoking the `condition`-function argument for each node.
// If the condition-function returns `false` traversal is stopped and no more nodes will be
// visited. Returns `true` if all nodes are visited; `false` if not. | [
"traverseWhile",
"traverses",
"the",
"nodes",
"in",
"the",
"tree",
"in",
"-",
"order",
"invoking",
"the",
"condition",
"-",
"function",
"argument",
"for",
"each",
"node",
".",
"If",
"the",
"condition",
"-",
"function",
"returns",
"false",
"traversal",
"is",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L267-L293 |
21,124 | uber/ringpop-go | hashring/rbtree.go | Search | func (t *redBlackTree) Search(key keytype) (valuetype, bool) {
if t.root == nil {
return nil, false
}
return t.root.search(key)
} | go | func (t *redBlackTree) Search(key keytype) (valuetype, bool) {
if t.root == nil {
return nil, false
}
return t.root.search(key)
} | [
"func",
"(",
"t",
"*",
"redBlackTree",
")",
"Search",
"(",
"key",
"keytype",
")",
"(",
"valuetype",
",",
"bool",
")",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\n",
"return",
"t",
".",
"root",
".",
... | // Search searches for the entry for key in the redBlackTree, returns the value
// and true if found or nil and false if there is no entry for key in the tree. | [
"Search",
"searches",
"for",
"the",
"entry",
"for",
"key",
"in",
"the",
"redBlackTree",
"returns",
"the",
"value",
"and",
"true",
"if",
"found",
"or",
"nil",
"and",
"false",
"if",
"there",
"is",
"no",
"entry",
"for",
"key",
"in",
"the",
"tree",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L297-L302 |
21,125 | uber/ringpop-go | hashring/rbtree.go | LookupNUniqueAt | func (t *redBlackTree) LookupNUniqueAt(n int, key keytype, result map[valuetype]struct{}) {
findNUniqueAbove(t.root, n, key, result, nil)
} | go | func (t *redBlackTree) LookupNUniqueAt(n int, key keytype, result map[valuetype]struct{}) {
findNUniqueAbove(t.root, n, key, result, nil)
} | [
"func",
"(",
"t",
"*",
"redBlackTree",
")",
"LookupNUniqueAt",
"(",
"n",
"int",
",",
"key",
"keytype",
",",
"result",
"map",
"[",
"valuetype",
"]",
"struct",
"{",
"}",
")",
"{",
"findNUniqueAbove",
"(",
"t",
".",
"root",
",",
"n",
",",
"key",
",",
... | // LookupNUniqueAt iterates through the tree from the last node that is smaller
// than key or equal, and returns the next n unique values. This function is not
// guaranteed to return n values, less might be returned. Because this function
// relies on writing the unique values to a golang map type, order cannot be
//... | [
"LookupNUniqueAt",
"iterates",
"through",
"the",
"tree",
"from",
"the",
"last",
"node",
"that",
"is",
"smaller",
"than",
"key",
"or",
"equal",
"and",
"returns",
"the",
"next",
"n",
"unique",
"values",
".",
"This",
"function",
"is",
"not",
"guaranteed",
"to",... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L309-L311 |
21,126 | uber/ringpop-go | hashring/rbtree.go | LookupOrderedNUniqueAt | func (t *redBlackTree) LookupOrderedNUniqueAt(n int, key keytype, result map[valuetype]struct{}, orderedResult *[]valuetype) {
findNUniqueAbove(t.root, n, key, result, orderedResult)
} | go | func (t *redBlackTree) LookupOrderedNUniqueAt(n int, key keytype, result map[valuetype]struct{}, orderedResult *[]valuetype) {
findNUniqueAbove(t.root, n, key, result, orderedResult)
} | [
"func",
"(",
"t",
"*",
"redBlackTree",
")",
"LookupOrderedNUniqueAt",
"(",
"n",
"int",
",",
"key",
"keytype",
",",
"result",
"map",
"[",
"valuetype",
"]",
"struct",
"{",
"}",
",",
"orderedResult",
"*",
"[",
"]",
"valuetype",
")",
"{",
"findNUniqueAbove",
... | // LookupOrderedNUniqueAt iterates through the tree from the last node that is
// smaller than key or equal, and returns the next n unique values. This function
// is not guaranteed to return n values, less might be returned. This method
// replaces LookupNUniqueAt since it uses a slice to guarantee order. | [
"LookupOrderedNUniqueAt",
"iterates",
"through",
"the",
"tree",
"from",
"the",
"last",
"node",
"that",
"is",
"smaller",
"than",
"key",
"or",
"equal",
"and",
"returns",
"the",
"next",
"n",
"unique",
"values",
".",
"This",
"function",
"is",
"not",
"guaranteed",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L317-L319 |
21,127 | uber/ringpop-go | hashring/rbtree.go | findNUniqueAbove | func findNUniqueAbove(node *redBlackNode, n int, key keytype, result map[valuetype]struct{}, orderedResult *[]valuetype) {
if len(result) >= n || node == nil {
return
}
// skip left branch when all its keys are smaller than key
cmp := node.key.Compare(key)
if cmp >= 0 {
findNUniqueAbove(node.left, n, key, res... | go | func findNUniqueAbove(node *redBlackNode, n int, key keytype, result map[valuetype]struct{}, orderedResult *[]valuetype) {
if len(result) >= n || node == nil {
return
}
// skip left branch when all its keys are smaller than key
cmp := node.key.Compare(key)
if cmp >= 0 {
findNUniqueAbove(node.left, n, key, res... | [
"func",
"findNUniqueAbove",
"(",
"node",
"*",
"redBlackNode",
",",
"n",
"int",
",",
"key",
"keytype",
",",
"result",
"map",
"[",
"valuetype",
"]",
"struct",
"{",
"}",
",",
"orderedResult",
"*",
"[",
"]",
"valuetype",
")",
"{",
"if",
"len",
"(",
"result... | // findNUniqueAbove is a recursive search that finds n unique values with a key
// bigger or equal than key | [
"findNUniqueAbove",
"is",
"a",
"recursive",
"search",
"that",
"finds",
"n",
"unique",
"values",
"with",
"a",
"key",
"bigger",
"or",
"equal",
"than",
"key"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/rbtree.go#L323-L347 |
21,128 | uber/ringpop-go | examples/keyvalue/gen-go/keyvalue/ringpop-keyvalue.go | Get | func (a *RingpopKeyValueServiceAdapter) Get(ctx thrift.Context, key string) (r string, err error) {
// check if the function should be called locally
if a.config.Get == nil || forward.DeleteForwardedHeader(ctx) {
return a.impl.Get(ctx, key)
}
// find the key to shard on
ringpopKey, err := a.config.Get.Key(ctx, ... | go | func (a *RingpopKeyValueServiceAdapter) Get(ctx thrift.Context, key string) (r string, err error) {
// check if the function should be called locally
if a.config.Get == nil || forward.DeleteForwardedHeader(ctx) {
return a.impl.Get(ctx, key)
}
// find the key to shard on
ringpopKey, err := a.config.Get.Key(ctx, ... | [
"func",
"(",
"a",
"*",
"RingpopKeyValueServiceAdapter",
")",
"Get",
"(",
"ctx",
"thrift",
".",
"Context",
",",
"key",
"string",
")",
"(",
"r",
"string",
",",
"err",
"error",
")",
"{",
"// check if the function should be called locally",
"if",
"a",
".",
"config... | // Get satisfies the TChanKeyValueService interface. This function uses the configuration for Get to determine the host to execute the call on. When it decides the call needs to be executed in the current process it will forward the invocation to its local implementation. | [
"Get",
"satisfies",
"the",
"TChanKeyValueService",
"interface",
".",
"This",
"function",
"uses",
"the",
"configuration",
"for",
"Get",
"to",
"determine",
"the",
"host",
"to",
"execute",
"the",
"call",
"on",
".",
"When",
"it",
"decides",
"the",
"call",
"needs",... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/examples/keyvalue/gen-go/keyvalue/ringpop-keyvalue.go#L124-L146 |
21,129 | uber/ringpop-go | hashring/hashring.go | New | func New(hashfunc func([]byte) uint32, replicaPoints int) *HashRing {
r := &HashRing{
replicaPoints: replicaPoints,
hashfunc: func(str string) int {
return int(hashfunc([]byte(str)))
},
logger: logging.Logger("ring"),
checksummers: map[string]Checksummer{
"replica": &replicaPointChecksummer{},
},
}... | go | func New(hashfunc func([]byte) uint32, replicaPoints int) *HashRing {
r := &HashRing{
replicaPoints: replicaPoints,
hashfunc: func(str string) int {
return int(hashfunc([]byte(str)))
},
logger: logging.Logger("ring"),
checksummers: map[string]Checksummer{
"replica": &replicaPointChecksummer{},
},
}... | [
"func",
"New",
"(",
"hashfunc",
"func",
"(",
"[",
"]",
"byte",
")",
"uint32",
",",
"replicaPoints",
"int",
")",
"*",
"HashRing",
"{",
"r",
":=",
"&",
"HashRing",
"{",
"replicaPoints",
":",
"replicaPoints",
",",
"hashfunc",
":",
"func",
"(",
"str",
"str... | // New instantiates and returns a new HashRing. | [
"New",
"instantiates",
"and",
"returns",
"a",
"new",
"HashRing",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L106-L122 |
21,130 | uber/ringpop-go | hashring/hashring.go | Checksum | func (r *HashRing) Checksum() (checksum uint32) {
r.RLock()
checksum = r.legacyChecksum
r.RUnlock()
return
} | go | func (r *HashRing) Checksum() (checksum uint32) {
r.RLock()
checksum = r.legacyChecksum
r.RUnlock()
return
} | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"Checksum",
"(",
")",
"(",
"checksum",
"uint32",
")",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"checksum",
"=",
"r",
".",
"legacyChecksum",
"\n",
"r",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Checksum returns the checksum of all stored servers in the HashRing
// Use this value to find out if the HashRing is mutated. | [
"Checksum",
"returns",
"the",
"checksum",
"of",
"all",
"stored",
"servers",
"in",
"the",
"HashRing",
"Use",
"this",
"value",
"to",
"find",
"out",
"if",
"the",
"HashRing",
"is",
"mutated",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L126-L131 |
21,131 | uber/ringpop-go | hashring/hashring.go | Checksums | func (r *HashRing) Checksums() (checksums map[string]uint32) {
r.RLock()
// even though the map is immutable the pointer to it is not so it requires
// a readlock
checksums = r.checksums
r.RUnlock()
return
} | go | func (r *HashRing) Checksums() (checksums map[string]uint32) {
r.RLock()
// even though the map is immutable the pointer to it is not so it requires
// a readlock
checksums = r.checksums
r.RUnlock()
return
} | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"Checksums",
"(",
")",
"(",
"checksums",
"map",
"[",
"string",
"]",
"uint32",
")",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"// even though the map is immutable the pointer to it is not so it requires",
"// a readlock",
"chec... | // Checksums returns a map of checksums named by the algorithm used to compute
// the checksum. | [
"Checksums",
"returns",
"a",
"map",
"of",
"checksums",
"named",
"by",
"the",
"algorithm",
"used",
"to",
"compute",
"the",
"checksum",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L135-L142 |
21,132 | uber/ringpop-go | hashring/hashring.go | computeChecksumsNoLock | func (r *HashRing) computeChecksumsNoLock() {
oldChecksums := r.checksums
r.checksums = make(map[string]uint32)
changed := false
// calculate all configured checksums
for name, checksummer := range r.checksummers {
oldChecksum := oldChecksums[name]
newChecksum := checksummer.Checksum(r)
r.checksums[name] = ... | go | func (r *HashRing) computeChecksumsNoLock() {
oldChecksums := r.checksums
r.checksums = make(map[string]uint32)
changed := false
// calculate all configured checksums
for name, checksummer := range r.checksummers {
oldChecksum := oldChecksums[name]
newChecksum := checksummer.Checksum(r)
r.checksums[name] = ... | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"computeChecksumsNoLock",
"(",
")",
"{",
"oldChecksums",
":=",
"r",
".",
"checksums",
"\n\n",
"r",
".",
"checksums",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"uint32",
")",
"\n",
"changed",
":=",
"false",
"\n... | // computeChecksumsNoLock re-computes all configured checksums for this hashring
// and updates the in memory map with a new map containing the new checksums. | [
"computeChecksumsNoLock",
"re",
"-",
"computes",
"all",
"configured",
"checksums",
"for",
"this",
"hashring",
"and",
"updates",
"the",
"in",
"memory",
"map",
"with",
"a",
"new",
"map",
"containing",
"the",
"new",
"checksums",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L146-L186 |
21,133 | uber/ringpop-go | hashring/hashring.go | AddMembers | func (r *HashRing) AddMembers(members ...membership.Member) bool {
r.Lock()
changed := false
var added []string
for _, member := range members {
if r.addMemberNoLock(member) {
added = append(added, member.GetAddress())
changed = true
}
}
if changed {
r.computeChecksumsNoLock()
r.EmitEvent(events.Ri... | go | func (r *HashRing) AddMembers(members ...membership.Member) bool {
r.Lock()
changed := false
var added []string
for _, member := range members {
if r.addMemberNoLock(member) {
added = append(added, member.GetAddress())
changed = true
}
}
if changed {
r.computeChecksumsNoLock()
r.EmitEvent(events.Ri... | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"AddMembers",
"(",
"members",
"...",
"membership",
".",
"Member",
")",
"bool",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"changed",
":=",
"false",
"\n",
"var",
"added",
"[",
"]",
"string",
"\n",
"for",
"_",
",",... | // AddMembers adds multiple membership Member's and thus their replicas to the HashRing. | [
"AddMembers",
"adds",
"multiple",
"membership",
"Member",
"s",
"and",
"thus",
"their",
"replicas",
"to",
"the",
"HashRing",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L210-L229 |
21,134 | uber/ringpop-go | hashring/hashring.go | RemoveMembers | func (r *HashRing) RemoveMembers(members ...membership.Member) bool {
r.Lock()
changed := false
var removed []string
for _, server := range members {
if r.removeMemberNoLock(server) {
removed = append(removed, server.GetAddress())
changed = true
}
}
if changed {
r.computeChecksumsNoLock()
r.EmitEve... | go | func (r *HashRing) RemoveMembers(members ...membership.Member) bool {
r.Lock()
changed := false
var removed []string
for _, server := range members {
if r.removeMemberNoLock(server) {
removed = append(removed, server.GetAddress())
changed = true
}
}
if changed {
r.computeChecksumsNoLock()
r.EmitEve... | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"RemoveMembers",
"(",
"members",
"...",
"membership",
".",
"Member",
")",
"bool",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"changed",
":=",
"false",
"\n",
"var",
"removed",
"[",
"]",
"string",
"\n",
"for",
"_",
... | // RemoveMembers removes multiple membership Member's and thus their replicas from the HashRing. | [
"RemoveMembers",
"removes",
"multiple",
"membership",
"Member",
"s",
"and",
"thus",
"their",
"replicas",
"from",
"the",
"HashRing",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L250-L269 |
21,135 | uber/ringpop-go | hashring/hashring.go | ProcessMembershipChanges | func (r *HashRing) ProcessMembershipChanges(changes []membership.MemberChange) {
r.Lock()
changed := false
var added, updated, removed []string
for _, change := range changes {
if change.Before == nil && change.After != nil {
// new member
if r.addMemberNoLock(change.After) {
added = append(added, chang... | go | func (r *HashRing) ProcessMembershipChanges(changes []membership.MemberChange) {
r.Lock()
changed := false
var added, updated, removed []string
for _, change := range changes {
if change.Before == nil && change.After != nil {
// new member
if r.addMemberNoLock(change.After) {
added = append(added, chang... | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"ProcessMembershipChanges",
"(",
"changes",
"[",
"]",
"membership",
".",
"MemberChange",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"changed",
":=",
"false",
"\n",
"var",
"added",
",",
"updated",
",",
"removed",
... | // ProcessMembershipChanges takes a slice of membership.MemberChange's and
// applies them to the hashring by adding and removing members accordingly to
// the changes passed in. | [
"ProcessMembershipChanges",
"takes",
"a",
"slice",
"of",
"membership",
".",
"MemberChange",
"s",
"and",
"applies",
"them",
"to",
"the",
"hashring",
"by",
"adding",
"and",
"removing",
"members",
"accordingly",
"to",
"the",
"changes",
"passed",
"in",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L290-L329 |
21,136 | uber/ringpop-go | hashring/hashring.go | HasServer | func (r *HashRing) HasServer(server string) bool {
r.RLock()
_, ok := r.serverSet[server]
r.RUnlock()
return ok
} | go | func (r *HashRing) HasServer(server string) bool {
r.RLock()
_, ok := r.serverSet[server]
r.RUnlock()
return ok
} | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"HasServer",
"(",
"server",
"string",
")",
"bool",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"r",
".",
"serverSet",
"[",
"server",
"]",
"\n",
"r",
".",
"RUnlock",
"(",
")",
"\n",
"retu... | // HasServer returns whether the HashRing contains the given server. | [
"HasServer",
"returns",
"whether",
"the",
"HashRing",
"contains",
"the",
"given",
"server",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L332-L337 |
21,137 | uber/ringpop-go | hashring/hashring.go | Servers | func (r *HashRing) Servers() []string {
r.RLock()
servers := r.copyServersNoLock()
r.RUnlock()
return servers
} | go | func (r *HashRing) Servers() []string {
r.RLock()
servers := r.copyServersNoLock()
r.RUnlock()
return servers
} | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"Servers",
"(",
")",
"[",
"]",
"string",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"servers",
":=",
"r",
".",
"copyServersNoLock",
"(",
")",
"\n",
"r",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"servers",
"\n... | // Servers returns all servers contained in the HashRing. | [
"Servers",
"returns",
"all",
"servers",
"contained",
"in",
"the",
"HashRing",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L340-L345 |
21,138 | uber/ringpop-go | hashring/hashring.go | ServerCount | func (r *HashRing) ServerCount() int {
r.RLock()
count := len(r.serverSet)
r.RUnlock()
return count
} | go | func (r *HashRing) ServerCount() int {
r.RLock()
count := len(r.serverSet)
r.RUnlock()
return count
} | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"ServerCount",
"(",
")",
"int",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"count",
":=",
"len",
"(",
"r",
".",
"serverSet",
")",
"\n",
"r",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"count",
"\n",
"}"
] | // ServerCount returns the number of servers contained in the HashRing. | [
"ServerCount",
"returns",
"the",
"number",
"of",
"servers",
"contained",
"in",
"the",
"HashRing",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L357-L362 |
21,139 | uber/ringpop-go | hashring/hashring.go | Lookup | func (r *HashRing) Lookup(key string) (string, bool) {
strs := r.LookupN(key, 1)
if len(strs) == 0 {
return "", false
}
return strs[0], true
} | go | func (r *HashRing) Lookup(key string) (string, bool) {
strs := r.LookupN(key, 1)
if len(strs) == 0 {
return "", false
}
return strs[0], true
} | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"Lookup",
"(",
"key",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"strs",
":=",
"r",
".",
"LookupN",
"(",
"key",
",",
"1",
")",
"\n",
"if",
"len",
"(",
"strs",
")",
"==",
"0",
"{",
"return",
"\... | // Lookup returns the owner of the given key and whether the HashRing contains
// the key at all. | [
"Lookup",
"returns",
"the",
"owner",
"of",
"the",
"given",
"key",
"and",
"whether",
"the",
"HashRing",
"contains",
"the",
"key",
"at",
"all",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L366-L372 |
21,140 | uber/ringpop-go | hashring/hashring.go | LookupN | func (r *HashRing) LookupN(key string, n int) []string {
r.RLock()
servers := r.lookupNNoLock(key, n)
r.RUnlock()
return servers
} | go | func (r *HashRing) LookupN(key string, n int) []string {
r.RLock()
servers := r.lookupNNoLock(key, n)
r.RUnlock()
return servers
} | [
"func",
"(",
"r",
"*",
"HashRing",
")",
"LookupN",
"(",
"key",
"string",
",",
"n",
"int",
")",
"[",
"]",
"string",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"servers",
":=",
"r",
".",
"lookupNNoLock",
"(",
"key",
",",
"n",
")",
"\n",
"r",
".",
... | // LookupN returns the N servers that own the given key. Duplicates in the form
// of virtual nodes are skipped to maintain a list of unique servers. If there
// are less servers than N, we simply return all existing servers. | [
"LookupN",
"returns",
"the",
"N",
"servers",
"that",
"own",
"the",
"given",
"key",
".",
"Duplicates",
"in",
"the",
"form",
"of",
"virtual",
"nodes",
"are",
"skipped",
"to",
"maintain",
"a",
"list",
"of",
"unique",
"servers",
".",
"If",
"there",
"are",
"l... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/hashring/hashring.go#L377-L382 |
21,141 | uber/ringpop-go | options.go | applyOptions | func applyOptions(r *Ringpop, opts []Option) error {
for _, option := range opts {
err := option(r)
if err != nil {
return err
}
}
return nil
} | go | func applyOptions(r *Ringpop, opts []Option) error {
for _, option := range opts {
err := option(r)
if err != nil {
return err
}
}
return nil
} | [
"func",
"applyOptions",
"(",
"r",
"*",
"Ringpop",
",",
"opts",
"[",
"]",
"Option",
")",
"error",
"{",
"for",
"_",
",",
"option",
":=",
"range",
"opts",
"{",
"err",
":=",
"option",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err... | // applyOptions applies runtime configuration options to the specified Ringpop
// instance. | [
"applyOptions",
"applies",
"runtime",
"configuration",
"options",
"to",
"the",
"specified",
"Ringpop",
"instance",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L83-L91 |
21,142 | uber/ringpop-go | options.go | checkOptions | func checkOptions(rp *Ringpop) []error {
errs := []error{}
if rp.channel == nil {
errs = append(errs, errors.New("channel is required"))
}
if rp.addressResolver == nil {
errs = append(errs, errors.New("address resolver is nil"))
}
return errs
} | go | func checkOptions(rp *Ringpop) []error {
errs := []error{}
if rp.channel == nil {
errs = append(errs, errors.New("channel is required"))
}
if rp.addressResolver == nil {
errs = append(errs, errors.New("address resolver is nil"))
}
return errs
} | [
"func",
"checkOptions",
"(",
"rp",
"*",
"Ringpop",
")",
"[",
"]",
"error",
"{",
"errs",
":=",
"[",
"]",
"error",
"{",
"}",
"\n",
"if",
"rp",
".",
"channel",
"==",
"nil",
"{",
"errs",
"=",
"append",
"(",
"errs",
",",
"errors",
".",
"New",
"(",
"... | // checkOptions checks that the Ringpop instance has been properly configured
// with all the required options. | [
"checkOptions",
"checks",
"that",
"the",
"Ringpop",
"instance",
"has",
"been",
"properly",
"configured",
"with",
"all",
"the",
"required",
"options",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L95-L104 |
21,143 | uber/ringpop-go | options.go | Clock | func Clock(c clock.Clock) Option {
return func(r *Ringpop) error {
if c == nil {
return errors.New("clock is required")
}
r.clock = c
return nil
}
} | go | func Clock(c clock.Clock) Option {
return func(r *Ringpop) error {
if c == nil {
return errors.New("clock is required")
}
r.clock = c
return nil
}
} | [
"func",
"Clock",
"(",
"c",
"clock",
".",
"Clock",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"r",
".",
... | // Runtime options
// Clock is used to set the Clock mechanism. Testing harnesses will typically
// replace this with a mocked clock. | [
"Runtime",
"options",
"Clock",
"is",
"used",
"to",
"set",
"the",
"Clock",
"mechanism",
".",
"Testing",
"harnesses",
"will",
"typically",
"replace",
"this",
"with",
"a",
"mocked",
"clock",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L110-L118 |
21,144 | uber/ringpop-go | options.go | Logger | func Logger(l log.Logger) Option {
return func(r *Ringpop) error {
logging.SetLogger(l)
return nil
}
} | go | func Logger(l log.Logger) Option {
return func(r *Ringpop) error {
logging.SetLogger(l)
return nil
}
} | [
"func",
"Logger",
"(",
"l",
"log",
".",
"Logger",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"logging",
".",
"SetLogger",
"(",
"l",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Logger is used to specify a bark-compatible logger that will be used for
// all Ringpop logging. If a logger is not provided, one will be created
// automatically. | [
"Logger",
"is",
"used",
"to",
"specify",
"a",
"bark",
"-",
"compatible",
"logger",
"that",
"will",
"be",
"used",
"for",
"all",
"Ringpop",
"logging",
".",
"If",
"a",
"logger",
"is",
"not",
"provided",
"one",
"will",
"be",
"created",
"automatically",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L160-L165 |
21,145 | uber/ringpop-go | options.go | LogLevels | func LogLevels(levels map[string]logging.Level) Option {
return func(r *Ringpop) error {
return logging.SetLevels(levels)
}
} | go | func LogLevels(levels map[string]logging.Level) Option {
return func(r *Ringpop) error {
return logging.SetLevels(levels)
}
} | [
"func",
"LogLevels",
"(",
"levels",
"map",
"[",
"string",
"]",
"logging",
".",
"Level",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"return",
"logging",
".",
"SetLevels",
"(",
"levels",
")",
"\n",
"}",
"\n",
"}"... | // LogLevels is used to set the severity log level for all Ringpop named
// loggers. | [
"LogLevels",
"is",
"used",
"to",
"set",
"the",
"severity",
"log",
"level",
"for",
"all",
"Ringpop",
"named",
"loggers",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L169-L173 |
21,146 | uber/ringpop-go | options.go | SuspectPeriod | func SuspectPeriod(period time.Duration) Option {
return func(r *Ringpop) error {
r.config.StateTimeouts.Suspect = period
return nil
}
} | go | func SuspectPeriod(period time.Duration) Option {
return func(r *Ringpop) error {
r.config.StateTimeouts.Suspect = period
return nil
}
} | [
"func",
"SuspectPeriod",
"(",
"period",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"r",
".",
"config",
".",
"StateTimeouts",
".",
"Suspect",
"=",
"period",
"\n",
"return",
"nil",
"\n",
"}... | // SuspectPeriod configures the period it takes ringpop to declare a node faulty
// after ringpop has first detected the node to be unresponsive to a healthcheck.
// When a node is declared faulty it is removed from the consistent hashring and
// stops forwarding traffic to that node. All keys previously routed to that... | [
"SuspectPeriod",
"configures",
"the",
"period",
"it",
"takes",
"ringpop",
"to",
"declare",
"a",
"node",
"faulty",
"after",
"ringpop",
"has",
"first",
"detected",
"the",
"node",
"to",
"be",
"unresponsive",
"to",
"a",
"healthcheck",
".",
"When",
"a",
"node",
"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L283-L288 |
21,147 | uber/ringpop-go | options.go | FaultyPeriod | func FaultyPeriod(period time.Duration) Option {
return func(r *Ringpop) error {
r.config.StateTimeouts.Faulty = period
return nil
}
} | go | func FaultyPeriod(period time.Duration) Option {
return func(r *Ringpop) error {
r.config.StateTimeouts.Faulty = period
return nil
}
} | [
"func",
"FaultyPeriod",
"(",
"period",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"r",
".",
"config",
".",
"StateTimeouts",
".",
"Faulty",
"=",
"period",
"\n",
"return",
"nil",
"\n",
"}",... | // FaultyPeriod configures the period Ringpop keeps a faulty node in its memberlist.
// Even though the node will not receive any traffic it is still present in the
// list in case it will come back online later. After this timeout ringpop will
// remove the node from its membership list permanently. If a node happens ... | [
"FaultyPeriod",
"configures",
"the",
"period",
"Ringpop",
"keeps",
"a",
"faulty",
"node",
"in",
"its",
"memberlist",
".",
"Even",
"though",
"the",
"node",
"will",
"not",
"receive",
"any",
"traffic",
"it",
"is",
"still",
"present",
"in",
"the",
"list",
"in",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L298-L303 |
21,148 | uber/ringpop-go | options.go | TombstonePeriod | func TombstonePeriod(period time.Duration) Option {
return func(r *Ringpop) error {
r.config.StateTimeouts.Tombstone = period
return nil
}
} | go | func TombstonePeriod(period time.Duration) Option {
return func(r *Ringpop) error {
r.config.StateTimeouts.Tombstone = period
return nil
}
} | [
"func",
"TombstonePeriod",
"(",
"period",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"r",
".",
"config",
".",
"StateTimeouts",
".",
"Tombstone",
"=",
"period",
"\n",
"return",
"nil",
"\n",
... | // TombstonePeriod configures the period of the last time of the lifecycle in of
// a node in the membership list. This period should give the gossip protocol the
// time it needs to disseminate this change. If configured too short the node in
// question might show up again in faulty state in the distributed memberlis... | [
"TombstonePeriod",
"configures",
"the",
"period",
"of",
"the",
"last",
"time",
"of",
"the",
"lifecycle",
"in",
"of",
"a",
"node",
"in",
"the",
"membership",
"list",
".",
"This",
"period",
"should",
"give",
"the",
"gossip",
"protocol",
"the",
"time",
"it",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L310-L315 |
21,149 | uber/ringpop-go | options.go | LabelLimitCount | func LabelLimitCount(count int) Option {
return func(r *Ringpop) error {
r.config.LabelLimits.Count = count
return nil
}
} | go | func LabelLimitCount(count int) Option {
return func(r *Ringpop) error {
r.config.LabelLimits.Count = count
return nil
}
} | [
"func",
"LabelLimitCount",
"(",
"count",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"r",
".",
"config",
".",
"LabelLimits",
".",
"Count",
"=",
"count",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // LabelLimitCount limits the number of labels an application can set on this
// node. | [
"LabelLimitCount",
"limits",
"the",
"number",
"of",
"labels",
"an",
"application",
"can",
"set",
"on",
"this",
"node",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L319-L324 |
21,150 | uber/ringpop-go | options.go | LabelLimitKeySize | func LabelLimitKeySize(size int) Option {
return func(r *Ringpop) error {
r.config.LabelLimits.KeySize = size
return nil
}
} | go | func LabelLimitKeySize(size int) Option {
return func(r *Ringpop) error {
r.config.LabelLimits.KeySize = size
return nil
}
} | [
"func",
"LabelLimitKeySize",
"(",
"size",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"r",
".",
"config",
".",
"LabelLimits",
".",
"KeySize",
"=",
"size",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // LabelLimitKeySize limits the size that a key of a label can be. | [
"LabelLimitKeySize",
"limits",
"the",
"size",
"that",
"a",
"key",
"of",
"a",
"label",
"can",
"be",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L327-L332 |
21,151 | uber/ringpop-go | options.go | LabelLimitValueSize | func LabelLimitValueSize(size int) Option {
return func(r *Ringpop) error {
r.config.LabelLimits.ValueSize = size
return nil
}
} | go | func LabelLimitValueSize(size int) Option {
return func(r *Ringpop) error {
r.config.LabelLimits.ValueSize = size
return nil
}
} | [
"func",
"LabelLimitValueSize",
"(",
"size",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"r",
".",
"config",
".",
"LabelLimits",
".",
"ValueSize",
"=",
"size",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // LabelLimitValueSize limits the size that a value of a label can be. | [
"LabelLimitValueSize",
"limits",
"the",
"size",
"that",
"a",
"value",
"of",
"a",
"label",
"can",
"be",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L335-L340 |
21,152 | uber/ringpop-go | options.go | RequiresAppInPing | func RequiresAppInPing(requiresAppInPing bool) Option {
return func(r *Ringpop) error {
r.config.RequiresAppInPing = requiresAppInPing
return nil
}
} | go | func RequiresAppInPing(requiresAppInPing bool) Option {
return func(r *Ringpop) error {
r.config.RequiresAppInPing = requiresAppInPing
return nil
}
} | [
"func",
"RequiresAppInPing",
"(",
"requiresAppInPing",
"bool",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"r",
".",
"config",
".",
"RequiresAppInPing",
"=",
"requiresAppInPing",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
... | // RequiresAppInPing configures if ringpop node should reject pings
// that don't contain app name | [
"RequiresAppInPing",
"configures",
"if",
"ringpop",
"node",
"should",
"reject",
"pings",
"that",
"don",
"t",
"contain",
"app",
"name"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L364-L369 |
21,153 | uber/ringpop-go | options.go | defaultLogLevels | func defaultLogLevels(r *Ringpop) error {
return LogLevels(map[string]logging.Level{
"damping": logging.Error,
"dissemination": logging.Error,
"gossip": logging.Error,
"join": logging.Warn,
"membership": logging.Error,
"ring": logging.Error,
"suspicion": logging.Erro... | go | func defaultLogLevels(r *Ringpop) error {
return LogLevels(map[string]logging.Level{
"damping": logging.Error,
"dissemination": logging.Error,
"gossip": logging.Error,
"join": logging.Warn,
"membership": logging.Error,
"ring": logging.Error,
"suspicion": logging.Erro... | [
"func",
"defaultLogLevels",
"(",
"r",
"*",
"Ringpop",
")",
"error",
"{",
"return",
"LogLevels",
"(",
"map",
"[",
"string",
"]",
"logging",
".",
"Level",
"{",
"\"",
"\"",
":",
"logging",
".",
"Error",
",",
"\"",
"\"",
":",
"logging",
".",
"Error",
","... | // defaultLogLevels is the default configuration for all Ringpop named loggers. | [
"defaultLogLevels",
"is",
"the",
"default",
"configuration",
"for",
"all",
"Ringpop",
"named",
"loggers",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/options.go#L385-L395 |
21,154 | uber/ringpop-go | discovery/jsonfile/lib.go | Hosts | func (p *HostList) Hosts() ([]string, error) {
var hosts []string
data, err := ioutil.ReadFile(p.filePath)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &hosts)
if err != nil {
return nil, err
}
return hosts, nil
} | go | func (p *HostList) Hosts() ([]string, error) {
var hosts []string
data, err := ioutil.ReadFile(p.filePath)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &hosts)
if err != nil {
return nil, err
}
return hosts, nil
} | [
"func",
"(",
"p",
"*",
"HostList",
")",
"Hosts",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"hosts",
"[",
"]",
"string",
"\n\n",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"p",
".",
"filePath",
")",
"\n",
"... | // Hosts reads hosts from a JSON file. | [
"Hosts",
"reads",
"hosts",
"from",
"a",
"JSON",
"file",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/discovery/jsonfile/lib.go#L34-L48 |
21,155 | uber/ringpop-go | swim/handlers.go | notImplementedHandler | func notImplementedHandler(ctx json.Context, req *emptyArg) (*emptyArg, error) {
return nil, errors.New("handler not implemented")
} | go | func notImplementedHandler(ctx json.Context, req *emptyArg) (*emptyArg, error) {
return nil, errors.New("handler not implemented")
} | [
"func",
"notImplementedHandler",
"(",
"ctx",
"json",
".",
"Context",
",",
"req",
"*",
"emptyArg",
")",
"(",
"*",
"emptyArg",
",",
"error",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // notImplementedHandler is a dummy handler that returns an error explaining
// this method is not implemented. | [
"notImplementedHandler",
"is",
"a",
"dummy",
"handler",
"that",
"returns",
"an",
"error",
"explaining",
"this",
"method",
"is",
"not",
"implemented",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/handlers.go#L59-L61 |
21,156 | uber/ringpop-go | swim/handlers.go | reapFaultyMembersHandler | func (n *Node) reapFaultyMembersHandler(ctx json.Context, req *emptyArg) (*Status, error) {
members := n.memberlist.GetMembers()
for _, member := range members {
if member.Status == Faulty {
// declare all faulty members as tombstone
n.memberlist.MakeTombstone(member.Address, member.Incarnation)
}
}
retur... | go | func (n *Node) reapFaultyMembersHandler(ctx json.Context, req *emptyArg) (*Status, error) {
members := n.memberlist.GetMembers()
for _, member := range members {
if member.Status == Faulty {
// declare all faulty members as tombstone
n.memberlist.MakeTombstone(member.Address, member.Incarnation)
}
}
retur... | [
"func",
"(",
"n",
"*",
"Node",
")",
"reapFaultyMembersHandler",
"(",
"ctx",
"json",
".",
"Context",
",",
"req",
"*",
"emptyArg",
")",
"(",
"*",
"Status",
",",
"error",
")",
"{",
"members",
":=",
"n",
".",
"memberlist",
".",
"GetMembers",
"(",
")",
"\... | // reapFaultyMembersHandler iterates through the local members of this nodes and
// declares all the members marked as faulty as a tombstone. This will clean all
// these members from the membership in the complete cluster due to the gossipy
// nature of swim | [
"reapFaultyMembersHandler",
"iterates",
"through",
"the",
"local",
"members",
"of",
"this",
"nodes",
"and",
"declares",
"all",
"the",
"members",
"marked",
"as",
"faulty",
"as",
"a",
"tombstone",
".",
"This",
"will",
"clean",
"all",
"these",
"members",
"from",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/handlers.go#L154-L163 |
21,157 | uber/ringpop-go | swim/handlers.go | errorHandler | func (n *Node) errorHandler(ctx context.Context, err error) {
n.logger.WithField("error", err).Info("error occurred")
} | go | func (n *Node) errorHandler(ctx context.Context, err error) {
n.logger.WithField("error", err).Info("error occurred")
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"errorHandler",
"(",
"ctx",
"context",
".",
"Context",
",",
"err",
"error",
")",
"{",
"n",
".",
"logger",
".",
"WithField",
"(",
"\"",
"\"",
",",
"err",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // errorHandler is called when one of the handlers returns an error. | [
"errorHandler",
"is",
"called",
"when",
"one",
"of",
"the",
"handlers",
"returns",
"an",
"error",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/handlers.go#L166-L168 |
21,158 | uber/ringpop-go | logging/level.go | String | func (lvl Level) String() string {
switch lvl {
case Panic:
return "panic"
case Fatal:
return "fatal"
case Error:
return "error"
case Warn:
return "warn"
case Info:
return "info"
case Debug:
return "debug"
}
return strconv.Itoa(int(lvl))
} | go | func (lvl Level) String() string {
switch lvl {
case Panic:
return "panic"
case Fatal:
return "fatal"
case Error:
return "error"
case Warn:
return "warn"
case Info:
return "info"
case Debug:
return "debug"
}
return strconv.Itoa(int(lvl))
} | [
"func",
"(",
"lvl",
"Level",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"lvl",
"{",
"case",
"Panic",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Fatal",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Error",
":",
"return",
"\"",
"\"",
"\n",
"case",... | // String converts a log level to its string representation. | [
"String",
"converts",
"a",
"log",
"level",
"to",
"its",
"string",
"representation",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/level.go#L52-L68 |
21,159 | uber/ringpop-go | logging/level.go | Parse | func Parse(lvl string) (Level, error) {
switch lvl {
case "fatal":
return Fatal, nil
case "panic":
return Panic, nil
case "error":
return Error, nil
case "warn":
return Warn, nil
case "info":
return Info, nil
case "debug":
return Debug, nil
}
level, err := strconv.Atoi(lvl)
if level > maxLevel {
... | go | func Parse(lvl string) (Level, error) {
switch lvl {
case "fatal":
return Fatal, nil
case "panic":
return Panic, nil
case "error":
return Error, nil
case "warn":
return Warn, nil
case "info":
return Info, nil
case "debug":
return Debug, nil
}
level, err := strconv.Atoi(lvl)
if level > maxLevel {
... | [
"func",
"Parse",
"(",
"lvl",
"string",
")",
"(",
"Level",
",",
"error",
")",
"{",
"switch",
"lvl",
"{",
"case",
"\"",
"\"",
":",
"return",
"Fatal",
",",
"nil",
"\n",
"case",
"\"",
"\"",
":",
"return",
"Panic",
",",
"nil",
"\n",
"case",
"\"",
"\""... | // Parse converts a string to a log level. | [
"Parse",
"converts",
"a",
"string",
"to",
"a",
"log",
"level",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/level.go#L71-L92 |
21,160 | uber/ringpop-go | swim/join_sender.go | newJoinSender | func newJoinSender(node *Node, opts *joinOpts) (*joinSender, error) {
if opts == nil {
opts = &joinOpts{}
}
if node.discoverProvider == nil {
return nil, errors.New("no discover provider")
}
// Resolve/retrieve bootstrap hosts from the provider specified in the
// join options.
bootstrapHosts, err := node.... | go | func newJoinSender(node *Node, opts *joinOpts) (*joinSender, error) {
if opts == nil {
opts = &joinOpts{}
}
if node.discoverProvider == nil {
return nil, errors.New("no discover provider")
}
// Resolve/retrieve bootstrap hosts from the provider specified in the
// join options.
bootstrapHosts, err := node.... | [
"func",
"newJoinSender",
"(",
"node",
"*",
"Node",
",",
"opts",
"*",
"joinOpts",
")",
"(",
"*",
"joinSender",
",",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"joinOpts",
"{",
"}",
"\n",
"}",
"\n\n",
"if",
"node",
".",
"d... | // newJoinSender returns a new JoinSender to join a cluster with | [
"newJoinSender",
"returns",
"a",
"new",
"JoinSender",
"to",
"join",
"a",
"cluster",
"with"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L118-L168 |
21,161 | uber/ringpop-go | swim/join_sender.go | parseHosts | func (j *joinSender) parseHosts(hostports []string) {
// Parse bootstrap hosts into a map
j.bootstrapHostsMap = util.HostPortsByHost(hostports)
// Perform some sanity checks on the bootstrap hosts
err := util.CheckLocalMissing(j.node.address, j.bootstrapHostsMap[util.CaptureHost(j.node.address)])
if err != nil {
... | go | func (j *joinSender) parseHosts(hostports []string) {
// Parse bootstrap hosts into a map
j.bootstrapHostsMap = util.HostPortsByHost(hostports)
// Perform some sanity checks on the bootstrap hosts
err := util.CheckLocalMissing(j.node.address, j.bootstrapHostsMap[util.CaptureHost(j.node.address)])
if err != nil {
... | [
"func",
"(",
"j",
"*",
"joinSender",
")",
"parseHosts",
"(",
"hostports",
"[",
"]",
"string",
")",
"{",
"// Parse bootstrap hosts into a map",
"j",
".",
"bootstrapHostsMap",
"=",
"util",
".",
"HostPortsByHost",
"(",
"hostports",
")",
"\n\n",
"// Perform some sanit... | // parseHosts populates the bootstrap hosts map from the provided slice of
// hostports. | [
"parseHosts",
"populates",
"the",
"bootstrap",
"hosts",
"map",
"from",
"the",
"provided",
"slice",
"of",
"hostports",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L172-L186 |
21,162 | uber/ringpop-go | swim/join_sender.go | CollectPotentialNodes | func (j *joinSender) CollectPotentialNodes(nodesJoined []string) []string {
if nodesJoined == nil {
nodesJoined = make([]string, 0)
}
var potentialNodes []string
for _, hostports := range j.bootstrapHostsMap {
for _, hostport := range hostports {
if j.node.address != hostport && !util.StringInSlice(nodesJo... | go | func (j *joinSender) CollectPotentialNodes(nodesJoined []string) []string {
if nodesJoined == nil {
nodesJoined = make([]string, 0)
}
var potentialNodes []string
for _, hostports := range j.bootstrapHostsMap {
for _, hostport := range hostports {
if j.node.address != hostport && !util.StringInSlice(nodesJo... | [
"func",
"(",
"j",
"*",
"joinSender",
")",
"CollectPotentialNodes",
"(",
"nodesJoined",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"nodesJoined",
"==",
"nil",
"{",
"nodesJoined",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
... | // potential nodes are nodes that can be joined that are not the local node | [
"potential",
"nodes",
"are",
"nodes",
"that",
"can",
"be",
"joined",
"that",
"are",
"not",
"the",
"local",
"node"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L189-L205 |
21,163 | uber/ringpop-go | swim/join_sender.go | CollectPreferredNodes | func (j *joinSender) CollectPreferredNodes() []string {
var preferredNodes []string
for host, hostports := range j.bootstrapHostsMap {
if host != util.CaptureHost(j.node.address) {
preferredNodes = append(preferredNodes, hostports...)
}
}
return preferredNodes
} | go | func (j *joinSender) CollectPreferredNodes() []string {
var preferredNodes []string
for host, hostports := range j.bootstrapHostsMap {
if host != util.CaptureHost(j.node.address) {
preferredNodes = append(preferredNodes, hostports...)
}
}
return preferredNodes
} | [
"func",
"(",
"j",
"*",
"joinSender",
")",
"CollectPreferredNodes",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"preferredNodes",
"[",
"]",
"string",
"\n\n",
"for",
"host",
",",
"hostports",
":=",
"range",
"j",
".",
"bootstrapHostsMap",
"{",
"if",
"host",
"... | // preferred nodes are nodes that are not on the same host as the local node | [
"preferred",
"nodes",
"are",
"nodes",
"that",
"are",
"not",
"on",
"the",
"same",
"host",
"as",
"the",
"local",
"node"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L208-L218 |
21,164 | uber/ringpop-go | swim/join_sender.go | CollectNonPreferredNodes | func (j *joinSender) CollectNonPreferredNodes() []string {
if len(j.preferredNodes) == 0 {
return j.potentialNodes
}
var nonPreferredNodes []string
for _, host := range j.bootstrapHostsMap[util.CaptureHost(j.node.address)] {
if host != j.node.address {
nonPreferredNodes = append(nonPreferredNodes, host)
... | go | func (j *joinSender) CollectNonPreferredNodes() []string {
if len(j.preferredNodes) == 0 {
return j.potentialNodes
}
var nonPreferredNodes []string
for _, host := range j.bootstrapHostsMap[util.CaptureHost(j.node.address)] {
if host != j.node.address {
nonPreferredNodes = append(nonPreferredNodes, host)
... | [
"func",
"(",
"j",
"*",
"joinSender",
")",
"CollectNonPreferredNodes",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"j",
".",
"preferredNodes",
")",
"==",
"0",
"{",
"return",
"j",
".",
"potentialNodes",
"\n",
"}",
"\n\n",
"var",
"nonPreferredNodes... | // non-preferred nodes are everyone else | [
"non",
"-",
"preferred",
"nodes",
"are",
"everyone",
"else"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L221-L234 |
21,165 | uber/ringpop-go | swim/join_sender.go | SelectGroup | func (j *joinSender) SelectGroup(nodesJoined []string) []string {
var group []string
// if fully exhausted or first round, initialize this round's nodes
if len(j.roundPreferredNodes) == 0 && len(j.roundNonPreferredNodes) == 0 {
j.Init(nodesJoined)
}
numNodesLeft := j.size - len(nodesJoined)
cont := func() boo... | go | func (j *joinSender) SelectGroup(nodesJoined []string) []string {
var group []string
// if fully exhausted or first round, initialize this round's nodes
if len(j.roundPreferredNodes) == 0 && len(j.roundNonPreferredNodes) == 0 {
j.Init(nodesJoined)
}
numNodesLeft := j.size - len(nodesJoined)
cont := func() boo... | [
"func",
"(",
"j",
"*",
"joinSender",
")",
"SelectGroup",
"(",
"nodesJoined",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"var",
"group",
"[",
"]",
"string",
"\n",
"// if fully exhausted or first round, initialize this round's nodes",
"if",
"len",
"(",
"j",... | // selects a group of nodes | [
"selects",
"a",
"group",
"of",
"nodes"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L249-L280 |
21,166 | uber/ringpop-go | swim/join_sender.go | JoinGroup | func (j *joinSender) JoinGroup(nodesJoined []string) ([]string, []string) {
group := j.SelectGroup(nodesJoined)
var responses struct {
successes []string
failures []string
sync.Mutex
}
var numNodesLeft = j.size - len(nodesJoined)
var startTime = time.Now()
var wg sync.WaitGroup
j.numTries++
j.node.Em... | go | func (j *joinSender) JoinGroup(nodesJoined []string) ([]string, []string) {
group := j.SelectGroup(nodesJoined)
var responses struct {
successes []string
failures []string
sync.Mutex
}
var numNodesLeft = j.size - len(nodesJoined)
var startTime = time.Now()
var wg sync.WaitGroup
j.numTries++
j.node.Em... | [
"func",
"(",
"j",
"*",
"joinSender",
")",
"JoinGroup",
"(",
"nodesJoined",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"[",
"]",
"string",
")",
"{",
"group",
":=",
"j",
".",
"SelectGroup",
"(",
"nodesJoined",
")",
"\n\n",
"var",
"responses... | // JoinGroup collects a number of nodes to join and sends join requests to them.
// nodesJoined contains the nodes that are already joined. The method returns
// the nodes that are succesfully joined, and the nodes that failed respond. | [
"JoinGroup",
"collects",
"a",
"number",
"of",
"nodes",
"to",
"join",
"and",
"sends",
"join",
"requests",
"to",
"them",
".",
"nodesJoined",
"contains",
"the",
"nodes",
"that",
"are",
"already",
"joined",
".",
"The",
"method",
"returns",
"the",
"nodes",
"that"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L365-L436 |
21,167 | uber/ringpop-go | swim/join_sender.go | sendJoinRequest | func sendJoinRequest(node *Node, target string, timeout time.Duration) (*joinResponse, error) {
ctx, cancel := shared.NewTChannelContext(timeout)
defer cancel()
peer := node.channel.Peers().GetOrAdd(target)
req := joinRequest{
App: node.app,
Source: node.address,
Incarnation: node.Incarnation()... | go | func sendJoinRequest(node *Node, target string, timeout time.Duration) (*joinResponse, error) {
ctx, cancel := shared.NewTChannelContext(timeout)
defer cancel()
peer := node.channel.Peers().GetOrAdd(target)
req := joinRequest{
App: node.app,
Source: node.address,
Incarnation: node.Incarnation()... | [
"func",
"sendJoinRequest",
"(",
"node",
"*",
"Node",
",",
"target",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"joinResponse",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"shared",
".",
"NewTChannelContext",
"(",
"timeout",
... | // sendJoinRequest sends a join request to the specified target. | [
"sendJoinRequest",
"sends",
"a",
"join",
"request",
"to",
"the",
"specified",
"target",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L439-L478 |
21,168 | uber/ringpop-go | swim/join_sender.go | sendJoin | func sendJoin(node *Node, opts *joinOpts) ([]string, error) {
joiner, err := newJoinSender(node, opts)
if err != nil {
return nil, err
}
return joiner.JoinCluster()
} | go | func sendJoin(node *Node, opts *joinOpts) ([]string, error) {
joiner, err := newJoinSender(node, opts)
if err != nil {
return nil, err
}
return joiner.JoinCluster()
} | [
"func",
"sendJoin",
"(",
"node",
"*",
"Node",
",",
"opts",
"*",
"joinOpts",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"joiner",
",",
"err",
":=",
"newJoinSender",
"(",
"node",
",",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // SendJoin creates a new JoinSender and attempts to join the cluster defined by
// the nodes bootstrap hosts | [
"SendJoin",
"creates",
"a",
"new",
"JoinSender",
"and",
"attempts",
"to",
"join",
"the",
"cluster",
"defined",
"by",
"the",
"nodes",
"bootstrap",
"hosts"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/join_sender.go#L482-L488 |
21,169 | uber/ringpop-go | swim/node.go | NewNode | func NewNode(app, address string, channel shared.SubChannel, opts *Options) *Node {
// use defaults for options that are unspecified
opts = mergeDefaultOptions(opts)
node := &Node{
address: address,
app: app,
channel: channel,
logger: logging.Logger("node").WithField("local", address),
joinTimeout: ... | go | func NewNode(app, address string, channel shared.SubChannel, opts *Options) *Node {
// use defaults for options that are unspecified
opts = mergeDefaultOptions(opts)
node := &Node{
address: address,
app: app,
channel: channel,
logger: logging.Logger("node").WithField("local", address),
joinTimeout: ... | [
"func",
"NewNode",
"(",
"app",
",",
"address",
"string",
",",
"channel",
"shared",
".",
"SubChannel",
",",
"opts",
"*",
"Options",
")",
"*",
"Node",
"{",
"// use defaults for options that are unspecified",
"opts",
"=",
"mergeDefaultOptions",
"(",
"opts",
")",
"\... | // NewNode returns a new SWIM Node. | [
"NewNode",
"returns",
"a",
"new",
"SWIM",
"Node",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L231-L283 |
21,170 | uber/ringpop-go | swim/node.go | Incarnation | func (n *Node) Incarnation() int64 {
if n.memberlist != nil && n.memberlist.local != nil {
n.memberlist.members.RLock()
incarnation := n.memberlist.local.Incarnation
n.memberlist.members.RUnlock()
return incarnation
}
return -1
} | go | func (n *Node) Incarnation() int64 {
if n.memberlist != nil && n.memberlist.local != nil {
n.memberlist.members.RLock()
incarnation := n.memberlist.local.Incarnation
n.memberlist.members.RUnlock()
return incarnation
}
return -1
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Incarnation",
"(",
")",
"int64",
"{",
"if",
"n",
".",
"memberlist",
"!=",
"nil",
"&&",
"n",
".",
"memberlist",
".",
"local",
"!=",
"nil",
"{",
"n",
".",
"memberlist",
".",
"members",
".",
"RLock",
"(",
")",
"\... | // Incarnation returns the incarnation number of the Node. | [
"Incarnation",
"returns",
"the",
"incarnation",
"number",
"of",
"the",
"Node",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L301-L309 |
21,171 | uber/ringpop-go | swim/node.go | Start | func (n *Node) Start() {
n.gossip.Start()
n.stateTransitions.Enable()
n.healer.Start()
n.state.Lock()
n.state.stopped = false
n.state.Unlock()
} | go | func (n *Node) Start() {
n.gossip.Start()
n.stateTransitions.Enable()
n.healer.Start()
n.state.Lock()
n.state.stopped = false
n.state.Unlock()
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Start",
"(",
")",
"{",
"n",
".",
"gossip",
".",
"Start",
"(",
")",
"\n",
"n",
".",
"stateTransitions",
".",
"Enable",
"(",
")",
"\n",
"n",
".",
"healer",
".",
"Start",
"(",
")",
"\n\n",
"n",
".",
"state",
... | // Start starts the SWIM protocol and all sub-protocols. | [
"Start",
"starts",
"the",
"SWIM",
"protocol",
"and",
"all",
"sub",
"-",
"protocols",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L312-L320 |
21,172 | uber/ringpop-go | swim/node.go | Stop | func (n *Node) Stop() {
n.gossip.Stop()
n.stateTransitions.Disable()
n.healer.Stop()
n.state.Lock()
n.state.stopped = true
n.state.Unlock()
} | go | func (n *Node) Stop() {
n.gossip.Stop()
n.stateTransitions.Disable()
n.healer.Stop()
n.state.Lock()
n.state.stopped = true
n.state.Unlock()
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Stop",
"(",
")",
"{",
"n",
".",
"gossip",
".",
"Stop",
"(",
")",
"\n",
"n",
".",
"stateTransitions",
".",
"Disable",
"(",
")",
"\n",
"n",
".",
"healer",
".",
"Stop",
"(",
")",
"\n\n",
"n",
".",
"state",
".... | // Stop stops the SWIM protocol and all sub-protocols. | [
"Stop",
"stops",
"the",
"SWIM",
"protocol",
"and",
"all",
"sub",
"-",
"protocols",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L323-L331 |
21,173 | uber/ringpop-go | swim/node.go | Stopped | func (n *Node) Stopped() bool {
n.state.RLock()
stopped := n.state.stopped
n.state.RUnlock()
return stopped
} | go | func (n *Node) Stopped() bool {
n.state.RLock()
stopped := n.state.stopped
n.state.RUnlock()
return stopped
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Stopped",
"(",
")",
"bool",
"{",
"n",
".",
"state",
".",
"RLock",
"(",
")",
"\n",
"stopped",
":=",
"n",
".",
"state",
".",
"stopped",
"\n",
"n",
".",
"state",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"sto... | // Stopped returns whether or not the SWIM protocol is currently running. | [
"Stopped",
"returns",
"whether",
"or",
"not",
"the",
"SWIM",
"protocol",
"is",
"currently",
"running",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L334-L340 |
21,174 | uber/ringpop-go | swim/node.go | Destroy | func (n *Node) Destroy() {
n.state.Lock()
if n.state.destroyed {
n.state.Unlock()
return
}
n.state.destroyed = true
n.state.Unlock()
n.Stop()
} | go | func (n *Node) Destroy() {
n.state.Lock()
if n.state.destroyed {
n.state.Unlock()
return
}
n.state.destroyed = true
n.state.Unlock()
n.Stop()
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Destroy",
"(",
")",
"{",
"n",
".",
"state",
".",
"Lock",
"(",
")",
"\n",
"if",
"n",
".",
"state",
".",
"destroyed",
"{",
"n",
".",
"state",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n",
"n",
... | // Destroy stops the SWIM protocol and all sub-protocols. | [
"Destroy",
"stops",
"the",
"SWIM",
"protocol",
"and",
"all",
"sub",
"-",
"protocols",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L343-L353 |
21,175 | uber/ringpop-go | swim/node.go | Destroyed | func (n *Node) Destroyed() bool {
n.state.RLock()
destroyed := n.state.destroyed
n.state.RUnlock()
return destroyed
} | go | func (n *Node) Destroyed() bool {
n.state.RLock()
destroyed := n.state.destroyed
n.state.RUnlock()
return destroyed
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Destroyed",
"(",
")",
"bool",
"{",
"n",
".",
"state",
".",
"RLock",
"(",
")",
"\n",
"destroyed",
":=",
"n",
".",
"state",
".",
"destroyed",
"\n",
"n",
".",
"state",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
... | // Destroyed returns whether or not the node has been destroyed. | [
"Destroyed",
"returns",
"whether",
"or",
"not",
"the",
"node",
"has",
"been",
"destroyed",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L356-L362 |
21,176 | uber/ringpop-go | swim/node.go | Ready | func (n *Node) Ready() bool {
n.state.RLock()
ready := n.state.ready
n.state.RUnlock()
return ready
} | go | func (n *Node) Ready() bool {
n.state.RLock()
ready := n.state.ready
n.state.RUnlock()
return ready
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Ready",
"(",
")",
"bool",
"{",
"n",
".",
"state",
".",
"RLock",
"(",
")",
"\n",
"ready",
":=",
"n",
".",
"state",
".",
"ready",
"\n",
"n",
".",
"state",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"ready",
... | // Ready returns whether or not the node has bootstrapped and is ready for use. | [
"Ready",
"returns",
"whether",
"or",
"not",
"the",
"node",
"has",
"bootstrapped",
"and",
"is",
"ready",
"for",
"use",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L365-L371 |
21,177 | uber/ringpop-go | swim/node.go | RegisterSelfEvictHook | func (n *Node) RegisterSelfEvictHook(hooks SelfEvictHook) error {
return n.selfEvict.RegisterSelfEvictHook(hooks)
} | go | func (n *Node) RegisterSelfEvictHook(hooks SelfEvictHook) error {
return n.selfEvict.RegisterSelfEvictHook(hooks)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"RegisterSelfEvictHook",
"(",
"hooks",
"SelfEvictHook",
")",
"error",
"{",
"return",
"n",
".",
"selfEvict",
".",
"RegisterSelfEvictHook",
"(",
"hooks",
")",
"\n",
"}"
] | // RegisterSelfEvictHook registers systems that want to hook into the eviction
// sequence of the swim protocol. | [
"RegisterSelfEvictHook",
"registers",
"systems",
"that",
"want",
"to",
"hook",
"into",
"the",
"eviction",
"sequence",
"of",
"the",
"swim",
"protocol",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L375-L377 |
21,178 | uber/ringpop-go | swim/node.go | Bootstrap | func (n *Node) Bootstrap(opts *BootstrapOptions) ([]string, error) {
if n.channel == nil {
return nil, errors.New("channel required")
}
if opts == nil {
opts = &BootstrapOptions{}
}
n.discoverProvider = opts.DiscoverProvider
joinOpts := &joinOpts{
timeout: opts.JoinTimeout,
size: ... | go | func (n *Node) Bootstrap(opts *BootstrapOptions) ([]string, error) {
if n.channel == nil {
return nil, errors.New("channel required")
}
if opts == nil {
opts = &BootstrapOptions{}
}
n.discoverProvider = opts.DiscoverProvider
joinOpts := &joinOpts{
timeout: opts.JoinTimeout,
size: ... | [
"func",
"(",
"n",
"*",
"Node",
")",
"Bootstrap",
"(",
"opts",
"*",
"BootstrapOptions",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"n",
".",
"channel",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",... | // Bootstrap joins a node to a cluster. The channel provided to the node must be
// listening for the bootstrap to complete. | [
"Bootstrap",
"joins",
"a",
"node",
"to",
"a",
"cluster",
".",
"The",
"channel",
"provided",
"to",
"the",
"node",
"must",
"be",
"listening",
"for",
"the",
"bootstrap",
"to",
"complete",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L420-L457 |
21,179 | uber/ringpop-go | swim/node.go | handleChanges | func (n *Node) handleChanges(changes []Change) {
n.disseminator.AdjustMaxPropagations()
for _, change := range changes {
n.disseminator.RecordChange(change)
switch change.Status {
case Alive:
n.stateTransitions.Cancel(change)
case Suspect:
n.stateTransitions.ScheduleSuspectToFaulty(change)
case Fau... | go | func (n *Node) handleChanges(changes []Change) {
n.disseminator.AdjustMaxPropagations()
for _, change := range changes {
n.disseminator.RecordChange(change)
switch change.Status {
case Alive:
n.stateTransitions.Cancel(change)
case Suspect:
n.stateTransitions.ScheduleSuspectToFaulty(change)
case Fau... | [
"func",
"(",
"n",
"*",
"Node",
")",
"handleChanges",
"(",
"changes",
"[",
"]",
"Change",
")",
"{",
"n",
".",
"disseminator",
".",
"AdjustMaxPropagations",
"(",
")",
"\n",
"for",
"_",
",",
"change",
":=",
"range",
"changes",
"{",
"n",
".",
"disseminator... | //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
//
// Change Handling
//
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | [
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"Change",
"Handling",
"=",
"=",
"="... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L465-L488 |
21,180 | uber/ringpop-go | swim/node.go | pinging | func (n *Node) pinging() bool {
n.state.RLock()
pinging := n.state.pinging
n.state.RUnlock()
return pinging
} | go | func (n *Node) pinging() bool {
n.state.RLock()
pinging := n.state.pinging
n.state.RUnlock()
return pinging
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"pinging",
"(",
")",
"bool",
"{",
"n",
".",
"state",
".",
"RLock",
"(",
")",
"\n",
"pinging",
":=",
"n",
".",
"state",
".",
"pinging",
"\n",
"n",
".",
"state",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"pin... | //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
//
// Gossip
//
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | [
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"Gossip",
"=",
"=",
"=",
"=",
"="... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L496-L502 |
21,181 | uber/ringpop-go | swim/node.go | pingNextMember | func (n *Node) pingNextMember() {
member, ok := n.memberiter.Next()
if !ok {
n.logger.Warn("no pingable members")
return
}
if n.pinging() {
n.logger.Warn("node already pinging")
return
}
n.setPinging(true)
defer n.setPinging(false)
// send ping
res, err := sendPing(n, member.Address, n.pingTimeout)
... | go | func (n *Node) pingNextMember() {
member, ok := n.memberiter.Next()
if !ok {
n.logger.Warn("no pingable members")
return
}
if n.pinging() {
n.logger.Warn("node already pinging")
return
}
n.setPinging(true)
defer n.setPinging(false)
// send ping
res, err := sendPing(n, member.Address, n.pingTimeout)
... | [
"func",
"(",
"n",
"*",
"Node",
")",
"pingNextMember",
"(",
")",
"{",
"member",
",",
"ok",
":=",
"n",
".",
"memberiter",
".",
"Next",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"n",
".",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
... | // pingNextMember pings the next member in the memberlist | [
"pingNextMember",
"pings",
"the",
"next",
"member",
"in",
"the",
"memberlist"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L511-L554 |
21,182 | uber/ringpop-go | swim/node.go | GetReachableMembers | func (n *Node) GetReachableMembers(predicates ...MemberPredicate) []Member {
predicates = append(predicates, memberIsReachable)
return n.memberlist.GetMembers(predicates...)
} | go | func (n *Node) GetReachableMembers(predicates ...MemberPredicate) []Member {
predicates = append(predicates, memberIsReachable)
return n.memberlist.GetMembers(predicates...)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"GetReachableMembers",
"(",
"predicates",
"...",
"MemberPredicate",
")",
"[",
"]",
"Member",
"{",
"predicates",
"=",
"append",
"(",
"predicates",
",",
"memberIsReachable",
")",
"\n",
"return",
"n",
".",
"memberlist",
".",
... | // GetReachableMembers returns a slice of members containing only the reachable
// members that satisfies the predicates passed in. | [
"GetReachableMembers",
"returns",
"a",
"slice",
"of",
"members",
"containing",
"only",
"the",
"reachable",
"members",
"that",
"satisfies",
"the",
"predicates",
"passed",
"in",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L558-L561 |
21,183 | uber/ringpop-go | swim/node.go | CountReachableMembers | func (n *Node) CountReachableMembers(predicates ...MemberPredicate) int {
predicates = append(predicates, memberIsReachable)
return n.memberlist.CountMembers(predicates...)
} | go | func (n *Node) CountReachableMembers(predicates ...MemberPredicate) int {
predicates = append(predicates, memberIsReachable)
return n.memberlist.CountMembers(predicates...)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"CountReachableMembers",
"(",
"predicates",
"...",
"MemberPredicate",
")",
"int",
"{",
"predicates",
"=",
"append",
"(",
"predicates",
",",
"memberIsReachable",
")",
"\n",
"return",
"n",
".",
"memberlist",
".",
"CountMembers... | // CountReachableMembers returns the number of reachable members currently in
// this node's membership list that satisfies all predicates passed in. | [
"CountReachableMembers",
"returns",
"the",
"number",
"of",
"reachable",
"members",
"currently",
"in",
"this",
"node",
"s",
"membership",
"list",
"that",
"satisfies",
"all",
"predicates",
"passed",
"in",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L565-L568 |
21,184 | uber/ringpop-go | swim/node.go | SetIdentity | func (n *Node) SetIdentity(identity string) error {
return n.memberlist.SetLocalLabel(membership.IdentityLabelKey, identity)
} | go | func (n *Node) SetIdentity(identity string) error {
return n.memberlist.SetLocalLabel(membership.IdentityLabelKey, identity)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"SetIdentity",
"(",
"identity",
"string",
")",
"error",
"{",
"return",
"n",
".",
"memberlist",
".",
"SetLocalLabel",
"(",
"membership",
".",
"IdentityLabelKey",
",",
"identity",
")",
"\n",
"}"
] | // SetIdentity changes the identity of the local node. This will change the
// state of the local node and will be gossiped around in the network. | [
"SetIdentity",
"changes",
"the",
"identity",
"of",
"the",
"local",
"node",
".",
"This",
"will",
"change",
"the",
"state",
"of",
"the",
"local",
"node",
"and",
"will",
"be",
"gossiped",
"around",
"in",
"the",
"network",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L579-L581 |
21,185 | uber/ringpop-go | events/events.go | AddListener | func (a *sharedEventEmitter) AddListener(l EventListener) bool {
if l == nil {
// do not register nil listener, will cause nil pointer dereference during
// event emitting
return false
}
a.listenersLock.Lock()
defer a.listenersLock.Unlock()
// Check if listener is already registered
for _, listener := ran... | go | func (a *sharedEventEmitter) AddListener(l EventListener) bool {
if l == nil {
// do not register nil listener, will cause nil pointer dereference during
// event emitting
return false
}
a.listenersLock.Lock()
defer a.listenersLock.Unlock()
// Check if listener is already registered
for _, listener := ran... | [
"func",
"(",
"a",
"*",
"sharedEventEmitter",
")",
"AddListener",
"(",
"l",
"EventListener",
")",
"bool",
"{",
"if",
"l",
"==",
"nil",
"{",
"// do not register nil listener, will cause nil pointer dereference during",
"// event emitting",
"return",
"false",
"\n",
"}",
... | // AddListener adds a listener to the EventEmitter. Events emitted on this
// emitter will be invoked on the listener. The return value indicates if the
// listener has been added or not. It can't be added if it is already added and
// therefore registered to receive events | [
"AddListener",
"adds",
"a",
"listener",
"to",
"the",
"EventEmitter",
".",
"Events",
"emitted",
"on",
"this",
"emitter",
"will",
"be",
"invoked",
"on",
"the",
"listener",
".",
"The",
"return",
"value",
"indicates",
"if",
"the",
"listener",
"has",
"been",
"add... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/events/events.go#L70-L98 |
21,186 | uber/ringpop-go | events/events.go | RemoveListener | func (a *sharedEventEmitter) RemoveListener(l EventListener) bool {
a.listenersLock.Lock()
defer a.listenersLock.Unlock()
for i := range a.listeners {
if a.listeners[i] == l {
// create a new list excluding the listener that needs removal
listenersCopy := make([]EventListener, 0, len(a.listeners)-1)
list... | go | func (a *sharedEventEmitter) RemoveListener(l EventListener) bool {
a.listenersLock.Lock()
defer a.listenersLock.Unlock()
for i := range a.listeners {
if a.listeners[i] == l {
// create a new list excluding the listener that needs removal
listenersCopy := make([]EventListener, 0, len(a.listeners)-1)
list... | [
"func",
"(",
"a",
"*",
"sharedEventEmitter",
")",
"RemoveListener",
"(",
"l",
"EventListener",
")",
"bool",
"{",
"a",
".",
"listenersLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"listenersLock",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"i",
":... | // RemoveListener removes a listener from the EventEmitter. Subsequent calls to
// EmitEvent will not cause HandleEvent to be called on this listener. The
// return value indicates if a listener has been removed or not. The listener
// can't be removed if it was not present before. | [
"RemoveListener",
"removes",
"a",
"listener",
"from",
"the",
"EventEmitter",
".",
"Subsequent",
"calls",
"to",
"EmitEvent",
"will",
"not",
"cause",
"HandleEvent",
"to",
"be",
"called",
"on",
"this",
"listener",
".",
"The",
"return",
"value",
"indicates",
"if",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/events/events.go#L104-L121 |
21,187 | uber/ringpop-go | events/events.go | EmitEvent | func (a *AsyncEventEmitter) EmitEvent(event Event) {
a.listenersLock.RLock()
for _, listener := range a.listeners {
go listener.HandleEvent(event)
}
a.listenersLock.RUnlock()
} | go | func (a *AsyncEventEmitter) EmitEvent(event Event) {
a.listenersLock.RLock()
for _, listener := range a.listeners {
go listener.HandleEvent(event)
}
a.listenersLock.RUnlock()
} | [
"func",
"(",
"a",
"*",
"AsyncEventEmitter",
")",
"EmitEvent",
"(",
"event",
"Event",
")",
"{",
"a",
".",
"listenersLock",
".",
"RLock",
"(",
")",
"\n",
"for",
"_",
",",
"listener",
":=",
"range",
"a",
".",
"listeners",
"{",
"go",
"listener",
".",
"Ha... | // EmitEvent will send the event to all registered listeners | [
"EmitEvent",
"will",
"send",
"the",
"event",
"to",
"all",
"registered",
"listeners"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/events/events.go#L130-L136 |
21,188 | uber/ringpop-go | swim/memberlist_iter.go | newMemberlistIter | func newMemberlistIter(m *memberlist) *memberlistIter {
iter := &memberlistIter{
m: m,
currentIndex: -1,
currentRound: 0,
}
iter.m.Shuffle()
return iter
} | go | func newMemberlistIter(m *memberlist) *memberlistIter {
iter := &memberlistIter{
m: m,
currentIndex: -1,
currentRound: 0,
}
iter.m.Shuffle()
return iter
} | [
"func",
"newMemberlistIter",
"(",
"m",
"*",
"memberlist",
")",
"*",
"memberlistIter",
"{",
"iter",
":=",
"&",
"memberlistIter",
"{",
"m",
":",
"m",
",",
"currentIndex",
":",
"-",
"1",
",",
"currentRound",
":",
"0",
",",
"}",
"\n\n",
"iter",
".",
"m",
... | // NewMemberlistIter returns a new MemberlistIter | [
"NewMemberlistIter",
"returns",
"a",
"new",
"MemberlistIter"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist_iter.go#L36-L46 |
21,189 | uber/ringpop-go | swim/memberlist_iter.go | Next | func (i *memberlistIter) Next() (*Member, bool) {
maxToVisit := i.m.NumMembers()
visited := make(map[string]bool)
for len(visited) < maxToVisit {
i.currentIndex++
if i.currentIndex >= i.m.NumMembers() {
i.currentIndex = 0
i.currentRound++
i.m.Shuffle()
}
member := i.m.MemberAt(i.currentIndex)
v... | go | func (i *memberlistIter) Next() (*Member, bool) {
maxToVisit := i.m.NumMembers()
visited := make(map[string]bool)
for len(visited) < maxToVisit {
i.currentIndex++
if i.currentIndex >= i.m.NumMembers() {
i.currentIndex = 0
i.currentRound++
i.m.Shuffle()
}
member := i.m.MemberAt(i.currentIndex)
v... | [
"func",
"(",
"i",
"*",
"memberlistIter",
")",
"Next",
"(",
")",
"(",
"*",
"Member",
",",
"bool",
")",
"{",
"maxToVisit",
":=",
"i",
".",
"m",
".",
"NumMembers",
"(",
")",
"\n",
"visited",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",... | // Next returns the next pingable member in the member list, if it
// visits all members but none are pingable returns nil, false | [
"Next",
"returns",
"the",
"next",
"pingable",
"member",
"in",
"the",
"member",
"list",
"if",
"it",
"visits",
"all",
"members",
"but",
"none",
"are",
"pingable",
"returns",
"nil",
"false"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist_iter.go#L50-L72 |
21,190 | beanstalkd/go-beanstalk | conn.go | Dial | func Dial(network, addr string) (*Conn, error) {
return DialTimeout(network, addr, DefaultDialTimeout)
} | go | func Dial(network, addr string) (*Conn, error) {
return DialTimeout(network, addr, DefaultDialTimeout)
} | [
"func",
"Dial",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"return",
"DialTimeout",
"(",
"network",
",",
"addr",
",",
"DefaultDialTimeout",
")",
"\n",
"}"
] | // Dial connects addr on the given network using net.DialTimeout
// with a default timeout of 10s and then returns a new Conn for the connection. | [
"Dial",
"connects",
"addr",
"on",
"the",
"given",
"network",
"using",
"net",
".",
"DialTimeout",
"with",
"a",
"default",
"timeout",
"of",
"10s",
"and",
"then",
"returns",
"a",
"new",
"Conn",
"for",
"the",
"connection",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L52-L54 |
21,191 | beanstalkd/go-beanstalk | conn.go | DialTimeout | func DialTimeout(network, addr string, timeout time.Duration) (*Conn, error) {
dialer := &net.Dialer{
Timeout: timeout,
KeepAlive: DefaultKeepAlivePeriod,
}
c, err := dialer.Dial(network, addr)
if err != nil {
return nil, err
}
return NewConn(c), nil
} | go | func DialTimeout(network, addr string, timeout time.Duration) (*Conn, error) {
dialer := &net.Dialer{
Timeout: timeout,
KeepAlive: DefaultKeepAlivePeriod,
}
c, err := dialer.Dial(network, addr)
if err != nil {
return nil, err
}
return NewConn(c), nil
} | [
"func",
"DialTimeout",
"(",
"network",
",",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"dialer",
":=",
"&",
"net",
".",
"Dialer",
"{",
"Timeout",
":",
"timeout",
",",
"KeepAlive",
":",
"D... | // DialTimeout connects addr on the given network using net.DialTimeout
// with a supplied timeout and then returns a new Conn for the connection. | [
"DialTimeout",
"connects",
"addr",
"on",
"the",
"given",
"network",
"using",
"net",
".",
"DialTimeout",
"with",
"a",
"supplied",
"timeout",
"and",
"then",
"returns",
"a",
"new",
"Conn",
"for",
"the",
"connection",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L58-L68 |
21,192 | beanstalkd/go-beanstalk | conn.go | printLine | func (c *Conn) printLine(cmd string, args ...interface{}) {
io.WriteString(c.c.W, cmd)
for _, a := range args {
c.c.W.Write(space)
fmt.Fprint(c.c.W, a)
}
c.c.W.Write(crnl)
} | go | func (c *Conn) printLine(cmd string, args ...interface{}) {
io.WriteString(c.c.W, cmd)
for _, a := range args {
c.c.W.Write(space)
fmt.Fprint(c.c.W, a)
}
c.c.W.Write(crnl)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"printLine",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"io",
".",
"WriteString",
"(",
"c",
".",
"c",
".",
"W",
",",
"cmd",
")",
"\n",
"for",
"_",
",",
"a",
":=",
"range",
"a... | // does not flush | [
"does",
"not",
"flush"
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L129-L136 |
21,193 | beanstalkd/go-beanstalk | conn.go | Delete | func (c *Conn) Delete(id uint64) error {
r, err := c.cmd(nil, nil, nil, "delete", id)
if err != nil {
return err
}
_, err = c.readResp(r, false, "DELETED")
return err
} | go | func (c *Conn) Delete(id uint64) error {
r, err := c.cmd(nil, nil, nil, "delete", id)
if err != nil {
return err
}
_, err = c.readResp(r, false, "DELETED")
return err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Delete",
"(",
"id",
"uint64",
")",
"error",
"{",
"r",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"nil",
",",
"nil",
",",
"nil",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return"... | // Delete deletes the given job. | [
"Delete",
"deletes",
"the",
"given",
"job",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L171-L178 |
21,194 | beanstalkd/go-beanstalk | conn.go | Bury | func (c *Conn) Bury(id uint64, pri uint32) error {
r, err := c.cmd(nil, nil, nil, "bury", id, pri)
if err != nil {
return err
}
_, err = c.readResp(r, false, "BURIED")
return err
} | go | func (c *Conn) Bury(id uint64, pri uint32) error {
r, err := c.cmd(nil, nil, nil, "bury", id, pri)
if err != nil {
return err
}
_, err = c.readResp(r, false, "BURIED")
return err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Bury",
"(",
"id",
"uint64",
",",
"pri",
"uint32",
")",
"error",
"{",
"r",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"nil",
",",
"nil",
",",
"nil",
",",
"\"",
"\"",
",",
"id",
",",
"pri",
")",
"\n",
"if",
... | // Bury places the given job in a holding area in the job's tube and
// sets its priority to pri. The job will not be scheduled again until it
// has been kicked; see also the documentation of Kick. | [
"Bury",
"places",
"the",
"given",
"job",
"in",
"a",
"holding",
"area",
"in",
"the",
"job",
"s",
"tube",
"and",
"sets",
"its",
"priority",
"to",
"pri",
".",
"The",
"job",
"will",
"not",
"be",
"scheduled",
"again",
"until",
"it",
"has",
"been",
"kicked",... | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L196-L203 |
21,195 | beanstalkd/go-beanstalk | conn.go | Peek | func (c *Conn) Peek(id uint64) (body []byte, err error) {
r, err := c.cmd(nil, nil, nil, "peek", id)
if err != nil {
return nil, err
}
return c.readResp(r, true, "FOUND %d", &id)
} | go | func (c *Conn) Peek(id uint64) (body []byte, err error) {
r, err := c.cmd(nil, nil, nil, "peek", id)
if err != nil {
return nil, err
}
return c.readResp(r, true, "FOUND %d", &id)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Peek",
"(",
"id",
"uint64",
")",
"(",
"body",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"nil",
",",
"nil",
",",
"nil",
",",
"\"",
"\"",
",",
"id",
")... | // Peek gets a copy of the specified job from the server. | [
"Peek",
"gets",
"a",
"copy",
"of",
"the",
"specified",
"job",
"from",
"the",
"server",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L229-L235 |
21,196 | beanstalkd/go-beanstalk | conn.go | Stats | func (c *Conn) Stats() (map[string]string, error) {
r, err := c.cmd(nil, nil, nil, "stats")
if err != nil {
return nil, err
}
body, err := c.readResp(r, true, "OK")
return parseDict(body), err
} | go | func (c *Conn) Stats() (map[string]string, error) {
r, err := c.cmd(nil, nil, nil, "stats")
if err != nil {
return nil, err
}
body, err := c.readResp(r, true, "OK")
return parseDict(body), err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Stats",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"nil",
",",
"nil",
",",
"nil",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
... | // Stats retrieves global statistics from the server. | [
"Stats",
"retrieves",
"global",
"statistics",
"from",
"the",
"server",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L238-L245 |
21,197 | beanstalkd/go-beanstalk | conn.go | StatsJob | func (c *Conn) StatsJob(id uint64) (map[string]string, error) {
r, err := c.cmd(nil, nil, nil, "stats-job", id)
if err != nil {
return nil, err
}
body, err := c.readResp(r, true, "OK")
return parseDict(body), err
} | go | func (c *Conn) StatsJob(id uint64) (map[string]string, error) {
r, err := c.cmd(nil, nil, nil, "stats-job", id)
if err != nil {
return nil, err
}
body, err := c.readResp(r, true, "OK")
return parseDict(body), err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"StatsJob",
"(",
"id",
"uint64",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"nil",
",",
"nil",
",",
"nil",
",",
"\"",
"\"",
",",
"i... | // StatsJob retrieves statistics about the given job. | [
"StatsJob",
"retrieves",
"statistics",
"about",
"the",
"given",
"job",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L248-L255 |
21,198 | beanstalkd/go-beanstalk | conn.go | ListTubes | func (c *Conn) ListTubes() ([]string, error) {
r, err := c.cmd(nil, nil, nil, "list-tubes")
if err != nil {
return nil, err
}
body, err := c.readResp(r, true, "OK")
return parseList(body), err
} | go | func (c *Conn) ListTubes() ([]string, error) {
r, err := c.cmd(nil, nil, nil, "list-tubes")
if err != nil {
return nil, err
}
body, err := c.readResp(r, true, "OK")
return parseList(body), err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ListTubes",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"nil",
",",
"nil",
",",
"nil",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // ListTubes returns the names of the tubes that currently
// exist on the server. | [
"ListTubes",
"returns",
"the",
"names",
"of",
"the",
"tubes",
"that",
"currently",
"exist",
"on",
"the",
"server",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L259-L266 |
21,199 | beanstalkd/go-beanstalk | tubeset.go | NewTubeSet | func NewTubeSet(c *Conn, name ...string) *TubeSet {
ts := &TubeSet{c, make(map[string]bool)}
for _, s := range name {
ts.Name[s] = true
}
return ts
} | go | func NewTubeSet(c *Conn, name ...string) *TubeSet {
ts := &TubeSet{c, make(map[string]bool)}
for _, s := range name {
ts.Name[s] = true
}
return ts
} | [
"func",
"NewTubeSet",
"(",
"c",
"*",
"Conn",
",",
"name",
"...",
"string",
")",
"*",
"TubeSet",
"{",
"ts",
":=",
"&",
"TubeSet",
"{",
"c",
",",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"}",
"\n",
"for",
"_",
",",
"s",
":=",
"range",... | // NewTubeSet returns a new TubeSet representing the given names. | [
"NewTubeSet",
"returns",
"a",
"new",
"TubeSet",
"representing",
"the",
"given",
"names",
"."
] | 7a112881e6c4f85f0d98f8929536e775d31fb4de | https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tubeset.go#L15-L21 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.