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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
143,000
hashicorp/go-getter
checksum.go
checksum
func (c *fileChecksum) checksum(source string) error { f, err := os.Open(source) if err != nil { return fmt.Errorf("Failed to open file for checksum: %s", err) } defer f.Close() c.Hash.Reset() if _, err := io.Copy(c.Hash, f); err != nil { return fmt.Errorf("Failed to hash: %s", err) } if actual := c.Hash....
go
func (c *fileChecksum) checksum(source string) error { f, err := os.Open(source) if err != nil { return fmt.Errorf("Failed to open file for checksum: %s", err) } defer f.Close() c.Hash.Reset() if _, err := io.Copy(c.Hash, f); err != nil { return fmt.Errorf("Failed to hash: %s", err) } if actual := c.Hash....
[ "func", "(", "c", "*", "fileChecksum", ")", "checksum", "(", "source", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\""...
// checksum is a simple method to compute the checksum of a source file // and compare it to the given expected value.
[ "checksum", "is", "a", "simple", "method", "to", "compute", "the", "checksum", "of", "a", "source", "file", "and", "compare", "it", "to", "the", "given", "expected", "value", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/checksum.go#L53-L75
143,001
hashicorp/go-getter
checksum.go
checksumFromFile
func (c *Client) checksumFromFile(checksumFile string, src *url.URL) (*fileChecksum, error) { checksumFileURL, err := urlhelper.Parse(checksumFile) if err != nil { return nil, err } tempfile, err := tmpFile("", filepath.Base(checksumFileURL.Path)) if err != nil { return nil, err } defer os.Remove(tempfile) ...
go
func (c *Client) checksumFromFile(checksumFile string, src *url.URL) (*fileChecksum, error) { checksumFileURL, err := urlhelper.Parse(checksumFile) if err != nil { return nil, err } tempfile, err := tmpFile("", filepath.Base(checksumFileURL.Path)) if err != nil { return nil, err } defer os.Remove(tempfile) ...
[ "func", "(", "c", "*", "Client", ")", "checksumFromFile", "(", "checksumFile", "string", ",", "src", "*", "url", ".", "URL", ")", "(", "*", "fileChecksum", ",", "error", ")", "{", "checksumFileURL", ",", "err", ":=", "urlhelper", ".", "Parse", "(", "ch...
// checksumsFromFile will return all the fileChecksums found in file // // checksumsFromFile will try to guess the hashing algorithm based on content // of checksum file // // checksumsFromFile will only return checksums for files that match file // behind src
[ "checksumsFromFile", "will", "return", "all", "the", "fileChecksums", "found", "in", "file", "checksumsFromFile", "will", "try", "to", "guess", "the", "hashing", "algorithm", "based", "on", "content", "of", "checksum", "file", "checksumsFromFile", "will", "only", ...
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/checksum.go#L193-L281
143,002
hashicorp/go-getter
checksum.go
parseChecksumLine
func parseChecksumLine(line string) (*fileChecksum, error) { parts := strings.Fields(line) switch len(parts) { case 4: // BSD-style checksum: // MD5 (file1) = <checksum> // MD5 (file2) = <checksum> if len(parts[1]) <= 2 || parts[1][0] != '(' || parts[1][len(parts[1])-1] != ')' { return nil, fmt.Erro...
go
func parseChecksumLine(line string) (*fileChecksum, error) { parts := strings.Fields(line) switch len(parts) { case 4: // BSD-style checksum: // MD5 (file1) = <checksum> // MD5 (file2) = <checksum> if len(parts[1]) <= 2 || parts[1][0] != '(' || parts[1][len(parts[1])-1] != ')' { return nil, fmt.Erro...
[ "func", "parseChecksumLine", "(", "line", "string", ")", "(", "*", "fileChecksum", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Fields", "(", "line", ")", "\n\n", "switch", "len", "(", "parts", ")", "{", "case", "4", ":", "// BSD-style checksu...
// parseChecksumLine takes a line from a checksum file and returns // checksumType, checksumValue and filename parseChecksumLine guesses the style // of the checksum BSD vs GNU by splitting the line and by counting the parts. // of a line. // for BSD type sums parseChecksumLine guesses the hashing algorithm // by check...
[ "parseChecksumLine", "takes", "a", "line", "from", "a", "checksum", "file", "and", "returns", "checksumType", "checksumValue", "and", "filename", "parseChecksumLine", "guesses", "the", "style", "of", "the", "checksum", "BSD", "vs", "GNU", "by", "splitting", "the",...
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/checksum.go#L289-L314
143,003
yanzay/tbot
server.go
WithHTTPClient
func WithHTTPClient(client *http.Client) ServerOption { return func(s *Server) { s.httpClient = client } }
go
func WithHTTPClient(client *http.Client) ServerOption { return func(s *Server) { s.httpClient = client } }
[ "func", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "{", "s", ".", "httpClient", "=", "client", "\n", "}", "\n", "}" ]
// WithHTTPClient sets custom http client for server.
[ "WithHTTPClient", "sets", "custom", "http", "client", "for", "server", "." ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/server.go#L99-L103
143,004
yanzay/tbot
server.go
Use
func (s *Server) Use(m Middleware) { s.middlewares = append(s.middlewares, m) }
go
func (s *Server) Use(m Middleware) { s.middlewares = append(s.middlewares, m) }
[ "func", "(", "s", "*", "Server", ")", "Use", "(", "m", "Middleware", ")", "{", "s", ".", "middlewares", "=", "append", "(", "s", ".", "middlewares", ",", "m", ")", "\n", "}" ]
// Use adds middleware to server
[ "Use", "adds", "middleware", "to", "server" ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/server.go#L113-L115
143,005
yanzay/tbot
server.go
Start
func (s *Server) Start() error { if len(s.token) == 0 { return fmt.Errorf("token is empty") } updates, err := s.getUpdates() if err != nil { return err } for { select { case update := <-updates: handleUpdate := func(update *Update) { switch { case update.Message != nil: s.handleMessage(upd...
go
func (s *Server) Start() error { if len(s.token) == 0 { return fmt.Errorf("token is empty") } updates, err := s.getUpdates() if err != nil { return err } for { select { case update := <-updates: handleUpdate := func(update *Update) { switch { case update.Message != nil: s.handleMessage(upd...
[ "func", "(", "s", "*", "Server", ")", "Start", "(", ")", "error", "{", "if", "len", "(", "s", ".", "token", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "updates", ",", "err", ":=", "s", ".", "...
// Start listening for updates
[ "Start", "listening", "for", "updates" ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/server.go#L118-L162
143,006
yanzay/tbot
server.go
HandleMessage
func (s *Server) HandleMessage(pattern string, handler func(*Message)) { rx := regexp.MustCompile(pattern) s.messageHandlers = append(s.messageHandlers, messageHandler{rx: rx, f: handler}) }
go
func (s *Server) HandleMessage(pattern string, handler func(*Message)) { rx := regexp.MustCompile(pattern) s.messageHandlers = append(s.messageHandlers, messageHandler{rx: rx, f: handler}) }
[ "func", "(", "s", "*", "Server", ")", "HandleMessage", "(", "pattern", "string", ",", "handler", "func", "(", "*", "Message", ")", ")", "{", "rx", ":=", "regexp", ".", "MustCompile", "(", "pattern", ")", "\n", "s", ".", "messageHandlers", "=", "append"...
// HandleMessage sets handler for incoming messages
[ "HandleMessage", "sets", "handler", "for", "incoming", "messages" ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/server.go#L259-L262
143,007
yanzay/tbot
client.go
NewClient
func NewClient(token string, httpClient *http.Client, baseURL string) *Client { return &Client{ token: token, httpClient: httpClient, url: fmt.Sprintf("%s/bot%s/", baseURL, token) + "%s", } }
go
func NewClient(token string, httpClient *http.Client, baseURL string) *Client { return &Client{ token: token, httpClient: httpClient, url: fmt.Sprintf("%s/bot%s/", baseURL, token) + "%s", } }
[ "func", "NewClient", "(", "token", "string", ",", "httpClient", "*", "http", ".", "Client", ",", "baseURL", "string", ")", "*", "Client", "{", "return", "&", "Client", "{", "token", ":", "token", ",", "httpClient", ":", "httpClient", ",", "url", ":", "...
// NewClient creates new Telegram API client
[ "NewClient", "creates", "new", "Telegram", "API", "client" ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/client.go#L25-L31
143,008
yanzay/tbot
client.go
GetMe
func (c *Client) GetMe() (*User, error) { me := &User{} err := c.doRequest("getMe", nil, me) return me, err }
go
func (c *Client) GetMe() (*User, error) { me := &User{} err := c.doRequest("getMe", nil, me) return me, err }
[ "func", "(", "c", "*", "Client", ")", "GetMe", "(", ")", "(", "*", "User", ",", "error", ")", "{", "me", ":=", "&", "User", "{", "}", "\n", "err", ":=", "c", ".", "doRequest", "(", "\"", "\"", ",", "nil", ",", "me", ")", "\n", "return", "me...
// GetMe returns info about bot as a User object
[ "GetMe", "returns", "info", "about", "bot", "as", "a", "User", "object" ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/client.go#L64-L68
143,009
yanzay/tbot
client.go
SendMediaGroup
func (c *Client) SendMediaGroup(chatID string, media []InputMedia, opts ...sendOption) ([]*Message, error) { req := url.Values{} req.Set("chat_id", chatID) m, _ := json.Marshal(media) req.Set("media", string(m)) for _, opt := range opts { opt(req) } var msgs []*Message err := c.doRequest("sendMediaGroup", req...
go
func (c *Client) SendMediaGroup(chatID string, media []InputMedia, opts ...sendOption) ([]*Message, error) { req := url.Values{} req.Set("chat_id", chatID) m, _ := json.Marshal(media) req.Set("media", string(m)) for _, opt := range opts { opt(req) } var msgs []*Message err := c.doRequest("sendMediaGroup", req...
[ "func", "(", "c", "*", "Client", ")", "SendMediaGroup", "(", "chatID", "string", ",", "media", "[", "]", "InputMedia", ",", "opts", "...", "sendOption", ")", "(", "[", "]", "*", "Message", ",", "error", ")", "{", "req", ":=", "url", ".", "Values", ...
// SendMediaGroup send a group of photos or videos as an album
[ "SendMediaGroup", "send", "a", "group", "of", "photos", "or", "videos", "as", "an", "album" ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/client.go#L699-L710
143,010
yanzay/tbot
helpers.go
Buttons
func Buttons(buttons [][]string) *ReplyKeyboardMarkup { keyboard := make([][]KeyboardButton, len(buttons)) for i := range buttons { keyboard[i] = make([]KeyboardButton, len(buttons[i])) for j := range buttons[i] { keyboard[i][j] = KeyboardButton{Text: buttons[i][j]} } } return &ReplyKeyboardMarkup{Keyboard...
go
func Buttons(buttons [][]string) *ReplyKeyboardMarkup { keyboard := make([][]KeyboardButton, len(buttons)) for i := range buttons { keyboard[i] = make([]KeyboardButton, len(buttons[i])) for j := range buttons[i] { keyboard[i][j] = KeyboardButton{Text: buttons[i][j]} } } return &ReplyKeyboardMarkup{Keyboard...
[ "func", "Buttons", "(", "buttons", "[", "]", "[", "]", "string", ")", "*", "ReplyKeyboardMarkup", "{", "keyboard", ":=", "make", "(", "[", "]", "[", "]", "KeyboardButton", ",", "len", "(", "buttons", ")", ")", "\n", "for", "i", ":=", "range", "button...
// Buttons construct ReplyKeyboardMarkup from strings
[ "Buttons", "construct", "ReplyKeyboardMarkup", "from", "strings" ]
f0e9ff0b2e656aa7e3348a3ef59e568d87538c77
https://github.com/yanzay/tbot/blob/f0e9ff0b2e656aa7e3348a3ef59e568d87538c77/helpers.go#L4-L13
143,011
uber/ringpop-go
swim/gossip.go
newGossip
func newGossip(node *Node, minProtocolPeriod time.Duration) *gossip { gossip := &gossip{ node: node, minProtocolPeriod: minProtocolPeriod, logger: logging.Logger("gossip").WithField("local", node.Address()), } gossip.protocol.timing = metrics.NewHistogram(metrics.NewUniformSample(10)) ...
go
func newGossip(node *Node, minProtocolPeriod time.Duration) *gossip { gossip := &gossip{ node: node, minProtocolPeriod: minProtocolPeriod, logger: logging.Logger("gossip").WithField("local", node.Address()), } gossip.protocol.timing = metrics.NewHistogram(metrics.NewUniformSample(10)) ...
[ "func", "newGossip", "(", "node", "*", "Node", ",", "minProtocolPeriod", "time", ".", "Duration", ")", "*", "gossip", "{", "gossip", ":=", "&", "gossip", "{", "node", ":", "node", ",", "minProtocolPeriod", ":", "minProtocolPeriod", ",", "logger", ":", "log...
// newGossip returns a new gossip SWIM sub-protocol with the given protocol period
[ "newGossip", "returns", "a", "new", "gossip", "SWIM", "sub", "-", "protocol", "with", "the", "given", "protocol", "period" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/gossip.go#L62-L73
143,012
uber/ringpop-go
swim/gossip.go
ComputeProtocolDelay
func (g *gossip) ComputeProtocolDelay() time.Duration { g.protocol.RLock() defer g.protocol.RUnlock() var delay time.Duration if g.protocol.numPeriods != 0 { target := g.protocol.lastPeriod.Add(g.protocol.lastRate) delay = time.Duration(math.Max(float64(target.Sub(time.Now())), float64(g.minProtocolPeriod))) ...
go
func (g *gossip) ComputeProtocolDelay() time.Duration { g.protocol.RLock() defer g.protocol.RUnlock() var delay time.Duration if g.protocol.numPeriods != 0 { target := g.protocol.lastPeriod.Add(g.protocol.lastRate) delay = time.Duration(math.Max(float64(target.Sub(time.Now())), float64(g.minProtocolPeriod))) ...
[ "func", "(", "g", "*", "gossip", ")", "ComputeProtocolDelay", "(", ")", "time", ".", "Duration", "{", "g", ".", "protocol", ".", "RLock", "(", ")", "\n", "defer", "g", ".", "protocol", ".", "RUnlock", "(", ")", "\n\n", "var", "delay", "time", ".", ...
// computes a delay for the gossip protocol period
[ "computes", "a", "delay", "for", "the", "gossip", "protocol", "period" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/gossip.go#L76-L94
143,013
uber/ringpop-go
swim/gossip.go
AdjustProtocolRate
func (g *gossip) AdjustProtocolRate() { g.protocol.Lock() observed := g.protocol.timing.Percentile(0.5) * 2.0 g.protocol.lastRate = time.Duration(math.Max(observed, float64(g.minProtocolPeriod))) g.protocol.Unlock() }
go
func (g *gossip) AdjustProtocolRate() { g.protocol.Lock() observed := g.protocol.timing.Percentile(0.5) * 2.0 g.protocol.lastRate = time.Duration(math.Max(observed, float64(g.minProtocolPeriod))) g.protocol.Unlock() }
[ "func", "(", "g", "*", "gossip", ")", "AdjustProtocolRate", "(", ")", "{", "g", ".", "protocol", ".", "Lock", "(", ")", "\n", "observed", ":=", "g", ".", "protocol", ".", "timing", ".", "Percentile", "(", "0.5", ")", "*", "2.0", "\n", "g", ".", "...
// computes a ProtocolRate for the Gossip
[ "computes", "a", "ProtocolRate", "for", "the", "Gossip" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/gossip.go#L105-L110
143,014
uber/ringpop-go
swim/gossip.go
Start
func (g *gossip) Start() { g.state.Lock() defer g.state.Unlock() if g.state.running { g.logger.Warn("gossip already started") return } // mark the state to be running g.state.running = true // schedule repeat execution in the background g.state.protocolPeriodStop, g.state.protocolPeriodWait = scheduleRep...
go
func (g *gossip) Start() { g.state.Lock() defer g.state.Unlock() if g.state.running { g.logger.Warn("gossip already started") return } // mark the state to be running g.state.running = true // schedule repeat execution in the background g.state.protocolPeriodStop, g.state.protocolPeriodWait = scheduleRep...
[ "func", "(", "g", "*", "gossip", ")", "Start", "(", ")", "{", "g", ".", "state", ".", "Lock", "(", ")", "\n", "defer", "g", ".", "state", ".", "Unlock", "(", ")", "\n\n", "if", "g", ".", "state", ".", "running", "{", "g", ".", "logger", ".", ...
// start the gossip protocol
[ "start", "the", "gossip", "protocol" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/gossip.go#L121-L140
143,015
uber/ringpop-go
swim/gossip.go
Stop
func (g *gossip) Stop() { g.state.Lock() defer g.state.Unlock() if !g.state.running { g.logger.Warn("gossip already stopped") return } g.state.running = false // stop background execution of running tasks close(g.state.protocolPeriodStop) close(g.state.protocolRateChannel) // wait for the goroutine to ...
go
func (g *gossip) Stop() { g.state.Lock() defer g.state.Unlock() if !g.state.running { g.logger.Warn("gossip already stopped") return } g.state.running = false // stop background execution of running tasks close(g.state.protocolPeriodStop) close(g.state.protocolRateChannel) // wait for the goroutine to ...
[ "func", "(", "g", "*", "gossip", ")", "Stop", "(", ")", "{", "g", ".", "state", ".", "Lock", "(", ")", "\n", "defer", "g", ".", "state", ".", "Unlock", "(", ")", "\n\n", "if", "!", "g", ".", "state", ".", "running", "{", "g", ".", "logger", ...
// stop the gossip protocol
[ "stop", "the", "gossip", "protocol" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/gossip.go#L143-L162
143,016
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
143,017
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
143,018
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
143,019
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
143,020
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
143,021
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
143,022
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
143,023
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
143,024
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
143,025
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
143,026
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
143,027
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
143,028
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
143,029
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
143,030
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
143,031
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
143,032
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
143,033
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
143,034
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
143,035
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
143,036
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
143,037
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
143,038
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
143,039
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
143,040
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
143,041
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
143,042
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
143,043
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
143,044
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
143,045
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
143,046
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
143,047
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
143,048
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
143,049
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
143,050
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
143,051
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
143,052
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
143,053
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
143,054
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
143,055
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
143,056
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
143,057
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
143,058
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
143,059
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
143,060
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
143,061
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
143,062
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
143,063
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
143,064
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
143,065
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
143,066
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
143,067
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
143,068
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
143,069
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
143,070
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
143,071
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
143,072
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
143,073
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
143,074
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
143,075
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
143,076
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
143,077
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
143,078
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
143,079
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
143,080
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
143,081
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
143,082
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
143,083
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
143,084
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
143,085
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
143,086
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
143,087
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
143,088
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
143,089
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
143,090
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
143,091
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
143,092
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
143,093
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
143,094
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
143,095
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
143,096
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
143,097
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
143,098
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
143,099
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