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,000 | uber/ringpop-go | swim/gossip.go | Stopped | func (g *gossip) Stopped() bool {
g.state.RLock()
stopped := !g.state.running
g.state.RUnlock()
return stopped
} | go | func (g *gossip) Stopped() bool {
g.state.RLock()
stopped := !g.state.running
g.state.RUnlock()
return stopped
} | [
"func",
"(",
"g",
"*",
"gossip",
")",
"Stopped",
"(",
")",
"bool",
"{",
"g",
".",
"state",
".",
"RLock",
"(",
")",
"\n",
"stopped",
":=",
"!",
"g",
".",
"state",
".",
"running",
"\n",
"g",
".",
"state",
".",
"RUnlock",
"(",
")",
"\n\n",
"return... | // returns whether or not the gossip sub-protocol is stopped | [
"returns",
"whether",
"or",
"not",
"the",
"gossip",
"sub",
"-",
"protocol",
"is",
"stopped"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/gossip.go#L165-L171 |
21,001 | uber/ringpop-go | swim/gossip.go | ProtocolPeriod | func (g *gossip) ProtocolPeriod() {
startTime := time.Now()
g.node.pingNextMember()
endTime := time.Now()
g.protocol.Lock()
lag := endTime.Sub(g.protocol.lastPeriod)
wasFirst := (g.protocol.numPeriods == 0)
g.protocol.lastPeriod = endTime
g.protocol.numPeriods++
g.protocol.timing.Update(int64(time.Now().Su... | go | func (g *gossip) ProtocolPeriod() {
startTime := time.Now()
g.node.pingNextMember()
endTime := time.Now()
g.protocol.Lock()
lag := endTime.Sub(g.protocol.lastPeriod)
wasFirst := (g.protocol.numPeriods == 0)
g.protocol.lastPeriod = endTime
g.protocol.numPeriods++
g.protocol.timing.Update(int64(time.Now().Su... | [
"func",
"(",
"g",
"*",
"gossip",
")",
"ProtocolPeriod",
"(",
")",
"{",
"startTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"g",
".",
"node",
".",
"pingNextMember",
"(",
")",
"\n",
"endTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"g",
"... | // run a gossip protocol period | [
"run",
"a",
"gossip",
"protocol",
"period"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/gossip.go#L174-L195 |
21,002 | uber/ringpop-go | logging/facility.go | NewFacility | func NewFacility(log bark.Logger) *Facility {
if log == nil {
log = NoLogger
}
return &Facility{
logger: log,
levels: make(map[string]Level),
}
} | go | func NewFacility(log bark.Logger) *Facility {
if log == nil {
log = NoLogger
}
return &Facility{
logger: log,
levels: make(map[string]Level),
}
} | [
"func",
"NewFacility",
"(",
"log",
"bark",
".",
"Logger",
")",
"*",
"Facility",
"{",
"if",
"log",
"==",
"nil",
"{",
"log",
"=",
"NoLogger",
"\n",
"}",
"\n",
"return",
"&",
"Facility",
"{",
"logger",
":",
"log",
",",
"levels",
":",
"make",
"(",
"map... | // NewFacility creates a new log facility with the specified logger as the
// underlying logger. If no logger is passed, a no-op implementation is used. | [
"NewFacility",
"creates",
"a",
"new",
"log",
"facility",
"with",
"the",
"specified",
"logger",
"as",
"the",
"underlying",
"logger",
".",
"If",
"no",
"logger",
"is",
"passed",
"a",
"no",
"-",
"op",
"implementation",
"is",
"used",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/facility.go#L41-L49 |
21,003 | uber/ringpop-go | logging/facility.go | SetLevels | func (f *Facility) SetLevels(levels map[string]Level) error {
for logName, level := range levels {
if level < Fatal {
return fmt.Errorf("cannot set a level above %s for %s", Fatal, logName)
}
}
// Prevent changing levels while a message is logged.
f.mu.Lock()
defer f.mu.Unlock()
for logName, level := range... | go | func (f *Facility) SetLevels(levels map[string]Level) error {
for logName, level := range levels {
if level < Fatal {
return fmt.Errorf("cannot set a level above %s for %s", Fatal, logName)
}
}
// Prevent changing levels while a message is logged.
f.mu.Lock()
defer f.mu.Unlock()
for logName, level := range... | [
"func",
"(",
"f",
"*",
"Facility",
")",
"SetLevels",
"(",
"levels",
"map",
"[",
"string",
"]",
"Level",
")",
"error",
"{",
"for",
"logName",
",",
"level",
":=",
"range",
"levels",
"{",
"if",
"level",
"<",
"Fatal",
"{",
"return",
"fmt",
".",
"Errorf",... | // SetLevels is like SetLevel but for multiple named loggers. | [
"SetLevels",
"is",
"like",
"SetLevel",
"but",
"for",
"multiple",
"named",
"loggers",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/facility.go#L52-L65 |
21,004 | uber/ringpop-go | logging/facility.go | SetLogger | func (f *Facility) SetLogger(log bark.Logger) {
// Prevent changing the logger while a message is logged.
f.mu.Lock()
defer f.mu.Unlock()
if log == nil {
log = NoLogger
}
f.logger = log
} | go | func (f *Facility) SetLogger(log bark.Logger) {
// Prevent changing the logger while a message is logged.
f.mu.Lock()
defer f.mu.Unlock()
if log == nil {
log = NoLogger
}
f.logger = log
} | [
"func",
"(",
"f",
"*",
"Facility",
")",
"SetLogger",
"(",
"log",
"bark",
".",
"Logger",
")",
"{",
"// Prevent changing the logger while a message is logged.",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
... | // SetLogger sets the underlying logger. All log messages produced, that are
// not silenced, are propagated to this logger. | [
"SetLogger",
"sets",
"the",
"underlying",
"logger",
".",
"All",
"log",
"messages",
"produced",
"that",
"are",
"not",
"silenced",
"are",
"propagated",
"to",
"this",
"logger",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/facility.go#L87-L95 |
21,005 | uber/ringpop-go | logging/facility.go | Logger | func (f *Facility) Logger(logName string) bark.Logger {
return &namedLogger{
name: logName,
forwardTo: f,
}
} | go | func (f *Facility) Logger(logName string) bark.Logger {
return &namedLogger{
name: logName,
forwardTo: f,
}
} | [
"func",
"(",
"f",
"*",
"Facility",
")",
"Logger",
"(",
"logName",
"string",
")",
"bark",
".",
"Logger",
"{",
"return",
"&",
"namedLogger",
"{",
"name",
":",
"logName",
",",
"forwardTo",
":",
"f",
",",
"}",
"\n\n",
"}"
] | // Logger returns a new named logger. | [
"Logger",
"returns",
"a",
"new",
"named",
"logger",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/facility.go#L98-L104 |
21,006 | uber/ringpop-go | logging/facility.go | Log | func (f *Facility) Log(logName string, wantLevel Level, fields bark.Fields, msg []interface{}) {
f.mu.RLock()
defer f.mu.RUnlock()
if setLevel, ok := f.levels[logName]; ok {
// For me this is confusing, so here's a clarification.
// The levels are consecutive integers starting from 0 defined in this order:
// ... | go | func (f *Facility) Log(logName string, wantLevel Level, fields bark.Fields, msg []interface{}) {
f.mu.RLock()
defer f.mu.RUnlock()
if setLevel, ok := f.levels[logName]; ok {
// For me this is confusing, so here's a clarification.
// The levels are consecutive integers starting from 0 defined in this order:
// ... | [
"func",
"(",
"f",
"*",
"Facility",
")",
"Log",
"(",
"logName",
"string",
",",
"wantLevel",
"Level",
",",
"fields",
"bark",
".",
"Fields",
",",
"msg",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer"... | // Log logs messages with a severity level equal to or higher than the one set
// with SetLevel. If that's not the case, the message is silenced.
// If the logName was not previously configured with SetLevel, the messages are
// never silenced.
// Instead on using this method directly, one can call Logger method to get... | [
"Log",
"logs",
"messages",
"with",
"a",
"severity",
"level",
"equal",
"to",
"or",
"higher",
"than",
"the",
"one",
"set",
"with",
"SetLevel",
".",
"If",
"that",
"s",
"not",
"the",
"case",
"the",
"message",
"is",
"silenced",
".",
"If",
"the",
"logName",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/facility.go#L112-L144 |
21,007 | uber/ringpop-go | logging/facility.go | Logf | func (f *Facility) Logf(logName string, wantLevel Level, fields bark.Fields, format string, msg []interface{}) {
f.mu.RLock()
defer f.mu.RUnlock()
if setLevel, ok := f.levels[logName]; ok {
if setLevel < wantLevel {
return
}
}
logger := f.logger
if len(fields) > 0 {
logger = logger.WithFields(fields)
}
... | go | func (f *Facility) Logf(logName string, wantLevel Level, fields bark.Fields, format string, msg []interface{}) {
f.mu.RLock()
defer f.mu.RUnlock()
if setLevel, ok := f.levels[logName]; ok {
if setLevel < wantLevel {
return
}
}
logger := f.logger
if len(fields) > 0 {
logger = logger.WithFields(fields)
}
... | [
"func",
"(",
"f",
"*",
"Facility",
")",
"Logf",
"(",
"logName",
"string",
",",
"wantLevel",
"Level",
",",
"fields",
"bark",
".",
"Fields",
",",
"format",
"string",
",",
"msg",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"f",
".",
"mu",
".",
"RLock",... | // Logf is the same as Log but with fmt.Printf-like formatting | [
"Logf",
"is",
"the",
"same",
"as",
"Log",
"but",
"with",
"fmt",
".",
"Printf",
"-",
"like",
"formatting"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/logging/facility.go#L147-L173 |
21,008 | uber/ringpop-go | swim/member_predicate.go | MemberMatchesPredicates | func MemberMatchesPredicates(member Member, predicates ...MemberPredicate) bool {
for _, p := range predicates {
if !p(member) {
return false
}
}
return true
} | go | func MemberMatchesPredicates(member Member, predicates ...MemberPredicate) bool {
for _, p := range predicates {
if !p(member) {
return false
}
}
return true
} | [
"func",
"MemberMatchesPredicates",
"(",
"member",
"Member",
",",
"predicates",
"...",
"MemberPredicate",
")",
"bool",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"predicates",
"{",
"if",
"!",
"p",
"(",
"member",
")",
"{",
"return",
"false",
"\n",
"}",
"\n"... | // MemberMatchesPredicates can take multiple predicates and test them against a
// member returning if the member satisfies all the predicates. This means that
// if one test fails it will stop executing and return with false. | [
"MemberMatchesPredicates",
"can",
"take",
"multiple",
"predicates",
"and",
"test",
"them",
"against",
"a",
"member",
"returning",
"if",
"the",
"member",
"satisfies",
"all",
"the",
"predicates",
".",
"This",
"means",
"that",
"if",
"one",
"test",
"fails",
"it",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member_predicate.go#L12-L19 |
21,009 | uber/ringpop-go | swim/member_predicate.go | MemberWithLabelAndValue | func MemberWithLabelAndValue(key, value string) MemberPredicate {
return func(member Member) bool {
v, ok := member.Labels[key]
if !ok {
return false
}
// test if the values match
return v == value
}
} | go | func MemberWithLabelAndValue(key, value string) MemberPredicate {
return func(member Member) bool {
v, ok := member.Labels[key]
if !ok {
return false
}
// test if the values match
return v == value
}
} | [
"func",
"MemberWithLabelAndValue",
"(",
"key",
",",
"value",
"string",
")",
"MemberPredicate",
"{",
"return",
"func",
"(",
"member",
"Member",
")",
"bool",
"{",
"v",
",",
"ok",
":=",
"member",
".",
"Labels",
"[",
"key",
"]",
"\n\n",
"if",
"!",
"ok",
"{... | // MemberWithLabelAndValue returns a predicate able to test if the value of a
// label on a member is equal to the provided value. | [
"MemberWithLabelAndValue",
"returns",
"a",
"predicate",
"able",
"to",
"test",
"if",
"the",
"value",
"of",
"a",
"label",
"on",
"a",
"member",
"is",
"equal",
"to",
"the",
"provided",
"value",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member_predicate.go#L32-L43 |
21,010 | uber/ringpop-go | shared/shared.go | NewTChannelContext | func NewTChannelContext(timeout time.Duration) (tchannel.ContextWithHeaders, context.CancelFunc) {
return tchannel.NewContextBuilder(timeout).
DisableTracing().
SetRetryOptions(retryOptions).
Build()
} | go | func NewTChannelContext(timeout time.Duration) (tchannel.ContextWithHeaders, context.CancelFunc) {
return tchannel.NewContextBuilder(timeout).
DisableTracing().
SetRetryOptions(retryOptions).
Build()
} | [
"func",
"NewTChannelContext",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"tchannel",
".",
"ContextWithHeaders",
",",
"context",
".",
"CancelFunc",
")",
"{",
"return",
"tchannel",
".",
"NewContextBuilder",
"(",
"timeout",
")",
".",
"DisableTracing",
"(",
... | // NewTChannelContext creates a new TChannel context with default options
// suitable for use in Ringpop. | [
"NewTChannelContext",
"creates",
"a",
"new",
"TChannel",
"context",
"with",
"default",
"options",
"suitable",
"for",
"use",
"in",
"Ringpop",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/shared/shared.go#L17-L22 |
21,011 | uber/ringpop-go | swim/disseminator.go | newDisseminator | func newDisseminator(n *Node) *disseminator {
d := &disseminator{
node: n,
changes: make(map[string]*pChange),
maxP: defaultPFactor,
pFactor: defaultPFactor,
logger: logging.Logger("disseminator").WithField("local", n.Address()),
reverseFul... | go | func newDisseminator(n *Node) *disseminator {
d := &disseminator{
node: n,
changes: make(map[string]*pChange),
maxP: defaultPFactor,
pFactor: defaultPFactor,
logger: logging.Logger("disseminator").WithField("local", n.Address()),
reverseFul... | [
"func",
"newDisseminator",
"(",
"n",
"*",
"Node",
")",
"*",
"disseminator",
"{",
"d",
":=",
"&",
"disseminator",
"{",
"node",
":",
"n",
",",
"changes",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"pChange",
")",
",",
"maxP",
":",
"defaultPFacto... | // newDisseminator returns a new Disseminator instance. | [
"newDisseminator",
"returns",
"a",
"new",
"Disseminator",
"instance",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/disseminator.go#L62-L73 |
21,012 | uber/ringpop-go | swim/disseminator.go | HasChanges | func (d *disseminator) HasChanges() bool {
d.RLock()
result := len(d.changes) > 0
d.RUnlock()
return result
} | go | func (d *disseminator) HasChanges() bool {
d.RLock()
result := len(d.changes) > 0
d.RUnlock()
return result
} | [
"func",
"(",
"d",
"*",
"disseminator",
")",
"HasChanges",
"(",
")",
"bool",
"{",
"d",
".",
"RLock",
"(",
")",
"\n",
"result",
":=",
"len",
"(",
"d",
".",
"changes",
")",
">",
"0",
"\n",
"d",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"result",
"... | // HasChanges reports whether disseminator has changes to disseminate. | [
"HasChanges",
"reports",
"whether",
"disseminator",
"has",
"changes",
"to",
"disseminate",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/disseminator.go#L100-L105 |
21,013 | uber/ringpop-go | swim/disseminator.go | IssueAsSender | func (d *disseminator) IssueAsSender() (changes []Change, bumpPiggybackCounters func()) {
changes = d.issueChanges()
return changes, func() {
d.bumpPiggybackCounters(changes)
}
} | go | func (d *disseminator) IssueAsSender() (changes []Change, bumpPiggybackCounters func()) {
changes = d.issueChanges()
return changes, func() {
d.bumpPiggybackCounters(changes)
}
} | [
"func",
"(",
"d",
"*",
"disseminator",
")",
"IssueAsSender",
"(",
")",
"(",
"changes",
"[",
"]",
"Change",
",",
"bumpPiggybackCounters",
"func",
"(",
")",
")",
"{",
"changes",
"=",
"d",
".",
"issueChanges",
"(",
")",
"\n",
"return",
"changes",
",",
"fu... | // IssueAsSender collects all changes a node needs when sending a ping or
// ping-req. The second return value is a callback that raises the piggyback
// counters of the given changes. | [
"IssueAsSender",
"collects",
"all",
"changes",
"a",
"node",
"needs",
"when",
"sending",
"a",
"ping",
"or",
"ping",
"-",
"req",
".",
"The",
"second",
"return",
"value",
"is",
"a",
"callback",
"that",
"raises",
"the",
"piggyback",
"counters",
"of",
"the",
"g... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/disseminator.go#L127-L132 |
21,014 | uber/ringpop-go | swim/disseminator.go | IssueAsReceiver | func (d *disseminator) IssueAsReceiver(
senderAddress string,
senderIncarnation int64,
senderChecksum uint32) (changes []Change, fullSync bool) {
changes = d.issueChanges()
// filter out changes that came from the sender previously
changes = d.filterChangesFromSender(changes, senderAddress, senderIncarnation)
... | go | func (d *disseminator) IssueAsReceiver(
senderAddress string,
senderIncarnation int64,
senderChecksum uint32) (changes []Change, fullSync bool) {
changes = d.issueChanges()
// filter out changes that came from the sender previously
changes = d.filterChangesFromSender(changes, senderAddress, senderIncarnation)
... | [
"func",
"(",
"d",
"*",
"disseminator",
")",
"IssueAsReceiver",
"(",
"senderAddress",
"string",
",",
"senderIncarnation",
"int64",
",",
"senderChecksum",
"uint32",
")",
"(",
"changes",
"[",
"]",
"Change",
",",
"fullSync",
"bool",
")",
"{",
"changes",
"=",
"d"... | // IssueAsReceiver collects all changes a node needs when responding to a ping
// or ping-req. Unlike IssueAsSender, IssueAsReceiver automatically increments
// the piggyback counters because it's difficult to find out whether a response
// reaches the client. The second return value indicates whether a full sync
// is... | [
"IssueAsReceiver",
"collects",
"all",
"changes",
"a",
"node",
"needs",
"when",
"responding",
"to",
"a",
"ping",
"or",
"ping",
"-",
"req",
".",
"Unlike",
"IssueAsSender",
"IssueAsReceiver",
"automatically",
"increments",
"the",
"piggyback",
"counters",
"because",
"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/disseminator.go#L155-L180 |
21,015 | uber/ringpop-go | swim/disseminator.go | filterChangesFromSender | func (d *disseminator) filterChangesFromSender(cs []Change, source string, incarnation int64) []Change {
for i := 0; i < len(cs); i++ {
if incarnation == cs[i].SourceIncarnation && source == cs[i].Source {
d.node.EmitEvent(ChangeFilteredEvent{cs[i]})
// swap, and not just overwrite, so that in the end only th... | go | func (d *disseminator) filterChangesFromSender(cs []Change, source string, incarnation int64) []Change {
for i := 0; i < len(cs); i++ {
if incarnation == cs[i].SourceIncarnation && source == cs[i].Source {
d.node.EmitEvent(ChangeFilteredEvent{cs[i]})
// swap, and not just overwrite, so that in the end only th... | [
"func",
"(",
"d",
"*",
"disseminator",
")",
"filterChangesFromSender",
"(",
"cs",
"[",
"]",
"Change",
",",
"source",
"string",
",",
"incarnation",
"int64",
")",
"[",
"]",
"Change",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"cs",
")",
"... | // filterChangesFromSender returns changes that didn't originate at the sender.
// Attention, this function reorders the underlaying input array. | [
"filterChangesFromSender",
"returns",
"changes",
"that",
"didn",
"t",
"originate",
"at",
"the",
"sender",
".",
"Attention",
"this",
"function",
"reorders",
"the",
"underlaying",
"input",
"array",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/disseminator.go#L184-L198 |
21,016 | uber/ringpop-go | swim/disseminator.go | tryStartReverseFullSync | func (d *disseminator) tryStartReverseFullSync(target string, timeout time.Duration) {
// occupy a job, return if none are available
select {
case d.reverseFullSyncJobs <- struct{}{}:
// continue if job is available
default:
d.logger.WithFields(log.Fields{
"remote": target,
}).Info("omit bidirectional full... | go | func (d *disseminator) tryStartReverseFullSync(target string, timeout time.Duration) {
// occupy a job, return if none are available
select {
case d.reverseFullSyncJobs <- struct{}{}:
// continue if job is available
default:
d.logger.WithFields(log.Fields{
"remote": target,
}).Info("omit bidirectional full... | [
"func",
"(",
"d",
"*",
"disseminator",
")",
"tryStartReverseFullSync",
"(",
"target",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"{",
"// occupy a job, return if none are available",
"select",
"{",
"case",
"d",
".",
"reverseFullSyncJobs",
"<-",
"struct"... | // tryStartReverseFullSync fires a goroutine that performs a full sync. We omit
// the reverse full sync if the maximum number of processes are already
// running. This ensures no more than reverseFullSyncJobs processes are
// running concurrently. | [
"tryStartReverseFullSync",
"fires",
"a",
"goroutine",
"that",
"performs",
"a",
"full",
"sync",
".",
"We",
"omit",
"the",
"reverse",
"full",
"sync",
"if",
"the",
"maximum",
"number",
"of",
"processes",
"are",
"already",
"running",
".",
"This",
"ensures",
"no",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/disseminator.go#L256-L277 |
21,017 | uber/ringpop-go | swim/disseminator.go | reverseFullSync | func (d *disseminator) reverseFullSync(target string, timeout time.Duration) {
d.node.EmitEvent(StartReverseFullSyncEvent{Target: target})
res, err := sendJoinRequest(d.node, target, timeout)
if err != nil || res == nil {
d.logger.WithFields(log.Fields{
"remote": target,
"error": err,
}).Warn("bidirectio... | go | func (d *disseminator) reverseFullSync(target string, timeout time.Duration) {
d.node.EmitEvent(StartReverseFullSyncEvent{Target: target})
res, err := sendJoinRequest(d.node, target, timeout)
if err != nil || res == nil {
d.logger.WithFields(log.Fields{
"remote": target,
"error": err,
}).Warn("bidirectio... | [
"func",
"(",
"d",
"*",
"disseminator",
")",
"reverseFullSync",
"(",
"target",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"{",
"d",
".",
"node",
".",
"EmitEvent",
"(",
"StartReverseFullSyncEvent",
"{",
"Target",
":",
"target",
"}",
")",
"\n\n",... | // reverseFullSync is the second part of a bidirectional full sync. The first
// part is performed by the IssueAsReceiver method. The reverse full sync
// ensures that this node merges the membership of the target node's membership
// with its own. | [
"reverseFullSync",
"is",
"the",
"second",
"part",
"of",
"a",
"bidirectional",
"full",
"sync",
".",
"The",
"first",
"part",
"is",
"performed",
"by",
"the",
"IssueAsReceiver",
"method",
".",
"The",
"reverse",
"full",
"sync",
"ensures",
"that",
"this",
"node",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/disseminator.go#L283-L303 |
21,018 | uber/ringpop-go | examples/ping-json/main.go | Bytes | func (p Ping) Bytes() []byte {
data, _ := json2.Marshal(p)
return data
} | go | func (p Ping) Bytes() []byte {
data, _ := json2.Marshal(p)
return data
} | [
"func",
"(",
"p",
"Ping",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"data",
",",
"_",
":=",
"json2",
".",
"Marshal",
"(",
"p",
")",
"\n",
"return",
"data",
"\n",
"}"
] | // Bytes returns the byets for a ping | [
"Bytes",
"returns",
"the",
"byets",
"for",
"a",
"ping"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/examples/ping-json/main.go#L55-L58 |
21,019 | uber/ringpop-go | swim/member.go | Label | func (m Member) Label(key string) (value string, has bool) {
value, has = m.Labels[key]
return
} | go | func (m Member) Label(key string) (value string, has bool) {
value, has = m.Labels[key]
return
} | [
"func",
"(",
"m",
"Member",
")",
"Label",
"(",
"key",
"string",
")",
"(",
"value",
"string",
",",
"has",
"bool",
")",
"{",
"value",
",",
"has",
"=",
"m",
".",
"Labels",
"[",
"key",
"]",
"\n",
"return",
"\n",
"}"
] | // Label returns the value of a label named by key. The `has` boolean indicates
// if the label was set on the member or not | [
"Label",
"returns",
"the",
"value",
"of",
"a",
"label",
"named",
"by",
"key",
".",
"The",
"has",
"boolean",
"indicates",
"if",
"the",
"label",
"was",
"set",
"on",
"the",
"member",
"or",
"not"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L80-L83 |
21,020 | uber/ringpop-go | swim/member.go | Identity | func (m Member) Identity() string {
// Read the identity from the labels
identity, set := m.Label(membership.IdentityLabelKey)
if set {
return identity
}
// return the member's address if there is no identity set
return m.Address
} | go | func (m Member) Identity() string {
// Read the identity from the labels
identity, set := m.Label(membership.IdentityLabelKey)
if set {
return identity
}
// return the member's address if there is no identity set
return m.Address
} | [
"func",
"(",
"m",
"Member",
")",
"Identity",
"(",
")",
"string",
"{",
"// Read the identity from the labels",
"identity",
",",
"set",
":=",
"m",
".",
"Label",
"(",
"membership",
".",
"IdentityLabelKey",
")",
"\n",
"if",
"set",
"{",
"return",
"identity",
"\n"... | // Identity returns the identity of a member. If a specific identity is not set
// for the member the address will be used as the identity | [
"Identity",
"returns",
"the",
"identity",
"of",
"a",
"member",
".",
"If",
"a",
"specific",
"identity",
"is",
"not",
"set",
"for",
"the",
"member",
"the",
"address",
"will",
"be",
"used",
"as",
"the",
"identity"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L87-L96 |
21,021 | uber/ringpop-go | swim/member.go | checksumString | func (m Member) checksumString(b *bytes.Buffer) {
b.WriteString(m.Address)
b.WriteString(m.Status)
b.WriteString(strconv.FormatInt(m.Incarnation, 10))
m.Labels.checksumString(b)
} | go | func (m Member) checksumString(b *bytes.Buffer) {
b.WriteString(m.Address)
b.WriteString(m.Status)
b.WriteString(strconv.FormatInt(m.Incarnation, 10))
m.Labels.checksumString(b)
} | [
"func",
"(",
"m",
"Member",
")",
"checksumString",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"b",
".",
"WriteString",
"(",
"m",
".",
"Address",
")",
"\n",
"b",
".",
"WriteString",
"(",
"m",
".",
"Status",
")",
"\n",
"b",
".",
"WriteString",
... | // checksumString fills a buffer that is passed with the contents that this node
// needs to add to the checksum string. | [
"checksumString",
"fills",
"a",
"buffer",
"that",
"is",
"passed",
"with",
"the",
"contents",
"that",
"this",
"node",
"needs",
"to",
"add",
"to",
"the",
"checksum",
"string",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L116-L121 |
21,022 | uber/ringpop-go | swim/member.go | copy | func (l LabelMap) copy() (result LabelMap) {
result = make(map[string]string, len(l))
for key, value := range l {
result[key] = value
}
return
} | go | func (l LabelMap) copy() (result LabelMap) {
result = make(map[string]string, len(l))
for key, value := range l {
result[key] = value
}
return
} | [
"func",
"(",
"l",
"LabelMap",
")",
"copy",
"(",
")",
"(",
"result",
"LabelMap",
")",
"{",
"result",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"l",
")",
")",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"l",
"{"... | // copy creates a non-nil version of the LabelMap that copies all existing
// entries of the map. This can be used to create a new version of the labels
// that can be mutated before putting it on a Member to make updates without
// mutating the map that was already on a Member | [
"copy",
"creates",
"a",
"non",
"-",
"nil",
"version",
"of",
"the",
"LabelMap",
"that",
"copies",
"all",
"existing",
"entries",
"of",
"the",
"map",
".",
"This",
"can",
"be",
"used",
"to",
"create",
"a",
"new",
"version",
"of",
"the",
"labels",
"that",
"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L127-L133 |
21,023 | uber/ringpop-go | swim/member.go | checksumString | func (l LabelMap) checksumString(b *bytes.Buffer) {
checksum := l.checksum()
if checksum == 0 {
// we don't write the checksum of the labels if the value of the checksum
// is 0 (zero) to be backwards compatible with ringpop applications on
// an older version. This only works if the newer version does not use... | go | func (l LabelMap) checksumString(b *bytes.Buffer) {
checksum := l.checksum()
if checksum == 0 {
// we don't write the checksum of the labels if the value of the checksum
// is 0 (zero) to be backwards compatible with ringpop applications on
// an older version. This only works if the newer version does not use... | [
"func",
"(",
"l",
"LabelMap",
")",
"checksumString",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"checksum",
":=",
"l",
".",
"checksum",
"(",
")",
"\n\n",
"if",
"checksum",
"==",
"0",
"{",
"// we don't write the checksum of the labels if the value of the ch... | // checksumString adds the label portion of the checksum to the buffer that is
// passed in. The string will not be appended in the case where labels are not
// set on this member. This is for backwards compatibility reasons with older
// versions. | [
"checksumString",
"adds",
"the",
"label",
"portion",
"of",
"the",
"checksum",
"to",
"the",
"buffer",
"that",
"is",
"passed",
"in",
".",
"The",
"string",
"will",
"not",
"be",
"appended",
"in",
"the",
"case",
"where",
"labels",
"are",
"not",
"set",
"on",
"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L139-L154 |
21,024 | uber/ringpop-go | swim/member.go | shuffle | func shuffle(members []*Member) []*Member {
newMembers := make([]*Member, len(members), cap(members))
newIndexes := rand.Perm(len(members))
for o, n := range newIndexes {
newMembers[n] = members[o]
}
return newMembers
} | go | func shuffle(members []*Member) []*Member {
newMembers := make([]*Member, len(members), cap(members))
newIndexes := rand.Perm(len(members))
for o, n := range newIndexes {
newMembers[n] = members[o]
}
return newMembers
} | [
"func",
"shuffle",
"(",
"members",
"[",
"]",
"*",
"Member",
")",
"[",
"]",
"*",
"Member",
"{",
"newMembers",
":=",
"make",
"(",
"[",
"]",
"*",
"Member",
",",
"len",
"(",
"members",
")",
",",
"cap",
"(",
"members",
")",
")",
"\n",
"newIndexes",
":... | // shuffles slice of members pseudo-randomly, returns new slice | [
"shuffles",
"slice",
"of",
"members",
"pseudo",
"-",
"randomly",
"returns",
"new",
"slice"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L200-L209 |
21,025 | uber/ringpop-go | swim/member.go | validateIncoming | func (c Change) validateIncoming() Change {
if c.Status == Faulty && c.Tombstone {
c.Status = Tombstone
}
return c
} | go | func (c Change) validateIncoming() Change {
if c.Status == Faulty && c.Tombstone {
c.Status = Tombstone
}
return c
} | [
"func",
"(",
"c",
"Change",
")",
"validateIncoming",
"(",
")",
"Change",
"{",
"if",
"c",
".",
"Status",
"==",
"Faulty",
"&&",
"c",
".",
"Tombstone",
"{",
"c",
".",
"Status",
"=",
"Tombstone",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] | // validateIncoming validates incoming changes before they are passed into the
// swim state machine. This is usefull to make late adjustments to incoming
// changes to transform some legacy wire protocol changes into new swim terminology | [
"validateIncoming",
"validates",
"incoming",
"changes",
"before",
"they",
"are",
"passed",
"into",
"the",
"swim",
"state",
"machine",
".",
"This",
"is",
"usefull",
"to",
"make",
"late",
"adjustments",
"to",
"incoming",
"changes",
"to",
"transform",
"some",
"lega... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L315-L320 |
21,026 | uber/ringpop-go | swim/member.go | validateOutgoing | func (c Change) validateOutgoing() Change {
if c.Status == Tombstone {
c.Status = Faulty
c.Tombstone = true
}
return c
} | go | func (c Change) validateOutgoing() Change {
if c.Status == Tombstone {
c.Status = Faulty
c.Tombstone = true
}
return c
} | [
"func",
"(",
"c",
"Change",
")",
"validateOutgoing",
"(",
")",
"Change",
"{",
"if",
"c",
".",
"Status",
"==",
"Tombstone",
"{",
"c",
".",
"Status",
"=",
"Faulty",
"\n",
"c",
".",
"Tombstone",
"=",
"true",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] | // validateOutgoing validates outgoing changes before they are passed to the module
// responsible for sending the change to the other side. This can be used to make sure
// that our changes are parsable by older version of ringpop-go to prevent unwanted
// behavior when incompatible changes are sent to older versions. | [
"validateOutgoing",
"validates",
"outgoing",
"changes",
"before",
"they",
"are",
"passed",
"to",
"the",
"module",
"responsible",
"for",
"sending",
"the",
"change",
"to",
"the",
"other",
"side",
".",
"This",
"can",
"be",
"used",
"to",
"make",
"sure",
"that",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/member.go#L326-L332 |
21,027 | uber/ringpop-go | ringpop.go | New | func New(app string, opts ...Option) (*Ringpop, error) {
var err error
ringpop := &Ringpop{
config: &configuration{
App: app,
InitialLabels: make(swim.LabelMap),
},
logger: logging.Logger("ringpop"),
}
err = applyOptions(ringpop, defaultOptions)
if err != nil {
panic(fmt.Errorf("Error app... | go | func New(app string, opts ...Option) (*Ringpop, error) {
var err error
ringpop := &Ringpop{
config: &configuration{
App: app,
InitialLabels: make(swim.LabelMap),
},
logger: logging.Logger("ringpop"),
}
err = applyOptions(ringpop, defaultOptions)
if err != nil {
panic(fmt.Errorf("Error app... | [
"func",
"New",
"(",
"app",
"string",
",",
"opts",
"...",
"Option",
")",
"(",
"*",
"Ringpop",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"ringpop",
":=",
"&",
"Ringpop",
"{",
"config",
":",
"&",
"configuration",
"{",
"App",
":",
"app",
"... | // New returns a new Ringpop instance. | [
"New",
"returns",
"a",
"new",
"Ringpop",
"instance",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L142-L171 |
21,028 | uber/ringpop-go | ringpop.go | init | func (rp *Ringpop) init() error {
if rp.channel == nil {
return errors.New("Missing channel")
}
address, err := rp.address()
if err != nil {
return err
}
// early initialization of statter before registering listeners that might
// fire and try to stat
rp.stats.hostport = genStatsHostport(address)
rp.sta... | go | func (rp *Ringpop) init() error {
if rp.channel == nil {
return errors.New("Missing channel")
}
address, err := rp.address()
if err != nil {
return err
}
// early initialization of statter before registering listeners that might
// fire and try to stat
rp.stats.hostport = genStatsHostport(address)
rp.sta... | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"init",
"(",
")",
"error",
"{",
"if",
"rp",
".",
"channel",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"address",
",",
"err",
":=",
"rp",
".",
"address",
"(... | // init configures a Ringpop instance and makes it ready to do comms. | [
"init",
"configures",
"a",
"Ringpop",
"instance",
"and",
"makes",
"it",
"ready",
"to",
"do",
"comms",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L174-L218 |
21,029 | uber/ringpop-go | ringpop.go | startTimers | func (rp *Ringpop) startTimers() {
if rp.tickers != nil {
return
}
rp.tickers = make(chan *clock.Ticker, 32) // 32 == max number of tickers
if rp.config.MembershipChecksumStatPeriod != StatPeriodNever {
ticker := rp.clock.Ticker(rp.config.MembershipChecksumStatPeriod)
rp.tickers <- ticker
go func() {
fo... | go | func (rp *Ringpop) startTimers() {
if rp.tickers != nil {
return
}
rp.tickers = make(chan *clock.Ticker, 32) // 32 == max number of tickers
if rp.config.MembershipChecksumStatPeriod != StatPeriodNever {
ticker := rp.clock.Ticker(rp.config.MembershipChecksumStatPeriod)
rp.tickers <- ticker
go func() {
fo... | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"startTimers",
"(",
")",
"{",
"if",
"rp",
".",
"tickers",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"rp",
".",
"tickers",
"=",
"make",
"(",
"chan",
"*",
"clock",
".",
"Ticker",
",",
"32",
")",
"// 32 == ... | // Starts periodic timers in a single goroutine. Can be turned back off via
// stopTimers. | [
"Starts",
"periodic",
"timers",
"in",
"a",
"single",
"goroutine",
".",
"Can",
"be",
"turned",
"back",
"off",
"via",
"stopTimers",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L222-L264 |
21,030 | uber/ringpop-go | ringpop.go | channelAddressResolver | func (rp *Ringpop) channelAddressResolver() (string, error) {
peerInfo := rp.channel.PeerInfo()
// Check that TChannel is listening on a real hostport. By default,
// TChannel listens on an ephemeral host/port. The real port is then
// assigned by the OS when ListenAndServe is called. If the hostport is
// ephemer... | go | func (rp *Ringpop) channelAddressResolver() (string, error) {
peerInfo := rp.channel.PeerInfo()
// Check that TChannel is listening on a real hostport. By default,
// TChannel listens on an ephemeral host/port. The real port is then
// assigned by the OS when ListenAndServe is called. If the hostport is
// ephemer... | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"channelAddressResolver",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"peerInfo",
":=",
"rp",
".",
"channel",
".",
"PeerInfo",
"(",
")",
"\n",
"// Check that TChannel is listening on a real hostport. By default,",
"// T... | // r.channelAddressResolver resolves the hostport from the current
// TChannel object on the Ringpop instance. | [
"r",
".",
"channelAddressResolver",
"resolves",
"the",
"hostport",
"from",
"the",
"current",
"TChannel",
"object",
"on",
"the",
"Ringpop",
"instance",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L284-L295 |
21,031 | uber/ringpop-go | ringpop.go | Destroy | func (rp *Ringpop) Destroy() {
if rp.node != nil {
rp.node.Destroy()
}
rp.stopTimers()
rp.setState(destroyed)
} | go | func (rp *Ringpop) Destroy() {
if rp.node != nil {
rp.node.Destroy()
}
rp.stopTimers()
rp.setState(destroyed)
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"Destroy",
"(",
")",
"{",
"if",
"rp",
".",
"node",
"!=",
"nil",
"{",
"rp",
".",
"node",
".",
"Destroy",
"(",
")",
"\n",
"}",
"\n\n",
"rp",
".",
"stopTimers",
"(",
")",
"\n\n",
"rp",
".",
"setState",
"(",
... | // Destroy stops all communication. Note that this does not close the TChannel
// instance that was passed to Ringpop in the constructor. Once an instance is
// destroyed, it cannot be restarted. | [
"Destroy",
"stops",
"all",
"communication",
".",
"Note",
"that",
"this",
"does",
"not",
"close",
"the",
"TChannel",
"instance",
"that",
"was",
"passed",
"to",
"Ringpop",
"in",
"the",
"constructor",
".",
"Once",
"an",
"instance",
"is",
"destroyed",
"it",
"can... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L300-L308 |
21,032 | uber/ringpop-go | ringpop.go | Uptime | func (rp *Ringpop) Uptime() (time.Duration, error) {
if !rp.Ready() {
return 0, ErrNotBootstrapped
}
return time.Now().Sub(rp.startTime), nil
} | go | func (rp *Ringpop) Uptime() (time.Duration, error) {
if !rp.Ready() {
return 0, ErrNotBootstrapped
}
return time.Now().Sub(rp.startTime), nil
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"Uptime",
"(",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"if",
"!",
"rp",
".",
"Ready",
"(",
")",
"{",
"return",
"0",
",",
"ErrNotBootstrapped",
"\n",
"}",
"\n",
"return",
"time",
".",
"Now... | // Uptime returns the amount of time that this Ringpop instance has been
// bootstrapped for. | [
"Uptime",
"returns",
"the",
"amount",
"of",
"time",
"that",
"this",
"Ringpop",
"instance",
"has",
"been",
"bootstrapped",
"for",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L333-L338 |
21,033 | uber/ringpop-go | ringpop.go | RegisterListener | func (rp *Ringpop) RegisterListener(l events.EventListener) {
rp.logger.Warn("RegisterListener is deprecated, use AddListener")
rp.AddListener(l)
} | go | func (rp *Ringpop) RegisterListener(l events.EventListener) {
rp.logger.Warn("RegisterListener is deprecated, use AddListener")
rp.AddListener(l)
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"RegisterListener",
"(",
"l",
"events",
".",
"EventListener",
")",
"{",
"rp",
".",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"rp",
".",
"AddListener",
"(",
"l",
")",
"\n",
"}"
] | // RegisterListener is DEPRECATED, use AddListener. This function is kept around
// for the time being to make sure that ringpop is a drop in replacement for
// now. It should not be used by new projects, to accomplish this it will log a
// warning message that the developer can understand. A release in the future
// w... | [
"RegisterListener",
"is",
"DEPRECATED",
"use",
"AddListener",
".",
"This",
"function",
"is",
"kept",
"around",
"for",
"the",
"time",
"being",
"to",
"make",
"sure",
"that",
"ringpop",
"is",
"a",
"drop",
"in",
"replacement",
"for",
"now",
".",
"It",
"should",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L346-L349 |
21,034 | uber/ringpop-go | ringpop.go | getState | func (rp *Ringpop) getState() state {
rp.stateMutex.RLock()
r := rp.state
rp.stateMutex.RUnlock()
return r
} | go | func (rp *Ringpop) getState() state {
rp.stateMutex.RLock()
r := rp.state
rp.stateMutex.RUnlock()
return r
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"getState",
"(",
")",
"state",
"{",
"rp",
".",
"stateMutex",
".",
"RLock",
"(",
")",
"\n",
"r",
":=",
"rp",
".",
"state",
"\n",
"rp",
".",
"stateMutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"r",
"\n",
... | // getState gets the state of the current Ringpop instance. | [
"getState",
"gets",
"the",
"state",
"of",
"the",
"current",
"Ringpop",
"instance",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L352-L357 |
21,035 | uber/ringpop-go | ringpop.go | setState | func (rp *Ringpop) setState(s state) {
rp.stateMutex.Lock()
oldState := rp.state
rp.state = s
rp.stateMutex.Unlock()
// test if the state has changed with this call to setState
if oldState != s {
switch s {
case ready:
rp.EmitEvent(events.Ready{})
case destroyed:
rp.EmitEvent(events.Destroyed{})
}
... | go | func (rp *Ringpop) setState(s state) {
rp.stateMutex.Lock()
oldState := rp.state
rp.state = s
rp.stateMutex.Unlock()
// test if the state has changed with this call to setState
if oldState != s {
switch s {
case ready:
rp.EmitEvent(events.Ready{})
case destroyed:
rp.EmitEvent(events.Destroyed{})
}
... | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"setState",
"(",
"s",
"state",
")",
"{",
"rp",
".",
"stateMutex",
".",
"Lock",
"(",
")",
"\n",
"oldState",
":=",
"rp",
".",
"state",
"\n",
"rp",
".",
"state",
"=",
"s",
"\n",
"rp",
".",
"stateMutex",
".",
... | // setState sets the state of the current Ringpop instance. It will emit an appropriate
// event when the state will actually change | [
"setState",
"sets",
"the",
"state",
"of",
"the",
"current",
"Ringpop",
"instance",
".",
"It",
"will",
"emit",
"an",
"appropriate",
"event",
"when",
"the",
"state",
"will",
"actually",
"change"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L361-L376 |
21,036 | uber/ringpop-go | ringpop.go | SelfEvict | func (rp *Ringpop) SelfEvict() error {
if !rp.Ready() {
return ErrNotBootstrapped
}
return rp.node.SelfEvict()
} | go | func (rp *Ringpop) SelfEvict() error {
if !rp.Ready() {
return ErrNotBootstrapped
}
return rp.node.SelfEvict()
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"SelfEvict",
"(",
")",
"error",
"{",
"if",
"!",
"rp",
".",
"Ready",
"(",
")",
"{",
"return",
"ErrNotBootstrapped",
"\n",
"}",
"\n",
"return",
"rp",
".",
"node",
".",
"SelfEvict",
"(",
")",
"\n",
"}"
] | // SelfEvict should be called before shutting down the application. When calling
// this function ringpop will gracefully evict itself from the network. Utilities
// that hook into ringpop will have the opportunity to hook into this system to
// gracefully handle the shutdown of ringpop. | [
"SelfEvict",
"should",
"be",
"called",
"before",
"shutting",
"down",
"the",
"application",
".",
"When",
"calling",
"this",
"function",
"ringpop",
"will",
"gracefully",
"evict",
"itself",
"from",
"the",
"network",
".",
"Utilities",
"that",
"hook",
"into",
"ringpo... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L396-L401 |
21,037 | uber/ringpop-go | ringpop.go | Bootstrap | func (rp *Ringpop) Bootstrap(bootstrapOpts *swim.BootstrapOptions) ([]string, error) {
if rp.getState() < initialized {
err := rp.init()
if err != nil {
return nil, err
}
}
// We shouldn't try to bootstrap if the channel is not listening
if rp.channel.State() != tchannel.ChannelListening {
rp.logger.Wit... | go | func (rp *Ringpop) Bootstrap(bootstrapOpts *swim.BootstrapOptions) ([]string, error) {
if rp.getState() < initialized {
err := rp.init()
if err != nil {
return nil, err
}
}
// We shouldn't try to bootstrap if the channel is not listening
if rp.channel.State() != tchannel.ChannelListening {
rp.logger.Wit... | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"Bootstrap",
"(",
"bootstrapOpts",
"*",
"swim",
".",
"BootstrapOptions",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"rp",
".",
"getState",
"(",
")",
"<",
"initialized",
"{",
"err",
":=",
"rp",
... | //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
//
// Bootstrap
//
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// Bootstrap starts communication for this Ringpop instance.
//
// When Bootstrap is called, this Ringpop instance will attempt to contact
//... | [
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"Bootstrap",
"=",
"=",
"=",
"=",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L415-L440 |
21,038 | uber/ringpop-go | ringpop.go | Ready | func (rp *Ringpop) Ready() bool {
if rp.getState() != ready {
return false
}
return rp.node.Ready()
} | go | func (rp *Ringpop) Ready() bool {
if rp.getState() != ready {
return false
}
return rp.node.Ready()
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"Ready",
"(",
")",
"bool",
"{",
"if",
"rp",
".",
"getState",
"(",
")",
"!=",
"ready",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"rp",
".",
"node",
".",
"Ready",
"(",
")",
"\n",
"}"
] | // Ready returns whether or not ringpop is bootstrapped and ready to receive
// requests. | [
"Ready",
"returns",
"whether",
"or",
"not",
"ringpop",
"is",
"bootstrapped",
"and",
"ready",
"to",
"receive",
"requests",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L444-L449 |
21,039 | uber/ringpop-go | ringpop.go | Checksum | func (rp *Ringpop) Checksum() (uint32, error) {
if !rp.Ready() {
return 0, ErrNotBootstrapped
}
return rp.ring.Checksum(), nil
} | go | func (rp *Ringpop) Checksum() (uint32, error) {
if !rp.Ready() {
return 0, ErrNotBootstrapped
}
return rp.ring.Checksum(), nil
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"Checksum",
"(",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"if",
"!",
"rp",
".",
"Ready",
"(",
")",
"{",
"return",
"0",
",",
"ErrNotBootstrapped",
"\n",
"}",
"\n",
"return",
"rp",
".",
"ring",
".",
"Check... | //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
//
// Ring
//
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// Checksum returns the current checksum of this Ringpop instance's hashring. | [
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"Ring",
"=",
"=",
"=",
"=",
"=",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L641-L646 |
21,040 | uber/ringpop-go | ringpop.go | GetReachableMembers | func (rp *Ringpop) GetReachableMembers(predicates ...swim.MemberPredicate) ([]string, error) {
if !rp.Ready() {
return nil, ErrNotBootstrapped
}
members := rp.node.GetReachableMembers(predicates...)
addresses := make([]string, 0, len(members))
for _, member := range members {
addresses = append(addresses, me... | go | func (rp *Ringpop) GetReachableMembers(predicates ...swim.MemberPredicate) ([]string, error) {
if !rp.Ready() {
return nil, ErrNotBootstrapped
}
members := rp.node.GetReachableMembers(predicates...)
addresses := make([]string, 0, len(members))
for _, member := range members {
addresses = append(addresses, me... | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"GetReachableMembers",
"(",
"predicates",
"...",
"swim",
".",
"MemberPredicate",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"!",
"rp",
".",
"Ready",
"(",
")",
"{",
"return",
"nil",
",",
"ErrNot... | // GetReachableMembers returns a slice of members currently in this instance's
// active membership list that match all provided predicates. | [
"GetReachableMembers",
"returns",
"a",
"slice",
"of",
"members",
"currently",
"in",
"this",
"instance",
"s",
"active",
"membership",
"list",
"that",
"match",
"all",
"provided",
"predicates",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L712-L724 |
21,041 | uber/ringpop-go | ringpop.go | CountReachableMembers | func (rp *Ringpop) CountReachableMembers(predicates ...swim.MemberPredicate) (int, error) {
if !rp.Ready() {
return 0, ErrNotBootstrapped
}
return rp.node.CountReachableMembers(predicates...), nil
} | go | func (rp *Ringpop) CountReachableMembers(predicates ...swim.MemberPredicate) (int, error) {
if !rp.Ready() {
return 0, ErrNotBootstrapped
}
return rp.node.CountReachableMembers(predicates...), nil
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"CountReachableMembers",
"(",
"predicates",
"...",
"swim",
".",
"MemberPredicate",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"!",
"rp",
".",
"Ready",
"(",
")",
"{",
"return",
"0",
",",
"ErrNotBootstrapped",
... | // CountReachableMembers returns the number of members currently in this
// instance's active membership list that match all provided predicates. | [
"CountReachableMembers",
"returns",
"the",
"number",
"of",
"members",
"currently",
"in",
"this",
"instance",
"s",
"active",
"membership",
"list",
"that",
"match",
"all",
"provided",
"predicates",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L728-L733 |
21,042 | uber/ringpop-go | ringpop.go | getStatKey | func (rp *Ringpop) getStatKey(key string) string {
rp.stats.Lock()
rpKey, ok := rp.stats.keys[key]
if !ok {
rpKey = fmt.Sprintf("%s.%s", rp.stats.prefix, key)
rp.stats.keys[key] = rpKey
}
rp.stats.Unlock()
return rpKey
} | go | func (rp *Ringpop) getStatKey(key string) string {
rp.stats.Lock()
rpKey, ok := rp.stats.keys[key]
if !ok {
rpKey = fmt.Sprintf("%s.%s", rp.stats.prefix, key)
rp.stats.keys[key] = rpKey
}
rp.stats.Unlock()
return rpKey
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"getStatKey",
"(",
"key",
"string",
")",
"string",
"{",
"rp",
".",
"stats",
".",
"Lock",
"(",
")",
"\n",
"rpKey",
",",
"ok",
":=",
"rp",
".",
"stats",
".",
"keys",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
... | //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
//
// Stats
//
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | [
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"Stats",
"=",
"=",
"=",
"=",
"=",... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L741-L751 |
21,043 | uber/ringpop-go | ringpop.go | HandleOrForward | func (rp *Ringpop) HandleOrForward(key string, request []byte, response *[]byte, service, endpoint string,
format tchannel.Format, opts *forward.Options) (bool, error) {
if !rp.Ready() {
return false, ErrNotBootstrapped
}
dest, err := rp.Lookup(key)
if err != nil {
return false, err
}
address, err := rp.W... | go | func (rp *Ringpop) HandleOrForward(key string, request []byte, response *[]byte, service, endpoint string,
format tchannel.Format, opts *forward.Options) (bool, error) {
if !rp.Ready() {
return false, ErrNotBootstrapped
}
dest, err := rp.Lookup(key)
if err != nil {
return false, err
}
address, err := rp.W... | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"HandleOrForward",
"(",
"key",
"string",
",",
"request",
"[",
"]",
"byte",
",",
"response",
"*",
"[",
"]",
"byte",
",",
"service",
",",
"endpoint",
"string",
",",
"format",
"tchannel",
".",
"Format",
",",
"opts",... | //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
//
// Forwarding
//
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// HandleOrForward returns true if the request should be handled locally, or false
// if it should be forwarded to a different node. If fals... | [
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"=",
"Forwarding",
"=",
"=",
"=",
"=",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L763-L788 |
21,044 | uber/ringpop-go | ringpop.go | Forward | func (rp *Ringpop) Forward(dest string, keys []string, request []byte, service, endpoint string,
format tchannel.Format, opts *forward.Options) ([]byte, error) {
return rp.forwarder.ForwardRequest(request, dest, service, endpoint, keys, format, opts)
} | go | func (rp *Ringpop) Forward(dest string, keys []string, request []byte, service, endpoint string,
format tchannel.Format, opts *forward.Options) ([]byte, error) {
return rp.forwarder.ForwardRequest(request, dest, service, endpoint, keys, format, opts)
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"Forward",
"(",
"dest",
"string",
",",
"keys",
"[",
"]",
"string",
",",
"request",
"[",
"]",
"byte",
",",
"service",
",",
"endpoint",
"string",
",",
"format",
"tchannel",
".",
"Format",
",",
"opts",
"*",
"forwa... | // Forward forwards the request to given destination host and returns the response. | [
"Forward",
"forwards",
"the",
"request",
"to",
"given",
"destination",
"host",
"and",
"returns",
"the",
"response",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L791-L795 |
21,045 | uber/ringpop-go | ringpop.go | Labels | func (rp *Ringpop) Labels() (*swim.NodeLabels, error) {
if !rp.Ready() {
return nil, ErrNotBootstrapped
}
return rp.node.Labels(), nil
} | go | func (rp *Ringpop) Labels() (*swim.NodeLabels, error) {
if !rp.Ready() {
return nil, ErrNotBootstrapped
}
return rp.node.Labels(), nil
} | [
"func",
"(",
"rp",
"*",
"Ringpop",
")",
"Labels",
"(",
")",
"(",
"*",
"swim",
".",
"NodeLabels",
",",
"error",
")",
"{",
"if",
"!",
"rp",
".",
"Ready",
"(",
")",
"{",
"return",
"nil",
",",
"ErrNotBootstrapped",
"\n",
"}",
"\n\n",
"return",
"rp",
... | // Labels provides access to a mutator of ringpop Labels that will be shared on
// the membership. Changes made on the mutator are synchronized accross the
// cluster for other members to make local decisions on. | [
"Labels",
"provides",
"access",
"to",
"a",
"mutator",
"of",
"ringpop",
"Labels",
"that",
"will",
"be",
"shared",
"on",
"the",
"membership",
".",
"Changes",
"made",
"on",
"the",
"mutator",
"are",
"synchronized",
"accross",
"the",
"cluster",
"for",
"other",
"m... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L800-L806 |
21,046 | uber/ringpop-go | ringpop.go | SerializeThrift | func SerializeThrift(s athrift.TStruct) ([]byte, error) {
var b []byte
var buffer = bytes.NewBuffer(b)
transport := athrift.NewStreamTransportW(buffer)
if err := s.Write(athrift.NewTBinaryProtocolTransport(transport)); err != nil {
return nil, err
}
if err := transport.Flush(); err != nil {
return nil, err
... | go | func SerializeThrift(s athrift.TStruct) ([]byte, error) {
var b []byte
var buffer = bytes.NewBuffer(b)
transport := athrift.NewStreamTransportW(buffer)
if err := s.Write(athrift.NewTBinaryProtocolTransport(transport)); err != nil {
return nil, err
}
if err := transport.Flush(); err != nil {
return nil, err
... | [
"func",
"SerializeThrift",
"(",
"s",
"athrift",
".",
"TStruct",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"var",
"buffer",
"=",
"bytes",
".",
"NewBuffer",
"(",
"b",
")",
"\n\n",
"transport",
":=",
"athr... | // SerializeThrift takes a thrift struct and returns the serialized bytes
// of that struct using the thrift binary protocol. This is a temporary
// measure before frames can forwarded directly past the endpoint to the proper
// destinaiton. | [
"SerializeThrift",
"takes",
"a",
"thrift",
"struct",
"and",
"returns",
"the",
"serialized",
"bytes",
"of",
"that",
"struct",
"using",
"the",
"thrift",
"binary",
"protocol",
".",
"This",
"is",
"a",
"temporary",
"measure",
"before",
"frames",
"can",
"forwarded",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L812-L825 |
21,047 | uber/ringpop-go | ringpop.go | DeserializeThrift | func DeserializeThrift(b []byte, s athrift.TStruct) error {
reader := bytes.NewReader(b)
transport := athrift.NewStreamTransportR(reader)
return s.Read(athrift.NewTBinaryProtocolTransport(transport))
} | go | func DeserializeThrift(b []byte, s athrift.TStruct) error {
reader := bytes.NewReader(b)
transport := athrift.NewStreamTransportR(reader)
return s.Read(athrift.NewTBinaryProtocolTransport(transport))
} | [
"func",
"DeserializeThrift",
"(",
"b",
"[",
"]",
"byte",
",",
"s",
"athrift",
".",
"TStruct",
")",
"error",
"{",
"reader",
":=",
"bytes",
".",
"NewReader",
"(",
"b",
")",
"\n",
"transport",
":=",
"athrift",
".",
"NewStreamTransportR",
"(",
"reader",
")",... | // DeserializeThrift takes a byte slice and attempts to write it into the
// given thrift struct using the thrift binary protocol. This is a temporary
// measure before frames can forwarded directly past the endpoint to the proper
// destinaiton. | [
"DeserializeThrift",
"takes",
"a",
"byte",
"slice",
"and",
"attempts",
"to",
"write",
"it",
"into",
"the",
"given",
"thrift",
"struct",
"using",
"the",
"thrift",
"binary",
"protocol",
".",
"This",
"is",
"a",
"temporary",
"measure",
"before",
"frames",
"can",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/ringpop.go#L831-L835 |
21,048 | uber/ringpop-go | swim/heal_partition.go | reincarnateNodes | func reincarnateNodes(node *Node, target string, changesForA, changesForB []Change) error {
// reincarnate all nodes by disseminating that they are suspect
node.healer.logger.WithField("target", target).Info("reincarnate nodes before we can merge the partitions")
node.memberlist.Update(changesForA)
var err error
... | go | func reincarnateNodes(node *Node, target string, changesForA, changesForB []Change) error {
// reincarnate all nodes by disseminating that they are suspect
node.healer.logger.WithField("target", target).Info("reincarnate nodes before we can merge the partitions")
node.memberlist.Update(changesForA)
var err error
... | [
"func",
"reincarnateNodes",
"(",
"node",
"*",
"Node",
",",
"target",
"string",
",",
"changesForA",
",",
"changesForB",
"[",
"]",
"Change",
")",
"error",
"{",
"// reincarnate all nodes by disseminating that they are suspect",
"node",
".",
"healer",
".",
"logger",
"."... | // reincarnateNodes applies changesForA to this nodes membership, and sends a ping
// with changesForB to B's membership, so that B will apply those changes in its
// ping handler. | [
"reincarnateNodes",
"applies",
"changesForA",
"to",
"this",
"nodes",
"membership",
"and",
"sends",
"a",
"ping",
"with",
"changesForB",
"to",
"B",
"s",
"membership",
"so",
"that",
"B",
"will",
"apply",
"those",
"changes",
"in",
"its",
"ping",
"handler",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_partition.go#L119-L130 |
21,049 | uber/ringpop-go | swim/heal_partition.go | mergePartitions | func mergePartitions(node *Node, target string, MB []Change) error {
node.healer.logger.WithField("target", target).Info("merge two partitions")
// Add membership of B to this node, so that the membership
// information of B will be disseminated through A.
node.memberlist.Update(MB)
// Send membership of A to th... | go | func mergePartitions(node *Node, target string, MB []Change) error {
node.healer.logger.WithField("target", target).Info("merge two partitions")
// Add membership of B to this node, so that the membership
// information of B will be disseminated through A.
node.memberlist.Update(MB)
// Send membership of A to th... | [
"func",
"mergePartitions",
"(",
"node",
"*",
"Node",
",",
"target",
"string",
",",
"MB",
"[",
"]",
"Change",
")",
"error",
"{",
"node",
".",
"healer",
".",
"logger",
".",
"WithField",
"(",
"\"",
"\"",
",",
"target",
")",
".",
"Info",
"(",
"\"",
"\"... | // mergePartitions applies the membership of B to a and send the membership
// A to B piggybacked on top of a ping. | [
"mergePartitions",
"applies",
"the",
"membership",
"of",
"B",
"to",
"a",
"and",
"send",
"the",
"membership",
"A",
"to",
"B",
"piggybacked",
"on",
"top",
"of",
"a",
"ping",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_partition.go#L134-L146 |
21,050 | uber/ringpop-go | swim/heal_partition.go | pingableHosts | func pingableHosts(changes []Change) (ret []string) {
for _, b := range changes {
if b.isPingable() {
ret = append(ret, b.Address)
}
}
return
} | go | func pingableHosts(changes []Change) (ret []string) {
for _, b := range changes {
if b.isPingable() {
ret = append(ret, b.Address)
}
}
return
} | [
"func",
"pingableHosts",
"(",
"changes",
"[",
"]",
"Change",
")",
"(",
"ret",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"b",
":=",
"range",
"changes",
"{",
"if",
"b",
".",
"isPingable",
"(",
")",
"{",
"ret",
"=",
"append",
"(",
"ret",
",",
... | // pingableHosts returns the address of those changes that are pingable. | [
"pingableHosts",
"returns",
"the",
"address",
"of",
"those",
"changes",
"that",
"are",
"pingable",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_partition.go#L149-L156 |
21,051 | uber/ringpop-go | swim/heal_partition.go | selectMember | func selectMember(partition []Change, address string) (Change, bool) {
for _, m := range partition {
if m.Address == address {
return m, true
}
}
return Change{}, false
} | go | func selectMember(partition []Change, address string) (Change, bool) {
for _, m := range partition {
if m.Address == address {
return m, true
}
}
return Change{}, false
} | [
"func",
"selectMember",
"(",
"partition",
"[",
"]",
"Change",
",",
"address",
"string",
")",
"(",
"Change",
",",
"bool",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"partition",
"{",
"if",
"m",
".",
"Address",
"==",
"address",
"{",
"return",
"m",
... | // selectMember selects the member with the specified address from the partition. | [
"selectMember",
"selects",
"the",
"member",
"with",
"the",
"specified",
"address",
"from",
"the",
"partition",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/heal_partition.go#L159-L167 |
21,052 | uber/ringpop-go | swim/memberlist.go | newMemberlist | func newMemberlist(n *Node, initialLabels LabelMap) *memberlist {
m := &memberlist{
node: n,
logger: logging.Logger("membership").WithField("local", n.address),
// prepopulate the local member with its state
local: &Member{
Address: n.Address(),
Incarnation: nowInMillis(n.clock),
Status: A... | go | func newMemberlist(n *Node, initialLabels LabelMap) *memberlist {
m := &memberlist{
node: n,
logger: logging.Logger("membership").WithField("local", n.address),
// prepopulate the local member with its state
local: &Member{
Address: n.Address(),
Incarnation: nowInMillis(n.clock),
Status: A... | [
"func",
"newMemberlist",
"(",
"n",
"*",
"Node",
",",
"initialLabels",
"LabelMap",
")",
"*",
"memberlist",
"{",
"m",
":=",
"&",
"memberlist",
"{",
"node",
":",
"n",
",",
"logger",
":",
"logging",
".",
"Logger",
"(",
"\"",
"\"",
")",
".",
"WithField",
... | // newMemberlist returns a new member list | [
"newMemberlist",
"returns",
"a",
"new",
"member",
"list"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L64-L83 |
21,053 | uber/ringpop-go | swim/memberlist.go | ComputeChecksum | func (m *memberlist) ComputeChecksum() {
startTime := time.Now()
m.members.Lock()
checksum := farm.Fingerprint32([]byte(m.genChecksumString()))
oldChecksum := m.members.checksum
m.members.checksum = checksum
m.members.Unlock()
if oldChecksum != checksum {
m.logger.WithFields(bark.Fields{
"checksum": che... | go | func (m *memberlist) ComputeChecksum() {
startTime := time.Now()
m.members.Lock()
checksum := farm.Fingerprint32([]byte(m.genChecksumString()))
oldChecksum := m.members.checksum
m.members.checksum = checksum
m.members.Unlock()
if oldChecksum != checksum {
m.logger.WithFields(bark.Fields{
"checksum": che... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"ComputeChecksum",
"(",
")",
"{",
"startTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"m",
".",
"members",
".",
"Lock",
"(",
")",
"\n",
"checksum",
":=",
"farm",
".",
"Fingerprint32",
"(",
"[",
"]",
"byt... | // computes membership checksum | [
"computes",
"membership",
"checksum"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L94-L114 |
21,054 | uber/ringpop-go | swim/memberlist.go | genChecksumString | func (m *memberlist) genChecksumString() string {
var strings sort.StringSlice
var buffer bytes.Buffer
for _, member := range m.members.list {
// Don't include Tombstone nodes in the checksum to avoid
// bringing them back to life through full syncs
if member.Status == Tombstone {
continue
}
// collec... | go | func (m *memberlist) genChecksumString() string {
var strings sort.StringSlice
var buffer bytes.Buffer
for _, member := range m.members.list {
// Don't include Tombstone nodes in the checksum to avoid
// bringing them back to life through full syncs
if member.Status == Tombstone {
continue
}
// collec... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"genChecksumString",
"(",
")",
"string",
"{",
"var",
"strings",
"sort",
".",
"StringSlice",
"\n",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n\n",
"for",
"_",
",",
"member",
":=",
"range",
"m",
".",
"members",
... | // generates string to use when computing checksum | [
"generates",
"string",
"to",
"use",
"when",
"computing",
"checksum"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L117-L143 |
21,055 | uber/ringpop-go | swim/memberlist.go | Member | func (m *memberlist) Member(address string) (*Member, bool) {
var memberCopy *Member
m.members.RLock()
member, ok := m.members.byAddress[address]
if member != nil {
memberCopy = new(Member)
*memberCopy = *member
}
m.members.RUnlock()
return memberCopy, ok
} | go | func (m *memberlist) Member(address string) (*Member, bool) {
var memberCopy *Member
m.members.RLock()
member, ok := m.members.byAddress[address]
if member != nil {
memberCopy = new(Member)
*memberCopy = *member
}
m.members.RUnlock()
return memberCopy, ok
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"Member",
"(",
"address",
"string",
")",
"(",
"*",
"Member",
",",
"bool",
")",
"{",
"var",
"memberCopy",
"*",
"Member",
"\n",
"m",
".",
"members",
".",
"RLock",
"(",
")",
"\n",
"member",
",",
"ok",
":=",
... | // returns the member at a specific address | [
"returns",
"the",
"member",
"at",
"a",
"specific",
"address"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L146-L157 |
21,056 | uber/ringpop-go | swim/memberlist.go | LocalMember | func (m *memberlist) LocalMember() (member Member) {
m.members.Lock()
// copy local member state
member = *m.local
m.members.Unlock()
return
} | go | func (m *memberlist) LocalMember() (member Member) {
m.members.Lock()
// copy local member state
member = *m.local
m.members.Unlock()
return
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"LocalMember",
"(",
")",
"(",
"member",
"Member",
")",
"{",
"m",
".",
"members",
".",
"Lock",
"(",
")",
"\n",
"// copy local member state",
"member",
"=",
"*",
"m",
".",
"local",
"\n",
"m",
".",
"members",
".... | // LocalMember returns a copy of the local Member in a thread safe way. | [
"LocalMember",
"returns",
"a",
"copy",
"of",
"the",
"local",
"Member",
"in",
"a",
"thread",
"safe",
"way",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L160-L166 |
21,057 | uber/ringpop-go | swim/memberlist.go | RemoveMember | func (m *memberlist) RemoveMember(address string) bool {
m.members.Lock()
member, hasMember := m.members.byAddress[address]
if hasMember {
delete(m.members.byAddress, address)
for i, lMember := range m.members.list {
if member == lMember {
// a safe way to remove a pointer from a slice
m.members.list,... | go | func (m *memberlist) RemoveMember(address string) bool {
m.members.Lock()
member, hasMember := m.members.byAddress[address]
if hasMember {
delete(m.members.byAddress, address)
for i, lMember := range m.members.list {
if member == lMember {
// a safe way to remove a pointer from a slice
m.members.list,... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"RemoveMember",
"(",
"address",
"string",
")",
"bool",
"{",
"m",
".",
"members",
".",
"Lock",
"(",
")",
"\n",
"member",
",",
"hasMember",
":=",
"m",
".",
"members",
".",
"byAddress",
"[",
"address",
"]",
"\n"... | // RemoveMember removes the member from the membership list. If the membership has
// changed during this operation a new checksum will be computed. | [
"RemoveMember",
"removes",
"the",
"member",
"from",
"the",
"membership",
"list",
".",
"If",
"the",
"membership",
"has",
"changed",
"during",
"this",
"operation",
"a",
"new",
"checksum",
"will",
"be",
"computed",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L170-L191 |
21,058 | uber/ringpop-go | swim/memberlist.go | Pingable | func (m *memberlist) Pingable(member Member) bool {
return member.Address != m.local.Address &&
(member.Status == Alive || member.Status == Suspect)
} | go | func (m *memberlist) Pingable(member Member) bool {
return member.Address != m.local.Address &&
(member.Status == Alive || member.Status == Suspect)
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"Pingable",
"(",
"member",
"Member",
")",
"bool",
"{",
"return",
"member",
".",
"Address",
"!=",
"m",
".",
"local",
".",
"Address",
"&&",
"(",
"member",
".",
"Status",
"==",
"Alive",
"||",
"member",
".",
"Sta... | // returns whether or not a member is pingable | [
"returns",
"whether",
"or",
"not",
"a",
"member",
"is",
"pingable"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L211-L215 |
21,059 | uber/ringpop-go | swim/memberlist.go | NumPingableMembers | func (m *memberlist) NumPingableMembers() (n int) {
m.members.RLock()
for _, member := range m.members.list {
if m.Pingable(*member) {
n++
}
}
m.members.RUnlock()
return n
} | go | func (m *memberlist) NumPingableMembers() (n int) {
m.members.RLock()
for _, member := range m.members.list {
if m.Pingable(*member) {
n++
}
}
m.members.RUnlock()
return n
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"NumPingableMembers",
"(",
")",
"(",
"n",
"int",
")",
"{",
"m",
".",
"members",
".",
"RLock",
"(",
")",
"\n",
"for",
"_",
",",
"member",
":=",
"range",
"m",
".",
"members",
".",
"list",
"{",
"if",
"m",
... | // returns the number of pingable members in the memberlist | [
"returns",
"the",
"number",
"of",
"pingable",
"members",
"in",
"the",
"memberlist"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L218-L228 |
21,060 | uber/ringpop-go | swim/memberlist.go | RandomPingableMembers | func (m *memberlist) RandomPingableMembers(n int, excluding map[string]bool) []Member {
members := make([]Member, 0, n)
m.members.RLock()
indices := rand.Perm(len(m.members.list))
for _, index := range indices {
member := m.members.list[index]
if m.Pingable(*member) && !excluding[member.Address] {
members =... | go | func (m *memberlist) RandomPingableMembers(n int, excluding map[string]bool) []Member {
members := make([]Member, 0, n)
m.members.RLock()
indices := rand.Perm(len(m.members.list))
for _, index := range indices {
member := m.members.list[index]
if m.Pingable(*member) && !excluding[member.Address] {
members =... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"RandomPingableMembers",
"(",
"n",
"int",
",",
"excluding",
"map",
"[",
"string",
"]",
"bool",
")",
"[",
"]",
"Member",
"{",
"members",
":=",
"make",
"(",
"[",
"]",
"Member",
",",
"0",
",",
"n",
")",
"\n\n"... | // returns n pingable members in the member list | [
"returns",
"n",
"pingable",
"members",
"in",
"the",
"member",
"list"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L231-L247 |
21,061 | uber/ringpop-go | swim/memberlist.go | bumpIncarnation | func (m *memberlist) bumpIncarnation() Change {
// reincarnate the local copy of the state of the node
m.local.Incarnation = nowInMillis(m.node.clock)
// create a change to disseminate around
change := Change{}
change.populateSource(m.local)
change.populateSubject(m.local)
return change
} | go | func (m *memberlist) bumpIncarnation() Change {
// reincarnate the local copy of the state of the node
m.local.Incarnation = nowInMillis(m.node.clock)
// create a change to disseminate around
change := Change{}
change.populateSource(m.local)
change.populateSubject(m.local)
return change
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"bumpIncarnation",
"(",
")",
"Change",
"{",
"// reincarnate the local copy of the state of the node",
"m",
".",
"local",
".",
"Incarnation",
"=",
"nowInMillis",
"(",
"m",
".",
"node",
".",
"clock",
")",
"\n\n",
"// creat... | // bumpIncarnation will increase the incarnation number of the local member. It
// will also prepare the change needed to gossip the change to the rest of the
// network. This function does not update the checksum stored on the membership,
// this is the responsibility of the caller since more changes might be made at
... | [
"bumpIncarnation",
"will",
"increase",
"the",
"incarnation",
"number",
"of",
"the",
"local",
"member",
".",
"It",
"will",
"also",
"prepare",
"the",
"change",
"needed",
"to",
"gossip",
"the",
"change",
"to",
"the",
"rest",
"of",
"the",
"network",
".",
"This",... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L269-L279 |
21,062 | uber/ringpop-go | swim/memberlist.go | SetLocalLabel | func (m *memberlist) SetLocalLabel(key, value string) error {
return m.SetLocalLabels(map[string]string{key: value})
} | go | func (m *memberlist) SetLocalLabel(key, value string) error {
return m.SetLocalLabels(map[string]string{key: value})
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"SetLocalLabel",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"return",
"m",
".",
"SetLocalLabels",
"(",
"map",
"[",
"string",
"]",
"string",
"{",
"key",
":",
"value",
"}",
")",
"\n",
"}"
] | // SetLocalLabel sets the label identified by key to the new value. This
// operation is validated against the configured limits for labels and will
// return an ErrLabelSizeExceeded in the case this operation would alter the
// labels of the node in such a way that the configured limits are exceeded. | [
"SetLocalLabel",
"sets",
"the",
"label",
"identified",
"by",
"key",
"to",
"the",
"new",
"value",
".",
"This",
"operation",
"is",
"validated",
"against",
"the",
"configured",
"limits",
"for",
"labels",
"and",
"will",
"return",
"an",
"ErrLabelSizeExceeded",
"in",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L307-L309 |
21,063 | uber/ringpop-go | swim/memberlist.go | GetLocalLabel | func (m *memberlist) GetLocalLabel(key string) (string, bool) {
m.members.RLock()
value, has := m.local.Labels[key]
m.members.RUnlock()
return value, has
} | go | func (m *memberlist) GetLocalLabel(key string) (string, bool) {
m.members.RLock()
value, has := m.local.Labels[key]
m.members.RUnlock()
return value, has
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"GetLocalLabel",
"(",
"key",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"m",
".",
"members",
".",
"RLock",
"(",
")",
"\n",
"value",
",",
"has",
":=",
"m",
".",
"local",
".",
"Labels",
"[",
"key"... | // GetLocalLabel returns the value of a label set on the local node. Its second
// argument indicates if the key was present on the node or not | [
"GetLocalLabel",
"returns",
"the",
"value",
"of",
"a",
"label",
"set",
"on",
"the",
"local",
"node",
".",
"Its",
"second",
"argument",
"indicates",
"if",
"the",
"key",
"was",
"present",
"on",
"the",
"node",
"or",
"not"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L313-L318 |
21,064 | uber/ringpop-go | swim/memberlist.go | LocalLabelsAsMap | func (m *memberlist) LocalLabelsAsMap() map[string]string {
m.members.RLock()
defer m.members.RUnlock()
if len(m.local.Labels) == 0 {
return nil
}
cpy := make(map[string]string, len(m.local.Labels))
for k, v := range m.local.Labels {
cpy[k] = v
}
return cpy
} | go | func (m *memberlist) LocalLabelsAsMap() map[string]string {
m.members.RLock()
defer m.members.RUnlock()
if len(m.local.Labels) == 0 {
return nil
}
cpy := make(map[string]string, len(m.local.Labels))
for k, v := range m.local.Labels {
cpy[k] = v
}
return cpy
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"LocalLabelsAsMap",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
".",
"members",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"members",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"len",
"(",
"... | // LocalLabelsAsMap copies the labels set on the local node into a map for the
// callee to use. Changes to this map will not be reflected in the labels kept
// by this node. | [
"LocalLabelsAsMap",
"copies",
"the",
"labels",
"set",
"on",
"the",
"local",
"node",
"into",
"a",
"map",
"for",
"the",
"callee",
"to",
"use",
".",
"Changes",
"to",
"this",
"map",
"will",
"not",
"be",
"reflected",
"in",
"the",
"labels",
"kept",
"by",
"this... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L323-L335 |
21,065 | uber/ringpop-go | swim/memberlist.go | SetLocalLabels | func (m *memberlist) SetLocalLabels(labels map[string]string) error {
if err := m.node.labelLimits.validateLabels(m.local.Labels, labels); err != nil {
// the labels operation violates the label limits that has been configured
return err
}
m.updateLocalMember(func(member *Member) bool {
// ensure that there i... | go | func (m *memberlist) SetLocalLabels(labels map[string]string) error {
if err := m.node.labelLimits.validateLabels(m.local.Labels, labels); err != nil {
// the labels operation violates the label limits that has been configured
return err
}
m.updateLocalMember(func(member *Member) bool {
// ensure that there i... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"SetLocalLabels",
"(",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"node",
".",
"labelLimits",
".",
"validateLabels",
"(",
"m",
".",
"local",
".",
"Labels",
... | // SetLocalLabels updates multiple labels at once. It will take all the labels
// that are set in the map passed to this function and overwrite the value with
// the value in the map. Keys that are not present in the provided map will
// remain in the labels of this node. The operation is guaranteed to succeed
// compl... | [
"SetLocalLabels",
"updates",
"multiple",
"labels",
"at",
"once",
".",
"It",
"will",
"take",
"all",
"the",
"labels",
"that",
"are",
"set",
"in",
"the",
"map",
"passed",
"to",
"this",
"function",
"and",
"overwrite",
"the",
"value",
"with",
"the",
"value",
"i... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L345-L378 |
21,066 | uber/ringpop-go | swim/memberlist.go | updateLocalMember | func (m *memberlist) updateLocalMember(update func(*Member) bool) {
m.members.Lock()
before := *m.local
didUpdate := update(m.local)
// exit if the update didn't change anything
if !didUpdate {
m.members.Unlock()
return
}
// bump incarnation number if the member has been updated
change := m.bumpIncarnati... | go | func (m *memberlist) updateLocalMember(update func(*Member) bool) {
m.members.Lock()
before := *m.local
didUpdate := update(m.local)
// exit if the update didn't change anything
if !didUpdate {
m.members.Unlock()
return
}
// bump incarnation number if the member has been updated
change := m.bumpIncarnati... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"updateLocalMember",
"(",
"update",
"func",
"(",
"*",
"Member",
")",
"bool",
")",
"{",
"m",
".",
"members",
".",
"Lock",
"(",
")",
"\n\n",
"before",
":=",
"*",
"m",
".",
"local",
"\n",
"didUpdate",
":=",
"u... | // updateLocalMember takes an update function to upate the member passed in. The
// update function can make mutations to the member and should indicate if it
// made changes, only if changes are made the incarnation number will be bumped
// and the new state will be gossiped to the peers | [
"updateLocalMember",
"takes",
"an",
"update",
"function",
"to",
"upate",
"the",
"member",
"passed",
"in",
".",
"The",
"update",
"function",
"can",
"make",
"mutations",
"to",
"the",
"member",
"and",
"should",
"indicate",
"if",
"it",
"made",
"changes",
"only",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L418-L461 |
21,067 | uber/ringpop-go | swim/memberlist.go | MakeTombstone | func (m *memberlist) MakeTombstone(address string, incarnation int64) []Change {
m.node.EmitEvent(MakeNodeStatusEvent{Tombstone})
return m.MakeChange(address, incarnation, Tombstone)
} | go | func (m *memberlist) MakeTombstone(address string, incarnation int64) []Change {
m.node.EmitEvent(MakeNodeStatusEvent{Tombstone})
return m.MakeChange(address, incarnation, Tombstone)
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"MakeTombstone",
"(",
"address",
"string",
",",
"incarnation",
"int64",
")",
"[",
"]",
"Change",
"{",
"m",
".",
"node",
".",
"EmitEvent",
"(",
"MakeNodeStatusEvent",
"{",
"Tombstone",
"}",
")",
"\n",
"return",
"m... | // MakeTombstone declares the node with the provided address in the tombstone state
// on the given incarnation number. If the incarnation number in the local memberlist
// is already higher than the incartation number provided in this function it is
// essentially a no-op. The list of changes that is returned is the a... | [
"MakeTombstone",
"declares",
"the",
"node",
"with",
"the",
"provided",
"address",
"in",
"the",
"tombstone",
"state",
"on",
"the",
"given",
"incarnation",
"number",
".",
"If",
"the",
"incarnation",
"number",
"in",
"the",
"local",
"memberlist",
"is",
"already",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L469-L472 |
21,068 | uber/ringpop-go | swim/memberlist.go | Evict | func (m *memberlist) Evict(address string) {
if m.local.Address == address {
// We should not evict ourselves from the memberlist. This should not be reached, but we will make noise in the logs
m.logger.Error("ringpop tried to evict the local member from the memberlist, action has been prevented")
return
}
m.... | go | func (m *memberlist) Evict(address string) {
if m.local.Address == address {
// We should not evict ourselves from the memberlist. This should not be reached, but we will make noise in the logs
m.logger.Error("ringpop tried to evict the local member from the memberlist, action has been prevented")
return
}
m.... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"Evict",
"(",
"address",
"string",
")",
"{",
"if",
"m",
".",
"local",
".",
"Address",
"==",
"address",
"{",
"// We should not evict ourselves from the memberlist. This should not be reached, but we will make noise in the logs",
"m... | // Evict evicts a member from the memberlist. It prevents the local node to be evicted
// since that is undesired behavior. | [
"Evict",
"evicts",
"a",
"member",
"from",
"the",
"memberlist",
".",
"It",
"prevents",
"the",
"local",
"node",
"to",
"be",
"evicted",
"since",
"that",
"is",
"undesired",
"behavior",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L476-L484 |
21,069 | uber/ringpop-go | swim/memberlist.go | MakeChange | func (m *memberlist) MakeChange(address string, incarnation int64, status string) []Change {
member, _ := m.Member(address)
// create the new change based on information know to the memberlist
var change Change
change.populateSubject(member)
change.populateSource(m.local)
// Override values that are specific t... | go | func (m *memberlist) MakeChange(address string, incarnation int64, status string) []Change {
member, _ := m.Member(address)
// create the new change based on information know to the memberlist
var change Change
change.populateSubject(member)
change.populateSource(m.local)
// Override values that are specific t... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"MakeChange",
"(",
"address",
"string",
",",
"incarnation",
"int64",
",",
"status",
"string",
")",
"[",
"]",
"Change",
"{",
"member",
",",
"_",
":=",
"m",
".",
"Member",
"(",
"address",
")",
"\n\n",
"// create ... | // makes a change to the member list | [
"makes",
"a",
"change",
"to",
"the",
"member",
"list"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L487-L504 |
21,070 | uber/ringpop-go | swim/memberlist.go | Update | func (m *memberlist) Update(changes []Change) (applied []Change) {
if m.node.Stopped() || len(changes) == 0 {
return nil
}
// validate incoming changes
for i, change := range changes {
changes[i] = change.validateIncoming()
}
m.node.EmitEvent(MemberlistChangesReceivedEvent{changes})
var memberChanges []me... | go | func (m *memberlist) Update(changes []Change) (applied []Change) {
if m.node.Stopped() || len(changes) == 0 {
return nil
}
// validate incoming changes
for i, change := range changes {
changes[i] = change.validateIncoming()
}
m.node.EmitEvent(MemberlistChangesReceivedEvent{changes})
var memberChanges []me... | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"Update",
"(",
"changes",
"[",
"]",
"Change",
")",
"(",
"applied",
"[",
"]",
"Change",
")",
"{",
"if",
"m",
".",
"node",
".",
"Stopped",
"(",
")",
"||",
"len",
"(",
"changes",
")",
"==",
"0",
"{",
"retu... | // updates the member list with the slice of changes, applying selectively | [
"updates",
"the",
"member",
"list",
"with",
"the",
"slice",
"of",
"changes",
"applying",
"selectively"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L519-L629 |
21,071 | uber/ringpop-go | swim/memberlist.go | AddJoinList | func (m *memberlist) AddJoinList(list []Change) {
applied := m.Update(list)
for _, member := range applied {
if member.Address == m.node.Address() {
continue
}
m.node.disseminator.ClearChange(member.Address)
}
} | go | func (m *memberlist) AddJoinList(list []Change) {
applied := m.Update(list)
for _, member := range applied {
if member.Address == m.node.Address() {
continue
}
m.node.disseminator.ClearChange(member.Address)
}
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"AddJoinList",
"(",
"list",
"[",
"]",
"Change",
")",
"{",
"applied",
":=",
"m",
".",
"Update",
"(",
"list",
")",
"\n",
"for",
"_",
",",
"member",
":=",
"range",
"applied",
"{",
"if",
"member",
".",
"Address... | // AddJoinList adds the list to the membership with the Update
// function. However, as a side effect, Update adds changes to
// the disseminator as well. Since we don't want to disseminate
// the potentially very large join lists, we clear all the
// changes from the disseminator, except for the one change
// that ref... | [
"AddJoinList",
"adds",
"the",
"list",
"to",
"the",
"membership",
"with",
"the",
"Update",
"function",
".",
"However",
"as",
"a",
"side",
"effect",
"Update",
"adds",
"changes",
"to",
"the",
"disseminator",
"as",
"well",
".",
"Since",
"we",
"don",
"t",
"want... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L637-L645 |
21,072 | uber/ringpop-go | swim/memberlist.go | getJoinPosition | func (m *memberlist) getJoinPosition() int {
l := len(m.members.list)
if l == 0 {
return l
}
return rand.Intn(l)
} | go | func (m *memberlist) getJoinPosition() int {
l := len(m.members.list)
if l == 0 {
return l
}
return rand.Intn(l)
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"getJoinPosition",
"(",
")",
"int",
"{",
"l",
":=",
"len",
"(",
"m",
".",
"members",
".",
"list",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"l",
"\n",
"}",
"\n",
"return",
"rand",
".",
"Intn",
"("... | // getJoinPosition picks a random position in [0, length of member list), this
// assumes the caller already has a read lock on the member struct to prevent
// concurrent access. | [
"getJoinPosition",
"picks",
"a",
"random",
"position",
"in",
"[",
"0",
"length",
"of",
"member",
"list",
")",
"this",
"assumes",
"the",
"caller",
"already",
"has",
"a",
"read",
"lock",
"on",
"the",
"member",
"struct",
"to",
"prevent",
"concurrent",
"access",... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L650-L656 |
21,073 | uber/ringpop-go | swim/memberlist.go | Shuffle | func (m *memberlist) Shuffle() {
m.members.Lock()
m.members.list = shuffle(m.members.list)
m.members.Unlock()
} | go | func (m *memberlist) Shuffle() {
m.members.Lock()
m.members.list = shuffle(m.members.list)
m.members.Unlock()
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"Shuffle",
"(",
")",
"{",
"m",
".",
"members",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"members",
".",
"list",
"=",
"shuffle",
"(",
"m",
".",
"members",
".",
"list",
")",
"\n",
"m",
".",
"members",
".",
... | // shuffles the member list | [
"shuffles",
"the",
"member",
"list"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L659-L663 |
21,074 | uber/ringpop-go | swim/memberlist.go | String | func (m *memberlist) String() string {
m.members.RLock()
str, _ := json.Marshal(m.members.list) // will never return error (presumably)
m.members.RUnlock()
return string(str)
} | go | func (m *memberlist) String() string {
m.members.RLock()
str, _ := json.Marshal(m.members.list) // will never return error (presumably)
m.members.RUnlock()
return string(str)
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"String",
"(",
")",
"string",
"{",
"m",
".",
"members",
".",
"RLock",
"(",
")",
"\n",
"str",
",",
"_",
":=",
"json",
".",
"Marshal",
"(",
"m",
".",
"members",
".",
"list",
")",
"// will never return error (pr... | // String returns a JSON string | [
"String",
"returns",
"a",
"JSON",
"string"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L666-L671 |
21,075 | uber/ringpop-go | swim/memberlist.go | CountMembers | func (m *memberlist) CountMembers(predicates ...MemberPredicate) int {
count := 0
m.members.RLock()
for _, member := range m.members.list {
if MemberMatchesPredicates(*member, predicates...) {
count++
}
}
m.members.RUnlock()
return count
} | go | func (m *memberlist) CountMembers(predicates ...MemberPredicate) int {
count := 0
m.members.RLock()
for _, member := range m.members.list {
if MemberMatchesPredicates(*member, predicates...) {
count++
}
}
m.members.RUnlock()
return count
} | [
"func",
"(",
"m",
"*",
"memberlist",
")",
"CountMembers",
"(",
"predicates",
"...",
"MemberPredicate",
")",
"int",
"{",
"count",
":=",
"0",
"\n\n",
"m",
".",
"members",
".",
"RLock",
"(",
")",
"\n",
"for",
"_",
",",
"member",
":=",
"range",
"m",
".",... | // CountMembers returns the number of members maintained by the swim membership
// protocol for all members that match the predicates | [
"CountMembers",
"returns",
"the",
"number",
"of",
"members",
"maintained",
"by",
"the",
"swim",
"membership",
"protocol",
"for",
"all",
"members",
"that",
"match",
"the",
"predicates"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L680-L692 |
21,076 | uber/ringpop-go | swim/memberlist.go | nowInMillis | func nowInMillis(c clock.Clock) int64 {
return c.Now().UnixNano() / int64(time.Millisecond)
} | go | func nowInMillis(c clock.Clock) int64 {
return c.Now().UnixNano() / int64(time.Millisecond)
} | [
"func",
"nowInMillis",
"(",
"c",
"clock",
".",
"Clock",
")",
"int64",
"{",
"return",
"c",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
"/",
"int64",
"(",
"time",
".",
"Millisecond",
")",
"\n",
"}"
] | // nowInMillis is a utility function that call Now on the clock and converts it
// to milliseconds. | [
"nowInMillis",
"is",
"a",
"utility",
"function",
"that",
"call",
"Now",
"on",
"the",
"clock",
"and",
"converts",
"it",
"to",
"milliseconds",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist.go#L696-L698 |
21,077 | uber/ringpop-go | examples/role-labels/gen-go/role/ringpop-role.go | SetRole | func (a *RingpopRoleServiceAdapter) SetRole(ctx thrift.Context, role string) (err error) {
// check if the function should be called locally
if a.config.SetRole == nil || forward.DeleteForwardedHeader(ctx) {
return a.impl.SetRole(ctx, role)
}
// find the key to shard on
ringpopKey, err := a.config.SetRole.Key(c... | go | func (a *RingpopRoleServiceAdapter) SetRole(ctx thrift.Context, role string) (err error) {
// check if the function should be called locally
if a.config.SetRole == nil || forward.DeleteForwardedHeader(ctx) {
return a.impl.SetRole(ctx, role)
}
// find the key to shard on
ringpopKey, err := a.config.SetRole.Key(c... | [
"func",
"(",
"a",
"*",
"RingpopRoleServiceAdapter",
")",
"SetRole",
"(",
"ctx",
"thrift",
".",
"Context",
",",
"role",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// check if the function should be called locally",
"if",
"a",
".",
"config",
".",
"SetRole",
... | // SetRole satisfies the TChanRoleService interface. This function uses the configuration for SetRole 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. | [
"SetRole",
"satisfies",
"the",
"TChanRoleService",
"interface",
".",
"This",
"function",
"uses",
"the",
"configuration",
"for",
"SetRole",
"to",
"determine",
"the",
"host",
"to",
"execute",
"the",
"call",
"on",
".",
"When",
"it",
"decides",
"the",
"call",
"nee... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/examples/role-labels/gen-go/role/ringpop-role.go#L143-L165 |
21,078 | uber/ringpop-go | forward/request_sender.go | newRequestSender | func newRequestSender(sender Sender, emitter events.EventEmitter, channel shared.SubChannel, request []byte, keys []string,
destination, service, endpoint string, format tchannel.Format, opts *Options) *requestSender {
logger := logging.Logger("sender")
if address, err := sender.WhoAmI(); err != nil {
logger = lo... | go | func newRequestSender(sender Sender, emitter events.EventEmitter, channel shared.SubChannel, request []byte, keys []string,
destination, service, endpoint string, format tchannel.Format, opts *Options) *requestSender {
logger := logging.Logger("sender")
if address, err := sender.WhoAmI(); err != nil {
logger = lo... | [
"func",
"newRequestSender",
"(",
"sender",
"Sender",
",",
"emitter",
"events",
".",
"EventEmitter",
",",
"channel",
"shared",
".",
"SubChannel",
",",
"request",
"[",
"]",
"byte",
",",
"keys",
"[",
"]",
"string",
",",
"destination",
",",
"service",
",",
"en... | // NewRequestSender returns a new request sender that can be used to forward a request to its destination | [
"NewRequestSender",
"returns",
"a",
"new",
"request",
"sender",
"that",
"can",
"be",
"used",
"to",
"forward",
"a",
"request",
"to",
"its",
"destination"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/request_sender.go#L72-L98 |
21,079 | uber/ringpop-go | forward/request_sender.go | MakeCall | func (s *requestSender) MakeCall(ctx context.Context, res *[]byte, fwdError *error, appError *error) <-chan bool {
done := make(chan bool, 1)
go func() {
defer close(done)
peer := s.channel.Peers().GetOrAdd(s.destination)
call, err := peer.BeginCall(ctx, s.service, s.endpoint, &tchannel.CallOptions{
Format... | go | func (s *requestSender) MakeCall(ctx context.Context, res *[]byte, fwdError *error, appError *error) <-chan bool {
done := make(chan bool, 1)
go func() {
defer close(done)
peer := s.channel.Peers().GetOrAdd(s.destination)
call, err := peer.BeginCall(ctx, s.service, s.endpoint, &tchannel.CallOptions{
Format... | [
"func",
"(",
"s",
"*",
"requestSender",
")",
"MakeCall",
"(",
"ctx",
"context",
".",
"Context",
",",
"res",
"*",
"[",
"]",
"byte",
",",
"fwdError",
"*",
"error",
",",
"appError",
"*",
"error",
")",
"<-",
"chan",
"bool",
"{",
"done",
":=",
"make",
"... | // calls remote service and writes response to s.response | [
"calls",
"remote",
"service",
"and",
"writes",
"response",
"to",
"s",
".",
"response"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/request_sender.go#L160-L216 |
21,080 | uber/ringpop-go | forward/request_sender.go | AttemptRetry | func (s *requestSender) AttemptRetry() ([]byte, error) {
s.retries++
s.emitter.EmitEvent(RetryAttemptEvent{})
dests := s.LookupKeys(s.keys)
if len(dests) != 1 {
s.emitter.EmitEvent(RetryAbortEvent{errDestinationsDiverged.Error()})
return nil, errDestinationsDiverged
}
if s.rerouteRetries {
newDest := des... | go | func (s *requestSender) AttemptRetry() ([]byte, error) {
s.retries++
s.emitter.EmitEvent(RetryAttemptEvent{})
dests := s.LookupKeys(s.keys)
if len(dests) != 1 {
s.emitter.EmitEvent(RetryAbortEvent{errDestinationsDiverged.Error()})
return nil, errDestinationsDiverged
}
if s.rerouteRetries {
newDest := des... | [
"func",
"(",
"s",
"*",
"requestSender",
")",
"AttemptRetry",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"s",
".",
"retries",
"++",
"\n\n",
"s",
".",
"emitter",
".",
"EmitEvent",
"(",
"RetryAttemptEvent",
"{",
"}",
")",
"\n\n",
"dests",
... | // AttemptRetry attempts to resend a request. Before resending it will
// lookup the keys provided to the requestSender upon construction. If
// keys that previously hashed to the same destination diverge, an
// errDestinationsDiverged error will be returned. If keys do not diverge,
// the will be rerouted to their new... | [
"AttemptRetry",
"attempts",
"to",
"resend",
"a",
"request",
".",
"Before",
"resending",
"it",
"will",
"lookup",
"the",
"keys",
"provided",
"to",
"the",
"requestSender",
"upon",
"construction",
".",
"If",
"keys",
"that",
"previously",
"hashed",
"to",
"the",
"sa... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/request_sender.go#L234-L255 |
21,081 | uber/ringpop-go | forward/request_sender.go | LookupKeys | func (s *requestSender) LookupKeys(keys []string) []string {
// Lookup and dedupe the destinations of the keys.
destSet := make(map[string]struct{})
for _, key := range keys {
dest, err := s.sender.Lookup(key)
if err != nil {
// TODO Do something better than swallowing these errors.
continue
}
destSet... | go | func (s *requestSender) LookupKeys(keys []string) []string {
// Lookup and dedupe the destinations of the keys.
destSet := make(map[string]struct{})
for _, key := range keys {
dest, err := s.sender.Lookup(key)
if err != nil {
// TODO Do something better than swallowing these errors.
continue
}
destSet... | [
"func",
"(",
"s",
"*",
"requestSender",
")",
"LookupKeys",
"(",
"keys",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"// Lookup and dedupe the destinations of the keys.",
"destSet",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
... | // LookupKeys looks up the destinations of the keys provided. Returns a slice
// of destinations. If multiple keys hash to the same destination, they will
// be deduped. | [
"LookupKeys",
"looks",
"up",
"the",
"destinations",
"of",
"the",
"keys",
"provided",
".",
"Returns",
"a",
"slice",
"of",
"destinations",
".",
"If",
"multiple",
"keys",
"hash",
"to",
"the",
"same",
"destination",
"they",
"will",
"be",
"deduped",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/request_sender.go#L271-L290 |
21,082 | uber/ringpop-go | swim/stats.go | MemberStats | func (n *Node) MemberStats() MemberStats {
members := members(n.memberlist.GetMembers())
sort.Sort(&members)
return MemberStats{n.memberlist.Checksum(), members}
} | go | func (n *Node) MemberStats() MemberStats {
members := members(n.memberlist.GetMembers())
sort.Sort(&members)
return MemberStats{n.memberlist.Checksum(), members}
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"MemberStats",
"(",
")",
"MemberStats",
"{",
"members",
":=",
"members",
"(",
"n",
".",
"memberlist",
".",
"GetMembers",
"(",
")",
")",
"\n",
"sort",
".",
"Sort",
"(",
"&",
"members",
")",
"\n",
"return",
"MemberSt... | // MemberStats returns the current checksum of the node's memberlist and a slice
// of the members in the memberlist in lexographically sorted order by address | [
"MemberStats",
"returns",
"the",
"current",
"checksum",
"of",
"the",
"node",
"s",
"memberlist",
"and",
"a",
"slice",
"of",
"the",
"members",
"in",
"the",
"memberlist",
"in",
"lexographically",
"sorted",
"order",
"by",
"address"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/stats.go#L48-L52 |
21,083 | uber/ringpop-go | swim/stats.go | ProtocolStats | func (n *Node) ProtocolStats() ProtocolStats {
timing := n.gossip.ProtocolTiming()
return ProtocolStats{
Timing{
Type: "histogram",
Min: timing.Min(),
Max: timing.Max(),
Sum: timing.Sum(),
Variance: timing.Variance(),
Mean: timing.Mean(),
StdDev: timing.StdDev(),
Cou... | go | func (n *Node) ProtocolStats() ProtocolStats {
timing := n.gossip.ProtocolTiming()
return ProtocolStats{
Timing{
Type: "histogram",
Min: timing.Min(),
Max: timing.Max(),
Sum: timing.Sum(),
Variance: timing.Variance(),
Mean: timing.Mean(),
StdDev: timing.StdDev(),
Cou... | [
"func",
"(",
"n",
"*",
"Node",
")",
"ProtocolStats",
"(",
")",
"ProtocolStats",
"{",
"timing",
":=",
"n",
".",
"gossip",
".",
"ProtocolTiming",
"(",
")",
"\n",
"return",
"ProtocolStats",
"{",
"Timing",
"{",
"Type",
":",
"\"",
"\"",
",",
"Min",
":",
"... | // ProtocolStats returns stats about the node's SWIM protocol. | [
"ProtocolStats",
"returns",
"stats",
"about",
"the",
"node",
"s",
"SWIM",
"protocol",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/stats.go#L81-L104 |
21,084 | uber/ringpop-go | swim/stats.go | Uptime | func (n *Node) Uptime() time.Duration {
return time.Now().Sub(n.startTime)
} | go | func (n *Node) Uptime() time.Duration {
return time.Now().Sub(n.startTime)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Uptime",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"n",
".",
"startTime",
")",
"\n",
"}"
] | // Uptime returns the amount of time the node has been running for | [
"Uptime",
"returns",
"the",
"amount",
"of",
"time",
"the",
"node",
"has",
"been",
"running",
"for"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/stats.go#L107-L109 |
21,085 | uber/ringpop-go | router/router.go | New | func New(rp ringpop.Interface, f ClientFactory, ch *tchannel.Channel) Router {
r := &router{
ringpop: rp,
factory: f,
channel: ch,
clientCache: make(map[string]cacheEntry),
}
rp.AddListener(r)
return r
} | go | func New(rp ringpop.Interface, f ClientFactory, ch *tchannel.Channel) Router {
r := &router{
ringpop: rp,
factory: f,
channel: ch,
clientCache: make(map[string]cacheEntry),
}
rp.AddListener(r)
return r
} | [
"func",
"New",
"(",
"rp",
"ringpop",
".",
"Interface",
",",
"f",
"ClientFactory",
",",
"ch",
"*",
"tchannel",
".",
"Channel",
")",
"Router",
"{",
"r",
":=",
"&",
"router",
"{",
"ringpop",
":",
"rp",
",",
"factory",
":",
"f",
",",
"channel",
":",
"c... | // New creates an instance that validates the Router interface. A Router
// will be used to get implementations of service interfaces that implement a
// distributed microservice. | [
"New",
"creates",
"an",
"instance",
"that",
"validates",
"the",
"Router",
"interface",
".",
"A",
"Router",
"will",
"be",
"used",
"to",
"get",
"implementations",
"of",
"service",
"interfaces",
"that",
"implement",
"a",
"distributed",
"microservice",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/router/router.go#L73-L83 |
21,086 | uber/ringpop-go | router/router.go | GetClient | func (r *router) GetClient(key string) (client interface{}, isRemote bool, err error) {
dest, err := r.ringpop.Lookup(key)
if err != nil {
return nil, false, err
}
return r.getClientByHost(dest)
} | go | func (r *router) GetClient(key string) (client interface{}, isRemote bool, err error) {
dest, err := r.ringpop.Lookup(key)
if err != nil {
return nil, false, err
}
return r.getClientByHost(dest)
} | [
"func",
"(",
"r",
"*",
"router",
")",
"GetClient",
"(",
"key",
"string",
")",
"(",
"client",
"interface",
"{",
"}",
",",
"isRemote",
"bool",
",",
"err",
"error",
")",
"{",
"dest",
",",
"err",
":=",
"r",
".",
"ringpop",
".",
"Lookup",
"(",
"key",
... | // Get the client for a certain destination from our internal cache, or
// delegates the creation to the ClientFactory. | [
"Get",
"the",
"client",
"for",
"a",
"certain",
"destination",
"from",
"our",
"internal",
"cache",
"or",
"delegates",
"the",
"creation",
"to",
"the",
"ClientFactory",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/router/router.go#L103-L110 |
21,087 | uber/ringpop-go | swim/ping_request_sender.go | newPingRequestSender | func newPingRequestSender(node *Node, peer, target string, timeout time.Duration) *pingRequestSender {
p := &pingRequestSender{
node: node,
peer: peer,
target: target,
timeout: timeout,
logger: logging.Logger("ping").WithField("local", node.Address()),
}
return p
} | go | func newPingRequestSender(node *Node, peer, target string, timeout time.Duration) *pingRequestSender {
p := &pingRequestSender{
node: node,
peer: peer,
target: target,
timeout: timeout,
logger: logging.Logger("ping").WithField("local", node.Address()),
}
return p
} | [
"func",
"newPingRequestSender",
"(",
"node",
"*",
"Node",
",",
"peer",
",",
"target",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"*",
"pingRequestSender",
"{",
"p",
":=",
"&",
"pingRequestSender",
"{",
"node",
":",
"node",
",",
"peer",
":",
... | // NewPingRequestSender returns a new PingRequestSender | [
"NewPingRequestSender",
"returns",
"a",
"new",
"PingRequestSender"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/ping_request_sender.go#L53-L63 |
21,088 | uber/ringpop-go | swim/ping_request_sender.go | indirectPing | func indirectPing(n *Node, target string, amount int, timeout time.Duration) (reached bool, errs []error) {
resCh := sendPingRequests(n, target, amount, timeout)
// wait for responses from the ping-reqs
for result := range resCh {
switch res := result.(type) {
case *pingResponse:
if res.Ok {
return true,... | go | func indirectPing(n *Node, target string, amount int, timeout time.Duration) (reached bool, errs []error) {
resCh := sendPingRequests(n, target, amount, timeout)
// wait for responses from the ping-reqs
for result := range resCh {
switch res := result.(type) {
case *pingResponse:
if res.Ok {
return true,... | [
"func",
"indirectPing",
"(",
"n",
"*",
"Node",
",",
"target",
"string",
",",
"amount",
"int",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"reached",
"bool",
",",
"errs",
"[",
"]",
"error",
")",
"{",
"resCh",
":=",
"sendPingRequests",
"(",
"n",
... | // indirectPing is used to check if a target node can be reached indirectly.
// The indirectPing is performed by sending a specifiable amount of ping
// requests nodes in n's membership. | [
"indirectPing",
"is",
"used",
"to",
"check",
"if",
"a",
"target",
"node",
"can",
"be",
"reached",
"indirectly",
".",
"The",
"indirectPing",
"is",
"performed",
"by",
"sending",
"a",
"specifiable",
"amount",
"of",
"ping",
"requests",
"nodes",
"in",
"n",
"s",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/ping_request_sender.go#L120-L138 |
21,089 | uber/ringpop-go | forward/forwarder.go | NewForwarder | func NewForwarder(s Sender, ch shared.SubChannel) *Forwarder {
logger := logging.Logger("forwarder")
if address, err := s.WhoAmI(); err == nil {
logger = logger.WithField("local", address)
}
return &Forwarder{
sender: s,
channel: ch,
logger: logger,
}
} | go | func NewForwarder(s Sender, ch shared.SubChannel) *Forwarder {
logger := logging.Logger("forwarder")
if address, err := s.WhoAmI(); err == nil {
logger = logger.WithField("local", address)
}
return &Forwarder{
sender: s,
channel: ch,
logger: logger,
}
} | [
"func",
"NewForwarder",
"(",
"s",
"Sender",
",",
"ch",
"shared",
".",
"SubChannel",
")",
"*",
"Forwarder",
"{",
"logger",
":=",
"logging",
".",
"Logger",
"(",
"\"",
"\"",
")",
"\n",
"if",
"address",
",",
"err",
":=",
"s",
".",
"WhoAmI",
"(",
")",
"... | // NewForwarder returns a new forwarder | [
"NewForwarder",
"returns",
"a",
"new",
"forwarder"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/forwarder.go#L102-L114 |
21,090 | uber/ringpop-go | forward/forwarder.go | ForwardRequest | func (f *Forwarder) ForwardRequest(request []byte, destination, service, endpoint string,
keys []string, format tchannel.Format, opts *Options) ([]byte, error) {
f.EmitEvent(RequestForwardedEvent{})
f.incrementInflight()
opts = f.mergeDefaultOptions(opts)
rs := newRequestSender(f.sender, f, f.channel, request, k... | go | func (f *Forwarder) ForwardRequest(request []byte, destination, service, endpoint string,
keys []string, format tchannel.Format, opts *Options) ([]byte, error) {
f.EmitEvent(RequestForwardedEvent{})
f.incrementInflight()
opts = f.mergeDefaultOptions(opts)
rs := newRequestSender(f.sender, f, f.channel, request, k... | [
"func",
"(",
"f",
"*",
"Forwarder",
")",
"ForwardRequest",
"(",
"request",
"[",
"]",
"byte",
",",
"destination",
",",
"service",
",",
"endpoint",
"string",
",",
"keys",
"[",
"]",
"string",
",",
"format",
"tchannel",
".",
"Format",
",",
"opts",
"*",
"Op... | // ForwardRequest forwards a request to the given service and endpoint returns the response.
// Keys are used by the sender to lookup the destination on retry. If you have multiple keys
// and their destinations diverge on a retry then the call is aborted. | [
"ForwardRequest",
"forwards",
"a",
"request",
"to",
"the",
"given",
"service",
"and",
"endpoint",
"returns",
"the",
"response",
".",
"Keys",
"are",
"used",
"by",
"the",
"sender",
"to",
"lookup",
"the",
"destination",
"on",
"retry",
".",
"If",
"you",
"have",
... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/forwarder.go#L147-L165 |
21,091 | uber/ringpop-go | forward/forwarder.go | SetForwardedHeader | func SetForwardedHeader(ctx thrift.Context, keys []string) thrift.Context {
// copy headers to make sure two calls do not leak headers to each other
headers := make(map[string]string, len(ctx.Headers())+1)
for key, value := range ctx.Headers() {
headers[key] = value
}
if keys == nil {
// prevent null serializ... | go | func SetForwardedHeader(ctx thrift.Context, keys []string) thrift.Context {
// copy headers to make sure two calls do not leak headers to each other
headers := make(map[string]string, len(ctx.Headers())+1)
for key, value := range ctx.Headers() {
headers[key] = value
}
if keys == nil {
// prevent null serializ... | [
"func",
"SetForwardedHeader",
"(",
"ctx",
"thrift",
".",
"Context",
",",
"keys",
"[",
"]",
"string",
")",
"thrift",
".",
"Context",
"{",
"// copy headers to make sure two calls do not leak headers to each other",
"headers",
":=",
"make",
"(",
"map",
"[",
"string",
"... | // SetForwardedHeader adds a header to the current thrift context indicating
// that the call has been forwarded by another node in the ringpop ring. This
// header is used when a remote call is received to determine if forwarding
// checks needs to be applied. By not forwarding already forwarded calls we
// prevent un... | [
"SetForwardedHeader",
"adds",
"a",
"header",
"to",
"the",
"current",
"thrift",
"context",
"indicating",
"that",
"the",
"call",
"has",
"been",
"forwarded",
"by",
"another",
"node",
"in",
"the",
"ringpop",
"ring",
".",
"This",
"header",
"is",
"used",
"when",
"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/forwarder.go#L181-L200 |
21,092 | uber/ringpop-go | forward/forwarder.go | DeleteForwardedHeader | func DeleteForwardedHeader(ctx thrift.Context) bool {
_, ok := ctx.Headers()[ForwardedHeaderName]
if ok {
delete(ctx.Headers(), ForwardedHeaderName)
}
return ok
} | go | func DeleteForwardedHeader(ctx thrift.Context) bool {
_, ok := ctx.Headers()[ForwardedHeaderName]
if ok {
delete(ctx.Headers(), ForwardedHeaderName)
}
return ok
} | [
"func",
"DeleteForwardedHeader",
"(",
"ctx",
"thrift",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Headers",
"(",
")",
"[",
"ForwardedHeaderName",
"]",
"\n",
"if",
"ok",
"{",
"delete",
"(",
"ctx",
".",
"Headers",
"(",
")",
",... | // DeleteForwardedHeader takes the headers that came in via TChannel and looks
// for the precense of a specific ringpop header to see if ringpop already
// forwarded the message. If the header is present it will delete the header
// from the context. The return value indicates if the header was present and
// deleted | [
"DeleteForwardedHeader",
"takes",
"the",
"headers",
"that",
"came",
"in",
"via",
"TChannel",
"and",
"looks",
"for",
"the",
"precense",
"of",
"a",
"specific",
"ringpop",
"header",
"to",
"see",
"if",
"ringpop",
"already",
"forwarded",
"the",
"message",
".",
"If"... | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/forward/forwarder.go#L207-L213 |
21,093 | uber/ringpop-go | swim/state_transitions.go | newStateTransitions | func newStateTransitions(n *Node, timeouts StateTimeouts) *stateTransitions {
return &stateTransitions{
node: n,
timeouts: timeouts,
timers: make(map[string]*transitionTimer),
enabled: true,
logger: logging.Logger("stateTransitions").WithField("local", n.Address()),
}
} | go | func newStateTransitions(n *Node, timeouts StateTimeouts) *stateTransitions {
return &stateTransitions{
node: n,
timeouts: timeouts,
timers: make(map[string]*transitionTimer),
enabled: true,
logger: logging.Logger("stateTransitions").WithField("local", n.Address()),
}
} | [
"func",
"newStateTransitions",
"(",
"n",
"*",
"Node",
",",
"timeouts",
"StateTimeouts",
")",
"*",
"stateTransitions",
"{",
"return",
"&",
"stateTransitions",
"{",
"node",
":",
"n",
",",
"timeouts",
":",
"timeouts",
",",
"timers",
":",
"make",
"(",
"map",
"... | // newStateTransitions returns a new state transition controller that can be used to schedule state transitions for nodes | [
"newStateTransitions",
"returns",
"a",
"new",
"state",
"transition",
"controller",
"that",
"can",
"be",
"used",
"to",
"schedule",
"state",
"transitions",
"for",
"nodes"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L79-L87 |
21,094 | uber/ringpop-go | swim/state_transitions.go | ScheduleSuspectToFaulty | func (s *stateTransitions) ScheduleSuspectToFaulty(subject subject) {
s.Lock()
s.schedule(subject, Suspect, s.timeouts.Suspect, func() {
// transition the subject to faulty
s.node.memberlist.MakeFaulty(subject.address(), subject.incarnation())
})
s.Unlock()
} | go | func (s *stateTransitions) ScheduleSuspectToFaulty(subject subject) {
s.Lock()
s.schedule(subject, Suspect, s.timeouts.Suspect, func() {
// transition the subject to faulty
s.node.memberlist.MakeFaulty(subject.address(), subject.incarnation())
})
s.Unlock()
} | [
"func",
"(",
"s",
"*",
"stateTransitions",
")",
"ScheduleSuspectToFaulty",
"(",
"subject",
"subject",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"schedule",
"(",
"subject",
",",
"Suspect",
",",
"s",
".",
"timeouts",
".",
"Suspect",
",",
"fun... | // ScheduleSuspectToFaulty starts the suspect timer. After the Suspect timeout the node will be declared faulty | [
"ScheduleSuspectToFaulty",
"starts",
"the",
"suspect",
"timer",
".",
"After",
"the",
"Suspect",
"timeout",
"the",
"node",
"will",
"be",
"declared",
"faulty"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L90-L97 |
21,095 | uber/ringpop-go | swim/state_transitions.go | ScheduleFaultyToTombstone | func (s *stateTransitions) ScheduleFaultyToTombstone(subject subject) {
s.Lock()
s.schedule(subject, Faulty, s.timeouts.Faulty, func() {
// transition the subject to tombstone
s.node.memberlist.MakeTombstone(subject.address(), subject.incarnation())
})
s.Unlock()
} | go | func (s *stateTransitions) ScheduleFaultyToTombstone(subject subject) {
s.Lock()
s.schedule(subject, Faulty, s.timeouts.Faulty, func() {
// transition the subject to tombstone
s.node.memberlist.MakeTombstone(subject.address(), subject.incarnation())
})
s.Unlock()
} | [
"func",
"(",
"s",
"*",
"stateTransitions",
")",
"ScheduleFaultyToTombstone",
"(",
"subject",
"subject",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"schedule",
"(",
"subject",
",",
"Faulty",
",",
"s",
".",
"timeouts",
".",
"Faulty",
",",
"fun... | // ScheduleFaultyToTombstone starts the faulty timer. After the Faulty timeout the node will be declared tombstone | [
"ScheduleFaultyToTombstone",
"starts",
"the",
"faulty",
"timer",
".",
"After",
"the",
"Faulty",
"timeout",
"the",
"node",
"will",
"be",
"declared",
"tombstone"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L100-L107 |
21,096 | uber/ringpop-go | swim/state_transitions.go | ScheduleTombstoneToEvict | func (s *stateTransitions) ScheduleTombstoneToEvict(subject subject) {
s.Lock()
s.schedule(subject, Tombstone, s.timeouts.Tombstone, func() {
// transition the subject to tombstone
s.node.memberlist.Evict(subject.address())
})
s.Unlock()
} | go | func (s *stateTransitions) ScheduleTombstoneToEvict(subject subject) {
s.Lock()
s.schedule(subject, Tombstone, s.timeouts.Tombstone, func() {
// transition the subject to tombstone
s.node.memberlist.Evict(subject.address())
})
s.Unlock()
} | [
"func",
"(",
"s",
"*",
"stateTransitions",
")",
"ScheduleTombstoneToEvict",
"(",
"subject",
"subject",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"schedule",
"(",
"subject",
",",
"Tombstone",
",",
"s",
".",
"timeouts",
".",
"Tombstone",
",",
... | // ScheduleTombstoneToEvict starts the tombstone timer. After the Faulty timeout the node will be evicted | [
"ScheduleTombstoneToEvict",
"starts",
"the",
"tombstone",
"timer",
".",
"After",
"the",
"Faulty",
"timeout",
"the",
"node",
"will",
"be",
"evicted"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L110-L117 |
21,097 | uber/ringpop-go | swim/state_transitions.go | Cancel | func (s *stateTransitions) Cancel(subject subject) {
s.Lock()
if timer, ok := s.timers[subject.address()]; ok {
timer.Stop()
delete(s.timers, subject.address())
s.logger.WithFields(bark.Fields{
"member": subject.address(),
"state": timer.state,
}).Debug("stopped scheduled state transition for member")... | go | func (s *stateTransitions) Cancel(subject subject) {
s.Lock()
if timer, ok := s.timers[subject.address()]; ok {
timer.Stop()
delete(s.timers, subject.address())
s.logger.WithFields(bark.Fields{
"member": subject.address(),
"state": timer.state,
}).Debug("stopped scheduled state transition for member")... | [
"func",
"(",
"s",
"*",
"stateTransitions",
")",
"Cancel",
"(",
"subject",
"subject",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n\n",
"if",
"timer",
",",
"ok",
":=",
"s",
".",
"timers",
"[",
"subject",
".",
"address",
"(",
")",
"]",
";",
"ok",
"{",
... | // Cancel cancels the scheduled transition for the subject | [
"Cancel",
"cancels",
"the",
"scheduled",
"transition",
"for",
"the",
"subject"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L163-L176 |
21,098 | uber/ringpop-go | swim/state_transitions.go | Enable | func (s *stateTransitions) Enable() {
s.Lock()
if s.enabled {
s.logger.Warn("state transition controller already enabled")
s.Unlock()
return
}
s.enabled = true
s.Unlock()
s.logger.Info("enabled state transition controller")
} | go | func (s *stateTransitions) Enable() {
s.Lock()
if s.enabled {
s.logger.Warn("state transition controller already enabled")
s.Unlock()
return
}
s.enabled = true
s.Unlock()
s.logger.Info("enabled state transition controller")
} | [
"func",
"(",
"s",
"*",
"stateTransitions",
")",
"Enable",
"(",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n\n",
"if",
"s",
".",
"enabled",
"{",
"s",
".",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"s",
".",
"Unlock",
"(",
")",
"\n",
"ret... | // Enable enables state transition controller. The transition controller needs to be in enabled state to allow transitions to be scheduled. | [
"Enable",
"enables",
"state",
"transition",
"controller",
".",
"The",
"transition",
"controller",
"needs",
"to",
"be",
"in",
"enabled",
"state",
"to",
"allow",
"transitions",
"to",
"be",
"scheduled",
"."
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L179-L191 |
21,099 | uber/ringpop-go | swim/state_transitions.go | Disable | func (s *stateTransitions) Disable() {
s.Lock()
if !s.enabled {
s.logger.Warn("state transition controller already disabled")
s.Unlock()
return
}
s.enabled = false
numTimers := len(s.timers)
for address, timer := range s.timers {
timer.Stop()
delete(s.timers, address)
}
s.Unlock()
s.logger.WithFi... | go | func (s *stateTransitions) Disable() {
s.Lock()
if !s.enabled {
s.logger.Warn("state transition controller already disabled")
s.Unlock()
return
}
s.enabled = false
numTimers := len(s.timers)
for address, timer := range s.timers {
timer.Stop()
delete(s.timers, address)
}
s.Unlock()
s.logger.WithFi... | [
"func",
"(",
"s",
"*",
"stateTransitions",
")",
"Disable",
"(",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n\n",
"if",
"!",
"s",
".",
"enabled",
"{",
"s",
".",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"s",
".",
"Unlock",
"(",
")",
"\n"... | // Disable cancels all scheduled state transitions and disables the state transition controller for further use | [
"Disable",
"cancels",
"all",
"scheduled",
"state",
"transitions",
"and",
"disables",
"the",
"state",
"transition",
"controller",
"for",
"further",
"use"
] | 6475220d53092c8264fc6ce9416a351c960fe9fc | https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/state_transitions.go#L194-L213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.