repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
etcd-io/etcd
clientv3/compare.go
WithPrefix
func (cmp Cmp) WithPrefix() Cmp { cmp.RangeEnd = getPrefix(cmp.Key) return cmp }
go
func (cmp Cmp) WithPrefix() Cmp { cmp.RangeEnd = getPrefix(cmp.Key) return cmp }
[ "func", "(", "cmp", "Cmp", ")", "WithPrefix", "(", ")", "Cmp", "{", "cmp", ".", "RangeEnd", "=", "getPrefix", "(", "cmp", ".", "Key", ")", "\n", "return", "cmp", "\n", "}" ]
// WithPrefix sets the comparison to scan all keys prefixed by the key.
[ "WithPrefix", "sets", "the", "comparison", "to", "scan", "all", "keys", "prefixed", "by", "the", "key", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/compare.go#L117-L120
test
etcd-io/etcd
clientv3/compare.go
mustInt64
func mustInt64(val interface{}) int64 { if v, ok := val.(int64); ok { return v } if v, ok := val.(int); ok { return int64(v) } panic("bad value") }
go
func mustInt64(val interface{}) int64 { if v, ok := val.(int64); ok { return v } if v, ok := val.(int); ok { return int64(v) } panic("bad value") }
[ "func", "mustInt64", "(", "val", "interface", "{", "}", ")", "int64", "{", "if", "v", ",", "ok", ":=", "val", ".", "(", "int64", ")", ";", "ok", "{", "return", "v", "\n", "}", "\n", "if", "v", ",", "ok", ":=", "val", ".", "(", "int", ")", "...
// mustInt64 panics if val isn't an int or int64. It returns an int64 otherwise.
[ "mustInt64", "panics", "if", "val", "isn", "t", "an", "int", "or", "int64", ".", "It", "returns", "an", "int64", "otherwise", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/compare.go#L123-L131
test
etcd-io/etcd
clientv3/compare.go
mustInt64orLeaseID
func mustInt64orLeaseID(val interface{}) int64 { if v, ok := val.(LeaseID); ok { return int64(v) } return mustInt64(val) }
go
func mustInt64orLeaseID(val interface{}) int64 { if v, ok := val.(LeaseID); ok { return int64(v) } return mustInt64(val) }
[ "func", "mustInt64orLeaseID", "(", "val", "interface", "{", "}", ")", "int64", "{", "if", "v", ",", "ok", ":=", "val", ".", "(", "LeaseID", ")", ";", "ok", "{", "return", "int64", "(", "v", ")", "\n", "}", "\n", "return", "mustInt64", "(", "val", ...
// mustInt64orLeaseID panics if val isn't a LeaseID, int or int64. It returns an // int64 otherwise.
[ "mustInt64orLeaseID", "panics", "if", "val", "isn", "t", "a", "LeaseID", "int", "or", "int64", ".", "It", "returns", "an", "int64", "otherwise", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/compare.go#L135-L140
test
etcd-io/etcd
clientv3/naming/grpc.go
Next
func (gw *gRPCWatcher) Next() ([]*naming.Update, error) { if gw.wch == nil { // first Next() returns all addresses return gw.firstNext() } if gw.err != nil { return nil, gw.err } // process new events on target/* wr, ok := <-gw.wch if !ok { gw.err = status.Error(codes.Unavailable, ErrWatcherClosed.Error...
go
func (gw *gRPCWatcher) Next() ([]*naming.Update, error) { if gw.wch == nil { // first Next() returns all addresses return gw.firstNext() } if gw.err != nil { return nil, gw.err } // process new events on target/* wr, ok := <-gw.wch if !ok { gw.err = status.Error(codes.Unavailable, ErrWatcherClosed.Error...
[ "func", "(", "gw", "*", "gRPCWatcher", ")", "Next", "(", ")", "(", "[", "]", "*", "naming", ".", "Update", ",", "error", ")", "{", "if", "gw", ".", "wch", "==", "nil", "{", "return", "gw", ".", "firstNext", "(", ")", "\n", "}", "\n", "if", "g...
// Next gets the next set of updates from the etcd resolver. // Calls to Next should be serialized; concurrent calls are not safe since // there is no way to reconcile the update ordering.
[ "Next", "gets", "the", "next", "set", "of", "updates", "from", "the", "etcd", "resolver", ".", "Calls", "to", "Next", "should", "be", "serialized", ";", "concurrent", "calls", "are", "not", "safe", "since", "there", "is", "no", "way", "to", "reconcile", ...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/naming/grpc.go#L71-L109
test
etcd-io/etcd
embed/config_logging_journal_unix.go
getJournalWriteSyncer
func getJournalWriteSyncer() (zapcore.WriteSyncer, error) { jw, err := logutil.NewJournalWriter(os.Stderr) if err != nil { return nil, fmt.Errorf("can't find journal (%v)", err) } return zapcore.AddSync(jw), nil }
go
func getJournalWriteSyncer() (zapcore.WriteSyncer, error) { jw, err := logutil.NewJournalWriter(os.Stderr) if err != nil { return nil, fmt.Errorf("can't find journal (%v)", err) } return zapcore.AddSync(jw), nil }
[ "func", "getJournalWriteSyncer", "(", ")", "(", "zapcore", ".", "WriteSyncer", ",", "error", ")", "{", "jw", ",", "err", ":=", "logutil", ".", "NewJournalWriter", "(", "os", ".", "Stderr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",",...
// use stderr as fallback
[ "use", "stderr", "as", "fallback" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/embed/config_logging_journal_unix.go#L29-L35
test
etcd-io/etcd
etcdserver/api/v2store/node.go
newKV
func newKV(store *store, nodePath string, value string, createdIndex uint64, parent *node, expireTime time.Time) *node { return &node{ Path: nodePath, CreatedIndex: createdIndex, ModifiedIndex: createdIndex, Parent: parent, store: store, ExpireTime: expireTime, Value: ...
go
func newKV(store *store, nodePath string, value string, createdIndex uint64, parent *node, expireTime time.Time) *node { return &node{ Path: nodePath, CreatedIndex: createdIndex, ModifiedIndex: createdIndex, Parent: parent, store: store, ExpireTime: expireTime, Value: ...
[ "func", "newKV", "(", "store", "*", "store", ",", "nodePath", "string", ",", "value", "string", ",", "createdIndex", "uint64", ",", "parent", "*", "node", ",", "expireTime", "time", ".", "Time", ")", "*", "node", "{", "return", "&", "node", "{", "Path"...
// newKV creates a Key-Value pair
[ "newKV", "creates", "a", "Key", "-", "Value", "pair" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L57-L67
test
etcd-io/etcd
etcdserver/api/v2store/node.go
newDir
func newDir(store *store, nodePath string, createdIndex uint64, parent *node, expireTime time.Time) *node { return &node{ Path: nodePath, CreatedIndex: createdIndex, ModifiedIndex: createdIndex, Parent: parent, ExpireTime: expireTime, Children: make(map[string]*node), store: ...
go
func newDir(store *store, nodePath string, createdIndex uint64, parent *node, expireTime time.Time) *node { return &node{ Path: nodePath, CreatedIndex: createdIndex, ModifiedIndex: createdIndex, Parent: parent, ExpireTime: expireTime, Children: make(map[string]*node), store: ...
[ "func", "newDir", "(", "store", "*", "store", ",", "nodePath", "string", ",", "createdIndex", "uint64", ",", "parent", "*", "node", ",", "expireTime", "time", ".", "Time", ")", "*", "node", "{", "return", "&", "node", "{", "Path", ":", "nodePath", ",",...
// newDir creates a directory
[ "newDir", "creates", "a", "directory" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L70-L80
test
etcd-io/etcd
etcdserver/api/v2store/node.go
Read
func (n *node) Read() (string, *v2error.Error) { if n.IsDir() { return "", v2error.NewError(v2error.EcodeNotFile, "", n.store.CurrentIndex) } return n.Value, nil }
go
func (n *node) Read() (string, *v2error.Error) { if n.IsDir() { return "", v2error.NewError(v2error.EcodeNotFile, "", n.store.CurrentIndex) } return n.Value, nil }
[ "func", "(", "n", "*", "node", ")", "Read", "(", ")", "(", "string", ",", "*", "v2error", ".", "Error", ")", "{", "if", "n", ".", "IsDir", "(", ")", "{", "return", "\"\"", ",", "v2error", ".", "NewError", "(", "v2error", ".", "EcodeNotFile", ",",...
// Read function gets the value of the node. // If the receiver node is not a key-value pair, a "Not A File" error will be returned.
[ "Read", "function", "gets", "the", "value", "of", "the", "node", ".", "If", "the", "receiver", "node", "is", "not", "a", "key", "-", "value", "pair", "a", "Not", "A", "File", "error", "will", "be", "returned", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L110-L116
test
etcd-io/etcd
etcdserver/api/v2store/node.go
Write
func (n *node) Write(value string, index uint64) *v2error.Error { if n.IsDir() { return v2error.NewError(v2error.EcodeNotFile, "", n.store.CurrentIndex) } n.Value = value n.ModifiedIndex = index return nil }
go
func (n *node) Write(value string, index uint64) *v2error.Error { if n.IsDir() { return v2error.NewError(v2error.EcodeNotFile, "", n.store.CurrentIndex) } n.Value = value n.ModifiedIndex = index return nil }
[ "func", "(", "n", "*", "node", ")", "Write", "(", "value", "string", ",", "index", "uint64", ")", "*", "v2error", ".", "Error", "{", "if", "n", ".", "IsDir", "(", ")", "{", "return", "v2error", ".", "NewError", "(", "v2error", ".", "EcodeNotFile", ...
// Write function set the value of the node to the given value. // If the receiver node is a directory, a "Not A File" error will be returned.
[ "Write", "function", "set", "the", "value", "of", "the", "node", "to", "the", "given", "value", ".", "If", "the", "receiver", "node", "is", "a", "directory", "a", "Not", "A", "File", "error", "will", "be", "returned", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L120-L129
test
etcd-io/etcd
etcdserver/api/v2store/node.go
List
func (n *node) List() ([]*node, *v2error.Error) { if !n.IsDir() { return nil, v2error.NewError(v2error.EcodeNotDir, "", n.store.CurrentIndex) } nodes := make([]*node, len(n.Children)) i := 0 for _, node := range n.Children { nodes[i] = node i++ } return nodes, nil }
go
func (n *node) List() ([]*node, *v2error.Error) { if !n.IsDir() { return nil, v2error.NewError(v2error.EcodeNotDir, "", n.store.CurrentIndex) } nodes := make([]*node, len(n.Children)) i := 0 for _, node := range n.Children { nodes[i] = node i++ } return nodes, nil }
[ "func", "(", "n", "*", "node", ")", "List", "(", ")", "(", "[", "]", "*", "node", ",", "*", "v2error", ".", "Error", ")", "{", "if", "!", "n", ".", "IsDir", "(", ")", "{", "return", "nil", ",", "v2error", ".", "NewError", "(", "v2error", ".",...
// List function return a slice of nodes under the receiver node. // If the receiver node is not a directory, a "Not A Directory" error will be returned.
[ "List", "function", "return", "a", "slice", "of", "nodes", "under", "the", "receiver", "node", ".", "If", "the", "receiver", "node", "is", "not", "a", "directory", "a", "Not", "A", "Directory", "error", "will", "be", "returned", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L153-L167
test
etcd-io/etcd
etcdserver/api/v2store/node.go
GetChild
func (n *node) GetChild(name string) (*node, *v2error.Error) { if !n.IsDir() { return nil, v2error.NewError(v2error.EcodeNotDir, n.Path, n.store.CurrentIndex) } child, ok := n.Children[name] if ok { return child, nil } return nil, nil }
go
func (n *node) GetChild(name string) (*node, *v2error.Error) { if !n.IsDir() { return nil, v2error.NewError(v2error.EcodeNotDir, n.Path, n.store.CurrentIndex) } child, ok := n.Children[name] if ok { return child, nil } return nil, nil }
[ "func", "(", "n", "*", "node", ")", "GetChild", "(", "name", "string", ")", "(", "*", "node", ",", "*", "v2error", ".", "Error", ")", "{", "if", "!", "n", ".", "IsDir", "(", ")", "{", "return", "nil", ",", "v2error", ".", "NewError", "(", "v2er...
// GetChild function returns the child node under the directory node. // On success, it returns the file node
[ "GetChild", "function", "returns", "the", "child", "node", "under", "the", "directory", "node", ".", "On", "success", "it", "returns", "the", "file", "node" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L171-L183
test
etcd-io/etcd
etcdserver/api/v2store/node.go
Add
func (n *node) Add(child *node) *v2error.Error { if !n.IsDir() { return v2error.NewError(v2error.EcodeNotDir, "", n.store.CurrentIndex) } _, name := path.Split(child.Path) if _, ok := n.Children[name]; ok { return v2error.NewError(v2error.EcodeNodeExist, "", n.store.CurrentIndex) } n.Children[name] = child...
go
func (n *node) Add(child *node) *v2error.Error { if !n.IsDir() { return v2error.NewError(v2error.EcodeNotDir, "", n.store.CurrentIndex) } _, name := path.Split(child.Path) if _, ok := n.Children[name]; ok { return v2error.NewError(v2error.EcodeNodeExist, "", n.store.CurrentIndex) } n.Children[name] = child...
[ "func", "(", "n", "*", "node", ")", "Add", "(", "child", "*", "node", ")", "*", "v2error", ".", "Error", "{", "if", "!", "n", ".", "IsDir", "(", ")", "{", "return", "v2error", ".", "NewError", "(", "v2error", ".", "EcodeNotDir", ",", "\"\"", ",",...
// Add function adds a node to the receiver node. // If the receiver is not a directory, a "Not A Directory" error will be returned. // If there is an existing node with the same name under the directory, a "Already Exist" // error will be returned
[ "Add", "function", "adds", "a", "node", "to", "the", "receiver", "node", ".", "If", "the", "receiver", "is", "not", "a", "directory", "a", "Not", "A", "Directory", "error", "will", "be", "returned", ".", "If", "there", "is", "an", "existing", "node", "...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L189-L203
test
etcd-io/etcd
etcdserver/api/v2store/node.go
Remove
func (n *node) Remove(dir, recursive bool, callback func(path string)) *v2error.Error { if !n.IsDir() { // key-value pair _, name := path.Split(n.Path) // find its parent and remove the node from the map if n.Parent != nil && n.Parent.Children[name] == n { delete(n.Parent.Children, name) } if callback !...
go
func (n *node) Remove(dir, recursive bool, callback func(path string)) *v2error.Error { if !n.IsDir() { // key-value pair _, name := path.Split(n.Path) // find its parent and remove the node from the map if n.Parent != nil && n.Parent.Children[name] == n { delete(n.Parent.Children, name) } if callback !...
[ "func", "(", "n", "*", "node", ")", "Remove", "(", "dir", ",", "recursive", "bool", ",", "callback", "func", "(", "path", "string", ")", ")", "*", "v2error", ".", "Error", "{", "if", "!", "n", ".", "IsDir", "(", ")", "{", "_", ",", "name", ":="...
// Remove function remove the node.
[ "Remove", "function", "remove", "the", "node", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L206-L256
test
etcd-io/etcd
etcdserver/api/v2store/node.go
Compare
func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int) { indexMatch := prevIndex == 0 || n.ModifiedIndex == prevIndex valueMatch := prevValue == "" || n.Value == prevValue ok = valueMatch && indexMatch switch { case valueMatch && indexMatch: which = CompareMatch case indexMatch && !valu...
go
func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int) { indexMatch := prevIndex == 0 || n.ModifiedIndex == prevIndex valueMatch := prevValue == "" || n.Value == prevValue ok = valueMatch && indexMatch switch { case valueMatch && indexMatch: which = CompareMatch case indexMatch && !valu...
[ "func", "(", "n", "*", "node", ")", "Compare", "(", "prevValue", "string", ",", "prevIndex", "uint64", ")", "(", "ok", "bool", ",", "which", "int", ")", "{", "indexMatch", ":=", "prevIndex", "==", "0", "||", "n", ".", "ModifiedIndex", "==", "prevIndex"...
// Compare function compares node index and value with provided ones. // second result value explains result and equals to one of Compare.. constants
[ "Compare", "function", "compares", "node", "index", "and", "value", "with", "provided", "ones", ".", "second", "result", "value", "explains", "result", "and", "equals", "to", "one", "of", "Compare", "..", "constants" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L340-L355
test
etcd-io/etcd
etcdserver/api/v2store/node.go
Clone
func (n *node) Clone() *node { if !n.IsDir() { newkv := newKV(n.store, n.Path, n.Value, n.CreatedIndex, n.Parent, n.ExpireTime) newkv.ModifiedIndex = n.ModifiedIndex return newkv } clone := newDir(n.store, n.Path, n.CreatedIndex, n.Parent, n.ExpireTime) clone.ModifiedIndex = n.ModifiedIndex for key, child ...
go
func (n *node) Clone() *node { if !n.IsDir() { newkv := newKV(n.store, n.Path, n.Value, n.CreatedIndex, n.Parent, n.ExpireTime) newkv.ModifiedIndex = n.ModifiedIndex return newkv } clone := newDir(n.store, n.Path, n.CreatedIndex, n.Parent, n.ExpireTime) clone.ModifiedIndex = n.ModifiedIndex for key, child ...
[ "func", "(", "n", "*", "node", ")", "Clone", "(", ")", "*", "node", "{", "if", "!", "n", ".", "IsDir", "(", ")", "{", "newkv", ":=", "newKV", "(", "n", ".", "store", ",", "n", ".", "Path", ",", "n", ".", "Value", ",", "n", ".", "CreatedInde...
// Clone function clone the node recursively and return the new node. // If the node is a directory, it will clone all the content under this directory. // If the node is a key-value pair, it will clone the pair.
[ "Clone", "function", "clone", "the", "node", "recursively", "and", "return", "the", "new", "node", ".", "If", "the", "node", "is", "a", "directory", "it", "will", "clone", "all", "the", "content", "under", "this", "directory", ".", "If", "the", "node", "...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/node.go#L360-L375
test
etcd-io/etcd
etcdserver/util.go
isConnectedToQuorumSince
func isConnectedToQuorumSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) bool { return numConnectedSince(transport, since, self, members) >= (len(members)/2)+1 }
go
func isConnectedToQuorumSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) bool { return numConnectedSince(transport, since, self, members) >= (len(members)/2)+1 }
[ "func", "isConnectedToQuorumSince", "(", "transport", "rafthttp", ".", "Transporter", ",", "since", "time", ".", "Time", ",", "self", "types", ".", "ID", ",", "members", "[", "]", "*", "membership", ".", "Member", ")", "bool", "{", "return", "numConnectedSin...
// isConnectedToQuorumSince checks whether the local member is connected to the // quorum of the cluster since the given time.
[ "isConnectedToQuorumSince", "checks", "whether", "the", "local", "member", "is", "connected", "to", "the", "quorum", "of", "the", "cluster", "since", "the", "given", "time", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/util.go#L34-L36
test
etcd-io/etcd
etcdserver/util.go
isConnectedSince
func isConnectedSince(transport rafthttp.Transporter, since time.Time, remote types.ID) bool { t := transport.ActiveSince(remote) return !t.IsZero() && t.Before(since) }
go
func isConnectedSince(transport rafthttp.Transporter, since time.Time, remote types.ID) bool { t := transport.ActiveSince(remote) return !t.IsZero() && t.Before(since) }
[ "func", "isConnectedSince", "(", "transport", "rafthttp", ".", "Transporter", ",", "since", "time", ".", "Time", ",", "remote", "types", ".", "ID", ")", "bool", "{", "t", ":=", "transport", ".", "ActiveSince", "(", "remote", ")", "\n", "return", "!", "t"...
// isConnectedSince checks whether the local member is connected to the // remote member since the given time.
[ "isConnectedSince", "checks", "whether", "the", "local", "member", "is", "connected", "to", "the", "remote", "member", "since", "the", "given", "time", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/util.go#L40-L43
test
etcd-io/etcd
etcdserver/util.go
numConnectedSince
func numConnectedSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) int { connectedNum := 0 for _, m := range members { if m.ID == self || isConnectedSince(transport, since, m.ID) { connectedNum++ } } return connectedNum }
go
func numConnectedSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) int { connectedNum := 0 for _, m := range members { if m.ID == self || isConnectedSince(transport, since, m.ID) { connectedNum++ } } return connectedNum }
[ "func", "numConnectedSince", "(", "transport", "rafthttp", ".", "Transporter", ",", "since", "time", ".", "Time", ",", "self", "types", ".", "ID", ",", "members", "[", "]", "*", "membership", ".", "Member", ")", "int", "{", "connectedNum", ":=", "0", "\n...
// numConnectedSince counts how many members are connected to the local member // since the given time.
[ "numConnectedSince", "counts", "how", "many", "members", "are", "connected", "to", "the", "local", "member", "since", "the", "given", "time", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/util.go#L53-L61
test
etcd-io/etcd
etcdserver/util.go
longestConnected
func longestConnected(tp rafthttp.Transporter, membs []types.ID) (types.ID, bool) { var longest types.ID var oldest time.Time for _, id := range membs { tm := tp.ActiveSince(id) if tm.IsZero() { // inactive continue } if oldest.IsZero() { // first longest candidate oldest = tm longest = id } i...
go
func longestConnected(tp rafthttp.Transporter, membs []types.ID) (types.ID, bool) { var longest types.ID var oldest time.Time for _, id := range membs { tm := tp.ActiveSince(id) if tm.IsZero() { // inactive continue } if oldest.IsZero() { // first longest candidate oldest = tm longest = id } i...
[ "func", "longestConnected", "(", "tp", "rafthttp", ".", "Transporter", ",", "membs", "[", "]", "types", ".", "ID", ")", "(", "types", ".", "ID", ",", "bool", ")", "{", "var", "longest", "types", ".", "ID", "\n", "var", "oldest", "time", ".", "Time", ...
// longestConnected chooses the member with longest active-since-time. // It returns false, if nothing is active.
[ "longestConnected", "chooses", "the", "member", "with", "longest", "active", "-", "since", "-", "time", ".", "It", "returns", "false", "if", "nothing", "is", "active", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/util.go#L65-L88
test
etcd-io/etcd
wal/decoder.go
isTornEntry
func (d *decoder) isTornEntry(data []byte) bool { if len(d.brs) != 1 { return false } fileOff := d.lastValidOff + frameSizeBytes curOff := 0 chunks := [][]byte{} // split data on sector boundaries for curOff < len(data) { chunkLen := int(minSectorSize - (fileOff % minSectorSize)) if chunkLen > len(data)-c...
go
func (d *decoder) isTornEntry(data []byte) bool { if len(d.brs) != 1 { return false } fileOff := d.lastValidOff + frameSizeBytes curOff := 0 chunks := [][]byte{} // split data on sector boundaries for curOff < len(data) { chunkLen := int(minSectorSize - (fileOff % minSectorSize)) if chunkLen > len(data)-c...
[ "func", "(", "d", "*", "decoder", ")", "isTornEntry", "(", "data", "[", "]", "byte", ")", "bool", "{", "if", "len", "(", "d", ".", "brs", ")", "!=", "1", "{", "return", "false", "\n", "}", "\n", "fileOff", ":=", "d", ".", "lastValidOff", "+", "...
// isTornEntry determines whether the last entry of the WAL was partially written // and corrupted because of a torn write.
[ "isTornEntry", "determines", "whether", "the", "last", "entry", "of", "the", "WAL", "was", "partially", "written", "and", "corrupted", "because", "of", "a", "torn", "write", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/decoder.go#L127-L160
test
etcd-io/etcd
pkg/mock/mockserver/mockserver.go
StartMockServersOnNetwork
func StartMockServersOnNetwork(count int, network string) (ms *MockServers, err error) { switch network { case "tcp": return startMockServersTcp(count) case "unix": return startMockServersUnix(count) default: return nil, fmt.Errorf("unsupported network type: %s", network) } }
go
func StartMockServersOnNetwork(count int, network string) (ms *MockServers, err error) { switch network { case "tcp": return startMockServersTcp(count) case "unix": return startMockServersUnix(count) default: return nil, fmt.Errorf("unsupported network type: %s", network) } }
[ "func", "StartMockServersOnNetwork", "(", "count", "int", ",", "network", "string", ")", "(", "ms", "*", "MockServers", ",", "err", "error", ")", "{", "switch", "network", "{", "case", "\"tcp\"", ":", "return", "startMockServersTcp", "(", "count", ")", "\n",...
// StartMockServersOnNetwork creates mock servers on either 'tcp' or 'unix' sockets.
[ "StartMockServersOnNetwork", "creates", "mock", "servers", "on", "either", "tcp", "or", "unix", "sockets", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/mock/mockserver/mockserver.go#L64-L73
test
etcd-io/etcd
pkg/mock/mockserver/mockserver.go
StartAt
func (ms *MockServers) StartAt(idx int) (err error) { ms.mu.Lock() defer ms.mu.Unlock() if ms.Servers[idx].ln == nil { ms.Servers[idx].ln, err = net.Listen(ms.Servers[idx].Network, ms.Servers[idx].Address) if err != nil { return fmt.Errorf("failed to listen %v", err) } } svr := grpc.NewServer() pb.Regi...
go
func (ms *MockServers) StartAt(idx int) (err error) { ms.mu.Lock() defer ms.mu.Unlock() if ms.Servers[idx].ln == nil { ms.Servers[idx].ln, err = net.Listen(ms.Servers[idx].Network, ms.Servers[idx].Address) if err != nil { return fmt.Errorf("failed to listen %v", err) } } svr := grpc.NewServer() pb.Regi...
[ "func", "(", "ms", "*", "MockServers", ")", "StartAt", "(", "idx", "int", ")", "(", "err", "error", ")", "{", "ms", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ms", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "ms", ".", "Servers", "...
// StartAt restarts mock server at given index.
[ "StartAt", "restarts", "mock", "server", "at", "given", "index", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/mock/mockserver/mockserver.go#L123-L143
test
etcd-io/etcd
pkg/mock/mockserver/mockserver.go
StopAt
func (ms *MockServers) StopAt(idx int) { ms.mu.Lock() defer ms.mu.Unlock() if ms.Servers[idx].ln == nil { return } ms.Servers[idx].GrpcServer.Stop() ms.Servers[idx].GrpcServer = nil ms.Servers[idx].ln = nil ms.wg.Done() }
go
func (ms *MockServers) StopAt(idx int) { ms.mu.Lock() defer ms.mu.Unlock() if ms.Servers[idx].ln == nil { return } ms.Servers[idx].GrpcServer.Stop() ms.Servers[idx].GrpcServer = nil ms.Servers[idx].ln = nil ms.wg.Done() }
[ "func", "(", "ms", "*", "MockServers", ")", "StopAt", "(", "idx", "int", ")", "{", "ms", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ms", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "ms", ".", "Servers", "[", "idx", "]", ".", "ln", ...
// StopAt stops mock server at given index.
[ "StopAt", "stops", "mock", "server", "at", "given", "index", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/mock/mockserver/mockserver.go#L146-L158
test
etcd-io/etcd
pkg/mock/mockserver/mockserver.go
Stop
func (ms *MockServers) Stop() { for idx := range ms.Servers { ms.StopAt(idx) } ms.wg.Wait() }
go
func (ms *MockServers) Stop() { for idx := range ms.Servers { ms.StopAt(idx) } ms.wg.Wait() }
[ "func", "(", "ms", "*", "MockServers", ")", "Stop", "(", ")", "{", "for", "idx", ":=", "range", "ms", ".", "Servers", "{", "ms", ".", "StopAt", "(", "idx", ")", "\n", "}", "\n", "ms", ".", "wg", ".", "Wait", "(", ")", "\n", "}" ]
// Stop stops the mock server, immediately closing all open connections and listeners.
[ "Stop", "stops", "the", "mock", "server", "immediately", "closing", "all", "open", "connections", "and", "listeners", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/mock/mockserver/mockserver.go#L161-L166
test
etcd-io/etcd
etcdctl/ctlv3/command/check.go
NewCheckCommand
func NewCheckCommand() *cobra.Command { cc := &cobra.Command{ Use: "check <subcommand>", Short: "commands for checking properties of the etcd cluster", } cc.AddCommand(NewCheckPerfCommand()) cc.AddCommand(NewCheckDatascaleCommand()) return cc }
go
func NewCheckCommand() *cobra.Command { cc := &cobra.Command{ Use: "check <subcommand>", Short: "commands for checking properties of the etcd cluster", } cc.AddCommand(NewCheckPerfCommand()) cc.AddCommand(NewCheckDatascaleCommand()) return cc }
[ "func", "NewCheckCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"check <subcommand>\"", ",", "Short", ":", "\"commands for checking properties of the etcd cluster\"", ",", "}", "\n", "cc", ".",...
// NewCheckCommand returns the cobra command for "check".
[ "NewCheckCommand", "returns", "the", "cobra", "command", "for", "check", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/check.go#L106-L116
test
etcd-io/etcd
etcdctl/ctlv3/command/check.go
NewCheckPerfCommand
func NewCheckPerfCommand() *cobra.Command { cmd := &cobra.Command{ Use: "perf [options]", Short: "Check the performance of the etcd cluster", Run: newCheckPerfCommand, } // TODO: support customized configuration cmd.Flags().StringVar(&checkPerfLoad, "load", "s", "The performance check's workload model. A...
go
func NewCheckPerfCommand() *cobra.Command { cmd := &cobra.Command{ Use: "perf [options]", Short: "Check the performance of the etcd cluster", Run: newCheckPerfCommand, } // TODO: support customized configuration cmd.Flags().StringVar(&checkPerfLoad, "load", "s", "The performance check's workload model. A...
[ "func", "NewCheckPerfCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cmd", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"perf [options]\"", ",", "Short", ":", "\"Check the performance of the etcd cluster\"", ",", "Run", ":", "newCheckPerfCommand"...
// NewCheckPerfCommand returns the cobra command for "check perf".
[ "NewCheckPerfCommand", "returns", "the", "cobra", "command", "for", "check", "perf", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/check.go#L119-L133
test
etcd-io/etcd
etcdctl/ctlv3/command/check.go
NewCheckDatascaleCommand
func NewCheckDatascaleCommand() *cobra.Command { cmd := &cobra.Command{ Use: "datascale [options]", Short: "Check the memory usage of holding data for different workloads on a given server endpoint.", Long: "If no endpoint is provided, localhost will be used. If multiple endpoints are provided, first endpoint...
go
func NewCheckDatascaleCommand() *cobra.Command { cmd := &cobra.Command{ Use: "datascale [options]", Short: "Check the memory usage of holding data for different workloads on a given server endpoint.", Long: "If no endpoint is provided, localhost will be used. If multiple endpoints are provided, first endpoint...
[ "func", "NewCheckDatascaleCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cmd", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"datascale [options]\"", ",", "Short", ":", "\"Check the memory usage of holding data for different workloads on a given server e...
// NewCheckDatascaleCommand returns the cobra command for "check datascale".
[ "NewCheckDatascaleCommand", "returns", "the", "cobra", "command", "for", "check", "datascale", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/check.go#L269-L283
test
etcd-io/etcd
etcdctl/ctlv3/command/get_command.go
NewGetCommand
func NewGetCommand() *cobra.Command { cmd := &cobra.Command{ Use: "get [options] <key> [range_end]", Short: "Gets the key or a range of keys", Run: getCommandFunc, } cmd.Flags().StringVar(&getConsistency, "consistency", "l", "Linearizable(l) or Serializable(s)") cmd.Flags().StringVar(&getSortOrder, "orde...
go
func NewGetCommand() *cobra.Command { cmd := &cobra.Command{ Use: "get [options] <key> [range_end]", Short: "Gets the key or a range of keys", Run: getCommandFunc, } cmd.Flags().StringVar(&getConsistency, "consistency", "l", "Linearizable(l) or Serializable(s)") cmd.Flags().StringVar(&getSortOrder, "orde...
[ "func", "NewGetCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cmd", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"get [options] <key> [range_end]\"", ",", "Short", ":", "\"Gets the key or a range of keys\"", ",", "Run", ":", "getCommandFunc", ...
// NewGetCommand returns the cobra command for "get".
[ "NewGetCommand", "returns", "the", "cobra", "command", "for", "get", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/get_command.go#L38-L55
test
etcd-io/etcd
etcdctl/ctlv2/command/get_command.go
NewGetCommand
func NewGetCommand() cli.Command { return cli.Command{ Name: "get", Usage: "retrieve the value of a key", ArgsUsage: "<key>", Flags: []cli.Flag{ cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"}, cli.BoolFlag{Name: "quorum, q", Usage: "require quorum for get request"}, }, A...
go
func NewGetCommand() cli.Command { return cli.Command{ Name: "get", Usage: "retrieve the value of a key", ArgsUsage: "<key>", Flags: []cli.Flag{ cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"}, cli.BoolFlag{Name: "quorum, q", Usage: "require quorum for get request"}, }, A...
[ "func", "NewGetCommand", "(", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"get\"", ",", "Usage", ":", "\"retrieve the value of a key\"", ",", "ArgsUsage", ":", "\"<key>\"", ",", "Flags", ":", "[", "]", "cli", ".", ...
// NewGetCommand returns the CLI command for "get".
[ "NewGetCommand", "returns", "the", "CLI", "command", "for", "get", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/get_command.go#L27-L41
test
etcd-io/etcd
etcdserver/api/membership/member.go
PickPeerURL
func (m *Member) PickPeerURL() string { if len(m.PeerURLs) == 0 { panic("member should always have some peer url") } return m.PeerURLs[rand.Intn(len(m.PeerURLs))] }
go
func (m *Member) PickPeerURL() string { if len(m.PeerURLs) == 0 { panic("member should always have some peer url") } return m.PeerURLs[rand.Intn(len(m.PeerURLs))] }
[ "func", "(", "m", "*", "Member", ")", "PickPeerURL", "(", ")", "string", "{", "if", "len", "(", "m", ".", "PeerURLs", ")", "==", "0", "{", "panic", "(", "\"member should always have some peer url\"", ")", "\n", "}", "\n", "return", "m", ".", "PeerURLs", ...
// PickPeerURL chooses a random address from a given Member's PeerURLs. // It will panic if there is no PeerURLs available in Member.
[ "PickPeerURL", "chooses", "a", "random", "address", "from", "a", "given", "Member", "s", "PeerURLs", ".", "It", "will", "panic", "if", "there", "is", "no", "PeerURLs", "available", "in", "Member", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/membership/member.go#L78-L83
test
etcd-io/etcd
etcdserver/api/etcdhttp/metrics.go
HandleMetricsHealth
func HandleMetricsHealth(mux *http.ServeMux, srv etcdserver.ServerV2) { mux.Handle(PathMetrics, promhttp.Handler()) mux.Handle(PathHealth, NewHealthHandler(func() Health { return checkHealth(srv) })) }
go
func HandleMetricsHealth(mux *http.ServeMux, srv etcdserver.ServerV2) { mux.Handle(PathMetrics, promhttp.Handler()) mux.Handle(PathHealth, NewHealthHandler(func() Health { return checkHealth(srv) })) }
[ "func", "HandleMetricsHealth", "(", "mux", "*", "http", ".", "ServeMux", ",", "srv", "etcdserver", ".", "ServerV2", ")", "{", "mux", ".", "Handle", "(", "PathMetrics", ",", "promhttp", ".", "Handler", "(", ")", ")", "\n", "mux", ".", "Handle", "(", "Pa...
// HandleMetricsHealth registers metrics and health handlers.
[ "HandleMetricsHealth", "registers", "metrics", "and", "health", "handlers", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/metrics.go#L37-L40
test
etcd-io/etcd
etcdctl/ctlv2/command/rm_command.go
NewRemoveCommand
func NewRemoveCommand() cli.Command { return cli.Command{ Name: "rm", Usage: "remove a key or a directory", ArgsUsage: "<key>", Flags: []cli.Flag{ cli.BoolFlag{Name: "dir", Usage: "removes the key if it is an empty directory or a key-value pair"}, cli.BoolFlag{Name: "recursive, r", Usage: "remov...
go
func NewRemoveCommand() cli.Command { return cli.Command{ Name: "rm", Usage: "remove a key or a directory", ArgsUsage: "<key>", Flags: []cli.Flag{ cli.BoolFlag{Name: "dir", Usage: "removes the key if it is an empty directory or a key-value pair"}, cli.BoolFlag{Name: "recursive, r", Usage: "remov...
[ "func", "NewRemoveCommand", "(", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"rm\"", ",", "Usage", ":", "\"remove a key or a directory\"", ",", "ArgsUsage", ":", "\"<key>\"", ",", "Flags", ":", "[", "]", "cli", "."...
// NewRemoveCommand returns the CLI command for "rm".
[ "NewRemoveCommand", "returns", "the", "CLI", "command", "for", "rm", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/rm_command.go#L25-L41
test
etcd-io/etcd
etcdctl/ctlv2/command/rm_command.go
rmCommandFunc
func rmCommandFunc(c *cli.Context, ki client.KeysAPI) { if len(c.Args()) == 0 { handleError(c, ExitBadArgs, errors.New("key required")) } key := c.Args()[0] recursive := c.Bool("recursive") dir := c.Bool("dir") prevValue := c.String("with-value") prevIndex := c.Int("with-index") ctx, cancel := contextWithTot...
go
func rmCommandFunc(c *cli.Context, ki client.KeysAPI) { if len(c.Args()) == 0 { handleError(c, ExitBadArgs, errors.New("key required")) } key := c.Args()[0] recursive := c.Bool("recursive") dir := c.Bool("dir") prevValue := c.String("with-value") prevIndex := c.Int("with-index") ctx, cancel := contextWithTot...
[ "func", "rmCommandFunc", "(", "c", "*", "cli", ".", "Context", ",", "ki", "client", ".", "KeysAPI", ")", "{", "if", "len", "(", "c", ".", "Args", "(", ")", ")", "==", "0", "{", "handleError", "(", "c", ",", "ExitBadArgs", ",", "errors", ".", "New...
// rmCommandFunc executes the "rm" command.
[ "rmCommandFunc", "executes", "the", "rm", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/rm_command.go#L44-L63
test
etcd-io/etcd
etcdserver/api/v3rpc/key.go
checkIntervals
func checkIntervals(reqs []*pb.RequestOp) (map[string]struct{}, adt.IntervalTree, error) { var dels adt.IntervalTree // collect deletes from this level; build first to check lower level overlapped puts for _, req := range reqs { tv, ok := req.Request.(*pb.RequestOp_RequestDeleteRange) if !ok { continue } ...
go
func checkIntervals(reqs []*pb.RequestOp) (map[string]struct{}, adt.IntervalTree, error) { var dels adt.IntervalTree // collect deletes from this level; build first to check lower level overlapped puts for _, req := range reqs { tv, ok := req.Request.(*pb.RequestOp_RequestDeleteRange) if !ok { continue } ...
[ "func", "checkIntervals", "(", "reqs", "[", "]", "*", "pb", ".", "RequestOp", ")", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "adt", ".", "IntervalTree", ",", "error", ")", "{", "var", "dels", "adt", ".", "IntervalTree", "\n", "for", ...
// checkIntervals tests whether puts and deletes overlap for a list of ops. If // there is an overlap, returns an error. If no overlap, return put and delete // sets for recursive evaluation.
[ "checkIntervals", "tests", "whether", "puts", "and", "deletes", "overlap", "for", "a", "list", "of", "ops", ".", "If", "there", "is", "an", "overlap", "returns", "an", "error", ".", "If", "no", "overlap", "return", "put", "and", "delete", "sets", "for", ...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3rpc/key.go#L181-L260
test
etcd-io/etcd
mvcc/metrics.go
ReportEventReceived
func ReportEventReceived(n int) { pendingEventsGauge.Sub(float64(n)) totalEventsCounter.Add(float64(n)) }
go
func ReportEventReceived(n int) { pendingEventsGauge.Sub(float64(n)) totalEventsCounter.Add(float64(n)) }
[ "func", "ReportEventReceived", "(", "n", "int", ")", "{", "pendingEventsGauge", ".", "Sub", "(", "float64", "(", "n", ")", ")", "\n", "totalEventsCounter", ".", "Add", "(", "float64", "(", "n", ")", ")", "\n", "}" ]
// ReportEventReceived reports that an event is received. // This function should be called when the external systems received an // event from mvcc.Watcher.
[ "ReportEventReceived", "reports", "that", "an", "event", "is", "received", ".", "This", "function", "should", "be", "called", "when", "the", "external", "systems", "received", "an", "event", "from", "mvcc", ".", "Watcher", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/metrics.go#L247-L250
test
etcd-io/etcd
etcdserver/etcdserverpb/gw/rpc.pb.gw.go
RegisterKVHandler
func RegisterKVHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterKVHandlerClient(ctx, mux, etcdserverpb.NewKVClient(conn)) }
go
func RegisterKVHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterKVHandlerClient(ctx, mux, etcdserverpb.NewKVClient(conn)) }
[ "func", "RegisterKVHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterKVHandlerClient", "(", "ctx", ",", "mux", ",", "etcdserverpb",...
// RegisterKVHandler registers the http handlers for service KV to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterKVHandler", "registers", "the", "http", "handlers", "for", "service", "KV", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/gw/rpc.pb.gw.go#L678-L680
test
etcd-io/etcd
etcdserver/etcdserverpb/gw/rpc.pb.gw.go
RegisterWatchHandler
func RegisterWatchHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterWatchHandlerClient(ctx, mux, etcdserverpb.NewWatchClient(conn)) }
go
func RegisterWatchHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterWatchHandlerClient(ctx, mux, etcdserverpb.NewWatchClient(conn)) }
[ "func", "RegisterWatchHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterWatchHandlerClient", "(", "ctx", ",", "mux", ",", "etcdserv...
// RegisterWatchHandler registers the http handlers for service Watch to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterWatchHandler", "registers", "the", "http", "handlers", "for", "service", "Watch", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/gw/rpc.pb.gw.go#L888-L890
test
etcd-io/etcd
etcdserver/etcdserverpb/gw/rpc.pb.gw.go
RegisterLeaseHandler
func RegisterLeaseHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterLeaseHandlerClient(ctx, mux, etcdserverpb.NewLeaseClient(conn)) }
go
func RegisterLeaseHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterLeaseHandlerClient(ctx, mux, etcdserverpb.NewLeaseClient(conn)) }
[ "func", "RegisterLeaseHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterLeaseHandlerClient", "(", "ctx", ",", "mux", ",", "etcdserv...
// RegisterLeaseHandler registers the http handlers for service Lease to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterLeaseHandler", "registers", "the", "http", "handlers", "for", "service", "Lease", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/gw/rpc.pb.gw.go#L966-L968
test
etcd-io/etcd
etcdserver/etcdserverpb/gw/rpc.pb.gw.go
RegisterClusterHandler
func RegisterClusterHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterClusterHandlerClient(ctx, mux, etcdserverpb.NewClusterClient(conn)) }
go
func RegisterClusterHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterClusterHandlerClient(ctx, mux, etcdserverpb.NewClusterClient(conn)) }
[ "func", "RegisterClusterHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterClusterHandlerClient", "(", "ctx", ",", "mux", ",", "etcd...
// RegisterClusterHandler registers the http handlers for service Cluster to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterClusterHandler", "registers", "the", "http", "handlers", "for", "service", "Cluster", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/gw/rpc.pb.gw.go#L1275-L1277
test
etcd-io/etcd
etcdserver/etcdserverpb/gw/rpc.pb.gw.go
RegisterMaintenanceHandler
func RegisterMaintenanceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterMaintenanceHandlerClient(ctx, mux, etcdserverpb.NewMaintenanceClient(conn)) }
go
func RegisterMaintenanceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterMaintenanceHandlerClient(ctx, mux, etcdserverpb.NewMaintenanceClient(conn)) }
[ "func", "RegisterMaintenanceHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterMaintenanceHandlerClient", "(", "ctx", ",", "mux", ",",...
// RegisterMaintenanceHandler registers the http handlers for service Maintenance to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterMaintenanceHandler", "registers", "the", "http", "handlers", "for", "service", "Maintenance", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/gw/rpc.pb.gw.go#L1452-L1454
test
etcd-io/etcd
etcdserver/etcdserverpb/gw/rpc.pb.gw.go
RegisterAuthHandler
func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterAuthHandlerClient(ctx, mux, etcdserverpb.NewAuthClient(conn)) }
go
func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterAuthHandlerClient(ctx, mux, etcdserverpb.NewAuthClient(conn)) }
[ "func", "RegisterAuthHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterAuthHandlerClient", "(", "ctx", ",", "mux", ",", "etcdserver...
// RegisterAuthHandler registers the http handlers for service Auth to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterAuthHandler", "registers", "the", "http", "handlers", "for", "service", "Auth", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/gw/rpc.pb.gw.go#L1728-L1730
test
etcd-io/etcd
etcdmain/etcd.go
startEtcd
func startEtcd(cfg *embed.Config) (<-chan struct{}, <-chan error, error) { e, err := embed.StartEtcd(cfg) if err != nil { return nil, nil, err } osutil.RegisterInterruptHandler(e.Close) select { case <-e.Server.ReadyNotify(): // wait for e.Server to join the cluster case <-e.Server.StopNotify(): // publish abo...
go
func startEtcd(cfg *embed.Config) (<-chan struct{}, <-chan error, error) { e, err := embed.StartEtcd(cfg) if err != nil { return nil, nil, err } osutil.RegisterInterruptHandler(e.Close) select { case <-e.Server.ReadyNotify(): // wait for e.Server to join the cluster case <-e.Server.StopNotify(): // publish abo...
[ "func", "startEtcd", "(", "cfg", "*", "embed", ".", "Config", ")", "(", "<-", "chan", "struct", "{", "}", ",", "<-", "chan", "error", ",", "error", ")", "{", "e", ",", "err", ":=", "embed", ".", "StartEtcd", "(", "cfg", ")", "\n", "if", "err", ...
// startEtcd runs StartEtcd in addition to hooks needed for standalone etcd.
[ "startEtcd", "runs", "StartEtcd", "in", "addition", "to", "hooks", "needed", "for", "standalone", "etcd", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdmain/etcd.go#L301-L312
test
etcd-io/etcd
etcdmain/etcd.go
identifyDataDirOrDie
func identifyDataDirOrDie(lg *zap.Logger, dir string) dirType { names, err := fileutil.ReadDir(dir) if err != nil { if os.IsNotExist(err) { return dirEmpty } if lg != nil { lg.Fatal("failed to list data directory", zap.String("dir", dir), zap.Error(err)) } else { plog.Fatalf("error listing data dir: ...
go
func identifyDataDirOrDie(lg *zap.Logger, dir string) dirType { names, err := fileutil.ReadDir(dir) if err != nil { if os.IsNotExist(err) { return dirEmpty } if lg != nil { lg.Fatal("failed to list data directory", zap.String("dir", dir), zap.Error(err)) } else { plog.Fatalf("error listing data dir: ...
[ "func", "identifyDataDirOrDie", "(", "lg", "*", "zap", ".", "Logger", ",", "dir", "string", ")", "dirType", "{", "names", ",", "err", ":=", "fileutil", ".", "ReadDir", "(", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist...
// identifyDataDirOrDie returns the type of the data dir. // Dies if the datadir is invalid.
[ "identifyDataDirOrDie", "returns", "the", "type", "of", "the", "data", "dir", ".", "Dies", "if", "the", "datadir", "is", "invalid", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdmain/etcd.go#L555-L602
test
etcd-io/etcd
wal/repair.go
openLast
func openLast(lg *zap.Logger, dirpath string) (*fileutil.LockedFile, error) { names, err := readWALNames(lg, dirpath) if err != nil { return nil, err } last := filepath.Join(dirpath, names[len(names)-1]) return fileutil.LockFile(last, os.O_RDWR, fileutil.PrivateFileMode) }
go
func openLast(lg *zap.Logger, dirpath string) (*fileutil.LockedFile, error) { names, err := readWALNames(lg, dirpath) if err != nil { return nil, err } last := filepath.Join(dirpath, names[len(names)-1]) return fileutil.LockFile(last, os.O_RDWR, fileutil.PrivateFileMode) }
[ "func", "openLast", "(", "lg", "*", "zap", ".", "Logger", ",", "dirpath", "string", ")", "(", "*", "fileutil", ".", "LockedFile", ",", "error", ")", "{", "names", ",", "err", ":=", "readWALNames", "(", "lg", ",", "dirpath", ")", "\n", "if", "err", ...
// openLast opens the last wal file for read and write.
[ "openLast", "opens", "the", "last", "wal", "file", "for", "read", "and", "write", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/repair.go#L134-L141
test
etcd-io/etcd
proxy/grpcproxy/leader.go
gotLeader
func (l *leader) gotLeader() { l.mu.Lock() defer l.mu.Unlock() select { case <-l.leaderc: l.leaderc = make(chan struct{}) default: } }
go
func (l *leader) gotLeader() { l.mu.Lock() defer l.mu.Unlock() select { case <-l.leaderc: l.leaderc = make(chan struct{}) default: } }
[ "func", "(", "l", "*", "leader", ")", "gotLeader", "(", ")", "{", "l", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mu", ".", "Unlock", "(", ")", "\n", "select", "{", "case", "<-", "l", ".", "leaderc", ":", "l", ".", "leaderc",...
// gotLeader will force update the leadership status to having a leader.
[ "gotLeader", "will", "force", "update", "the", "leadership", "status", "to", "having", "a", "leader", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/leader.go#L93-L101
test
etcd-io/etcd
proxy/grpcproxy/leader.go
lostNotify
func (l *leader) lostNotify() <-chan struct{} { l.mu.RLock() defer l.mu.RUnlock() return l.leaderc }
go
func (l *leader) lostNotify() <-chan struct{} { l.mu.RLock() defer l.mu.RUnlock() return l.leaderc }
[ "func", "(", "l", "*", "leader", ")", "lostNotify", "(", ")", "<-", "chan", "struct", "{", "}", "{", "l", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "l", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "l", ".", "leaderc", "\n", "...
// lostNotify returns a channel that is closed if there has been // a leader loss not yet followed by a leader reacquire.
[ "lostNotify", "returns", "a", "channel", "that", "is", "closed", "if", "there", "has", "been", "a", "leader", "loss", "not", "yet", "followed", "by", "a", "leader", "reacquire", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/leader.go#L109-L113
test
etcd-io/etcd
etcdmain/grpc_proxy.go
newGRPCProxyCommand
func newGRPCProxyCommand() *cobra.Command { lpc := &cobra.Command{ Use: "grpc-proxy <subcommand>", Short: "grpc-proxy related command", } lpc.AddCommand(newGRPCProxyStartCommand()) return lpc }
go
func newGRPCProxyCommand() *cobra.Command { lpc := &cobra.Command{ Use: "grpc-proxy <subcommand>", Short: "grpc-proxy related command", } lpc.AddCommand(newGRPCProxyStartCommand()) return lpc }
[ "func", "newGRPCProxyCommand", "(", ")", "*", "cobra", ".", "Command", "{", "lpc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"grpc-proxy <subcommand>\"", ",", "Short", ":", "\"grpc-proxy related command\"", ",", "}", "\n", "lpc", ".", "AddCommand"...
// newGRPCProxyCommand returns the cobra command for "grpc-proxy".
[ "newGRPCProxyCommand", "returns", "the", "cobra", "command", "for", "grpc", "-", "proxy", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdmain/grpc_proxy.go#L98-L106
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
NewMemberCommand
func NewMemberCommand() *cobra.Command { mc := &cobra.Command{ Use: "member <subcommand>", Short: "Membership related commands", } mc.AddCommand(NewMemberAddCommand()) mc.AddCommand(NewMemberRemoveCommand()) mc.AddCommand(NewMemberUpdateCommand()) mc.AddCommand(NewMemberListCommand()) return mc }
go
func NewMemberCommand() *cobra.Command { mc := &cobra.Command{ Use: "member <subcommand>", Short: "Membership related commands", } mc.AddCommand(NewMemberAddCommand()) mc.AddCommand(NewMemberRemoveCommand()) mc.AddCommand(NewMemberUpdateCommand()) mc.AddCommand(NewMemberListCommand()) return mc }
[ "func", "NewMemberCommand", "(", ")", "*", "cobra", ".", "Command", "{", "mc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"member <subcommand>\"", ",", "Short", ":", "\"Membership related commands\"", ",", "}", "\n", "mc", ".", "AddCommand", "(",...
// NewMemberCommand returns the cobra command for "member".
[ "NewMemberCommand", "returns", "the", "cobra", "command", "for", "member", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L29-L41
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
NewMemberAddCommand
func NewMemberAddCommand() *cobra.Command { cc := &cobra.Command{ Use: "add <memberName> [options]", Short: "Adds a member into the cluster", Run: memberAddCommandFunc, } cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the new member.") return cc }
go
func NewMemberAddCommand() *cobra.Command { cc := &cobra.Command{ Use: "add <memberName> [options]", Short: "Adds a member into the cluster", Run: memberAddCommandFunc, } cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the new member.") return cc }
[ "func", "NewMemberAddCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"add <memberName> [options]\"", ",", "Short", ":", "\"Adds a member into the cluster\"", ",", "Run", ":", "memberAddCommandFunc...
// NewMemberAddCommand returns the cobra command for "member add".
[ "NewMemberAddCommand", "returns", "the", "cobra", "command", "for", "member", "add", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L44-L55
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
NewMemberRemoveCommand
func NewMemberRemoveCommand() *cobra.Command { cc := &cobra.Command{ Use: "remove <memberID>", Short: "Removes a member from the cluster", Run: memberRemoveCommandFunc, } return cc }
go
func NewMemberRemoveCommand() *cobra.Command { cc := &cobra.Command{ Use: "remove <memberID>", Short: "Removes a member from the cluster", Run: memberRemoveCommandFunc, } return cc }
[ "func", "NewMemberRemoveCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"remove <memberID>\"", ",", "Short", ":", "\"Removes a member from the cluster\"", ",", "Run", ":", "memberRemoveCommandFunc...
// NewMemberRemoveCommand returns the cobra command for "member remove".
[ "NewMemberRemoveCommand", "returns", "the", "cobra", "command", "for", "member", "remove", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L58-L67
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
NewMemberUpdateCommand
func NewMemberUpdateCommand() *cobra.Command { cc := &cobra.Command{ Use: "update <memberID> [options]", Short: "Updates a member in the cluster", Run: memberUpdateCommandFunc, } cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the updated member.") return cc }
go
func NewMemberUpdateCommand() *cobra.Command { cc := &cobra.Command{ Use: "update <memberID> [options]", Short: "Updates a member in the cluster", Run: memberUpdateCommandFunc, } cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the updated member.") return cc }
[ "func", "NewMemberUpdateCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"update <memberID> [options]\"", ",", "Short", ":", "\"Updates a member in the cluster\"", ",", "Run", ":", "memberUpdateCom...
// NewMemberUpdateCommand returns the cobra command for "member update".
[ "NewMemberUpdateCommand", "returns", "the", "cobra", "command", "for", "member", "update", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L70-L81
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
NewMemberListCommand
func NewMemberListCommand() *cobra.Command { cc := &cobra.Command{ Use: "list", Short: "Lists all members in the cluster", Long: `When --write-out is set to simple, this command prints out comma-separated member lists for each endpoint. The items in the lists are ID, Status, Name, Peer Addrs, Client Addrs. `, ...
go
func NewMemberListCommand() *cobra.Command { cc := &cobra.Command{ Use: "list", Short: "Lists all members in the cluster", Long: `When --write-out is set to simple, this command prints out comma-separated member lists for each endpoint. The items in the lists are ID, Status, Name, Peer Addrs, Client Addrs. `, ...
[ "func", "NewMemberListCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"list\"", ",", "Short", ":", "\"Lists all members in the cluster\"", ",", "Long", ":", "`When --write-out is set to simple, th...
// NewMemberListCommand returns the cobra command for "member list".
[ "NewMemberListCommand", "returns", "the", "cobra", "command", "for", "member", "list", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L84-L96
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
memberAddCommandFunc
func memberAddCommandFunc(cmd *cobra.Command, args []string) { if len(args) < 1 { ExitWithError(ExitBadArgs, errors.New("member name not provided")) } if len(args) > 1 { ev := "too many arguments" for _, s := range args { if strings.HasPrefix(strings.ToLower(s), "http") { ev += fmt.Sprintf(`, did you me...
go
func memberAddCommandFunc(cmd *cobra.Command, args []string) { if len(args) < 1 { ExitWithError(ExitBadArgs, errors.New("member name not provided")) } if len(args) > 1 { ev := "too many arguments" for _, s := range args { if strings.HasPrefix(strings.ToLower(s), "http") { ev += fmt.Sprintf(`, did you me...
[ "func", "memberAddCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "<", "1", "{", "ExitWithError", "(", "ExitBadArgs", ",", "errors", ".", "New", "(", "\"member name not pro...
// memberAddCommandFunc executes the "member add" command.
[ "memberAddCommandFunc", "executes", "the", "member", "add", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L99-L168
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
memberRemoveCommandFunc
func memberRemoveCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided")) } id, err := strconv.ParseUint(args[0], 16, 64) if err != nil { ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err)) }...
go
func memberRemoveCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided")) } id, err := strconv.ParseUint(args[0], 16, 64) if err != nil { ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err)) }...
[ "func", "memberRemoveCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"member ID is no...
// memberRemoveCommandFunc executes the "member remove" command.
[ "memberRemoveCommandFunc", "executes", "the", "member", "remove", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L171-L188
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
memberUpdateCommandFunc
func memberUpdateCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided")) } id, err := strconv.ParseUint(args[0], 16, 64) if err != nil { ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err)) }...
go
func memberUpdateCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided")) } id, err := strconv.ParseUint(args[0], 16, 64) if err != nil { ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err)) }...
[ "func", "memberUpdateCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"member ID is no...
// memberUpdateCommandFunc executes the "member update" command.
[ "memberUpdateCommandFunc", "executes", "the", "member", "update", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L191-L215
test
etcd-io/etcd
etcdctl/ctlv3/command/member_command.go
memberListCommandFunc
func memberListCommandFunc(cmd *cobra.Command, args []string) { ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).MemberList(ctx) cancel() if err != nil { ExitWithError(ExitError, err) } display.MemberList(*resp) }
go
func memberListCommandFunc(cmd *cobra.Command, args []string) { ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).MemberList(ctx) cancel() if err != nil { ExitWithError(ExitError, err) } display.MemberList(*resp) }
[ "func", "memberListCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "ctx", ",", "cancel", ":=", "commandCtx", "(", "cmd", ")", "\n", "resp", ",", "err", ":=", "mustClientFromCmd", "(", "cmd", ")", ".", ...
// memberListCommandFunc executes the "member list" command.
[ "memberListCommandFunc", "executes", "the", "member", "list", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L218-L227
test
etcd-io/etcd
wal/wal.go
Open
func Open(lg *zap.Logger, dirpath string, snap walpb.Snapshot) (*WAL, error) { w, err := openAtIndex(lg, dirpath, snap, true) if err != nil { return nil, err } if w.dirFile, err = fileutil.OpenDir(w.dir); err != nil { return nil, err } return w, nil }
go
func Open(lg *zap.Logger, dirpath string, snap walpb.Snapshot) (*WAL, error) { w, err := openAtIndex(lg, dirpath, snap, true) if err != nil { return nil, err } if w.dirFile, err = fileutil.OpenDir(w.dir); err != nil { return nil, err } return w, nil }
[ "func", "Open", "(", "lg", "*", "zap", ".", "Logger", ",", "dirpath", "string", ",", "snap", "walpb", ".", "Snapshot", ")", "(", "*", "WAL", ",", "error", ")", "{", "w", ",", "err", ":=", "openAtIndex", "(", "lg", ",", "dirpath", ",", "snap", ","...
// Open opens the WAL at the given snap. // The snap SHOULD have been previously saved to the WAL, or the following // ReadAll will fail. // The returned WAL is ready to read and the first record will be the one after // the given snap. The WAL cannot be appended to before reading out all of its // previous records.
[ "Open", "opens", "the", "WAL", "at", "the", "given", "snap", ".", "The", "snap", "SHOULD", "have", "been", "previously", "saved", "to", "the", "WAL", "or", "the", "following", "ReadAll", "will", "fail", ".", "The", "returned", "WAL", "is", "ready", "to",...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/wal.go#L284-L293
test
etcd-io/etcd
wal/wal.go
OpenForRead
func OpenForRead(lg *zap.Logger, dirpath string, snap walpb.Snapshot) (*WAL, error) { return openAtIndex(lg, dirpath, snap, false) }
go
func OpenForRead(lg *zap.Logger, dirpath string, snap walpb.Snapshot) (*WAL, error) { return openAtIndex(lg, dirpath, snap, false) }
[ "func", "OpenForRead", "(", "lg", "*", "zap", ".", "Logger", ",", "dirpath", "string", ",", "snap", "walpb", ".", "Snapshot", ")", "(", "*", "WAL", ",", "error", ")", "{", "return", "openAtIndex", "(", "lg", ",", "dirpath", ",", "snap", ",", "false",...
// OpenForRead only opens the wal files for read. // Write on a read only wal panics.
[ "OpenForRead", "only", "opens", "the", "wal", "files", "for", "read", ".", "Write", "on", "a", "read", "only", "wal", "panics", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/wal.go#L297-L299
test
etcd-io/etcd
wal/wal.go
Verify
func Verify(lg *zap.Logger, walDir string, snap walpb.Snapshot) error { var metadata []byte var err error var match bool rec := &walpb.Record{} names, nameIndex, err := selectWALFiles(lg, walDir, snap) if err != nil { return err } // open wal files in read mode, so that there is no conflict // when the sa...
go
func Verify(lg *zap.Logger, walDir string, snap walpb.Snapshot) error { var metadata []byte var err error var match bool rec := &walpb.Record{} names, nameIndex, err := selectWALFiles(lg, walDir, snap) if err != nil { return err } // open wal files in read mode, so that there is no conflict // when the sa...
[ "func", "Verify", "(", "lg", "*", "zap", ".", "Logger", ",", "walDir", "string", ",", "snap", "walpb", ".", "Snapshot", ")", "error", "{", "var", "metadata", "[", "]", "byte", "\n", "var", "err", "error", "\n", "var", "match", "bool", "\n", "rec", ...
// Verify reads through the given WAL and verifies that it is not corrupted. // It creates a new decoder to read through the records of the given WAL. // It does not conflict with any open WAL, but it is recommended not to // call this function after opening the WAL for writing. // If it cannot read out the expected sn...
[ "Verify", "reads", "through", "the", "given", "WAL", "and", "verifies", "that", "it", "is", "not", "corrupted", ".", "It", "creates", "a", "new", "decoder", "to", "read", "through", "the", "records", "of", "the", "given", "WAL", ".", "It", "does", "not",...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/wal.go#L508-L578
test
etcd-io/etcd
wal/wal.go
Close
func (w *WAL) Close() error { w.mu.Lock() defer w.mu.Unlock() if w.fp != nil { w.fp.Close() w.fp = nil } if w.tail() != nil { if err := w.sync(); err != nil { return err } } for _, l := range w.locks { if l == nil { continue } if err := l.Close(); err != nil { if w.lg != nil { w.lg.W...
go
func (w *WAL) Close() error { w.mu.Lock() defer w.mu.Unlock() if w.fp != nil { w.fp.Close() w.fp = nil } if w.tail() != nil { if err := w.sync(); err != nil { return err } } for _, l := range w.locks { if l == nil { continue } if err := l.Close(); err != nil { if w.lg != nil { w.lg.W...
[ "func", "(", "w", "*", "WAL", ")", "Close", "(", ")", "error", "{", "w", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "w", ".", "fp", "!=", "nil", "{", "w", ".", "fp", ".", "Close",...
// Close closes the current WAL file and directory.
[ "Close", "closes", "the", "current", "WAL", "file", "and", "directory", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/wal.go#L743-L771
test
etcd-io/etcd
etcdserver/api/v2store/watcher.go
notify
func (w *watcher) notify(e *Event, originalPath bool, deleted bool) bool { // watcher is interested the path in three cases and under one condition // the condition is that the event happens after the watcher's sinceIndex // 1. the path at which the event happens is the path the watcher is watching at. // For exam...
go
func (w *watcher) notify(e *Event, originalPath bool, deleted bool) bool { // watcher is interested the path in three cases and under one condition // the condition is that the event happens after the watcher's sinceIndex // 1. the path at which the event happens is the path the watcher is watching at. // For exam...
[ "func", "(", "w", "*", "watcher", ")", "notify", "(", "e", "*", "Event", ",", "originalPath", "bool", ",", "deleted", "bool", ")", "bool", "{", "if", "(", "w", ".", "recursive", "||", "originalPath", "||", "deleted", ")", "&&", "e", ".", "Index", "...
// notify function notifies the watcher. If the watcher interests in the given path, // the function will return true.
[ "notify", "function", "notifies", "the", "watcher", ".", "If", "the", "watcher", "interests", "in", "the", "given", "path", "the", "function", "will", "return", "true", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/watcher.go#L44-L75
test
etcd-io/etcd
etcdserver/api/v2store/watcher.go
Remove
func (w *watcher) Remove() { w.hub.mutex.Lock() defer w.hub.mutex.Unlock() close(w.eventChan) if w.remove != nil { w.remove() } }
go
func (w *watcher) Remove() { w.hub.mutex.Lock() defer w.hub.mutex.Unlock() close(w.eventChan) if w.remove != nil { w.remove() } }
[ "func", "(", "w", "*", "watcher", ")", "Remove", "(", ")", "{", "w", ".", "hub", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "hub", ".", "mutex", ".", "Unlock", "(", ")", "\n", "close", "(", "w", ".", "eventChan", ")", "\n",...
// Remove removes the watcher from watcherHub // The actual remove function is guaranteed to only be executed once
[ "Remove", "removes", "the", "watcher", "from", "watcherHub", "The", "actual", "remove", "function", "is", "guaranteed", "to", "only", "be", "executed", "once" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/watcher.go#L79-L87
test
etcd-io/etcd
etcdserver/api/v2v3/store.go
mkPathDepth
func (s *v2v3Store) mkPathDepth(nodePath string, depth int) string { normalForm := path.Clean(path.Join("/", nodePath)) n := strings.Count(normalForm, "/") + depth return fmt.Sprintf("%s/%03d/k/%s", s.pfx, n, normalForm) }
go
func (s *v2v3Store) mkPathDepth(nodePath string, depth int) string { normalForm := path.Clean(path.Join("/", nodePath)) n := strings.Count(normalForm, "/") + depth return fmt.Sprintf("%s/%03d/k/%s", s.pfx, n, normalForm) }
[ "func", "(", "s", "*", "v2v3Store", ")", "mkPathDepth", "(", "nodePath", "string", ",", "depth", "int", ")", "string", "{", "normalForm", ":=", "path", ".", "Clean", "(", "path", ".", "Join", "(", "\"/\"", ",", "nodePath", ")", ")", "\n", "n", ":=", ...
// mkPathDepth makes a path to a key that encodes its directory depth // for fast directory listing. If a depth is provided, it is added // to the computed depth.
[ "mkPathDepth", "makes", "a", "path", "to", "a", "key", "that", "encodes", "its", "directory", "depth", "for", "fast", "directory", "listing", ".", "If", "a", "depth", "is", "provided", "it", "is", "added", "to", "the", "computed", "depth", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2v3/store.go#L582-L586
test
etcd-io/etcd
etcdserver/api/v2v3/store.go
mkV2Node
func (s *v2v3Store) mkV2Node(kv *mvccpb.KeyValue) *v2store.NodeExtern { if kv == nil { return nil } n := &v2store.NodeExtern{ Key: s.mkNodePath(string(kv.Key)), Dir: kv.Key[len(kv.Key)-1] == '/', CreatedIndex: mkV2Rev(kv.CreateRevision), ModifiedIndex: mkV2Rev(kv.ModRevision), } if !...
go
func (s *v2v3Store) mkV2Node(kv *mvccpb.KeyValue) *v2store.NodeExtern { if kv == nil { return nil } n := &v2store.NodeExtern{ Key: s.mkNodePath(string(kv.Key)), Dir: kv.Key[len(kv.Key)-1] == '/', CreatedIndex: mkV2Rev(kv.CreateRevision), ModifiedIndex: mkV2Rev(kv.ModRevision), } if !...
[ "func", "(", "s", "*", "v2v3Store", ")", "mkV2Node", "(", "kv", "*", "mvccpb", ".", "KeyValue", ")", "*", "v2store", ".", "NodeExtern", "{", "if", "kv", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "n", ":=", "&", "v2store", ".", "NodeExtern...
// mkV2Node creates a V2 NodeExtern from a V3 KeyValue
[ "mkV2Node", "creates", "a", "V2", "NodeExtern", "from", "a", "V3", "KeyValue" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2v3/store.go#L607-L622
test
etcd-io/etcd
etcdserver/api/v2v3/store.go
prevKeyFromPuts
func prevKeyFromPuts(resp *clientv3.TxnResponse) *mvccpb.KeyValue { for _, r := range resp.Responses { pkv := r.GetResponsePut().PrevKv if pkv != nil && pkv.CreateRevision > 0 { return pkv } } return nil }
go
func prevKeyFromPuts(resp *clientv3.TxnResponse) *mvccpb.KeyValue { for _, r := range resp.Responses { pkv := r.GetResponsePut().PrevKv if pkv != nil && pkv.CreateRevision > 0 { return pkv } } return nil }
[ "func", "prevKeyFromPuts", "(", "resp", "*", "clientv3", ".", "TxnResponse", ")", "*", "mvccpb", ".", "KeyValue", "{", "for", "_", ",", "r", ":=", "range", "resp", ".", "Responses", "{", "pkv", ":=", "r", ".", "GetResponsePut", "(", ")", ".", "PrevKv",...
// prevKeyFromPuts gets the prev key that is being put; ignores // the put action response.
[ "prevKeyFromPuts", "gets", "the", "prev", "key", "that", "is", "being", "put", ";", "ignores", "the", "put", "action", "response", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2v3/store.go#L626-L634
test
etcd-io/etcd
pkg/report/weighted.go
NewWeightedReport
func NewWeightedReport(r Report, precision string) Report { return &weightedReport{ baseReport: r, report: newReport(precision), results: make(chan Result, 16), } }
go
func NewWeightedReport(r Report, precision string) Report { return &weightedReport{ baseReport: r, report: newReport(precision), results: make(chan Result, 16), } }
[ "func", "NewWeightedReport", "(", "r", "Report", ",", "precision", "string", ")", "Report", "{", "return", "&", "weightedReport", "{", "baseReport", ":", "r", ",", "report", ":", "newReport", "(", "precision", ")", ",", "results", ":", "make", "(", "chan",...
// NewWeightedReport returns a report that includes // both weighted and unweighted statistics.
[ "NewWeightedReport", "returns", "a", "report", "that", "includes", "both", "weighted", "and", "unweighted", "statistics", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/report/weighted.go#L33-L39
test
etcd-io/etcd
pkg/types/urlsmap.go
NewURLsMapFromStringMap
func NewURLsMapFromStringMap(m map[string]string, sep string) (URLsMap, error) { var err error um := URLsMap{} for k, v := range m { um[k], err = NewURLs(strings.Split(v, sep)) if err != nil { return nil, err } } return um, nil }
go
func NewURLsMapFromStringMap(m map[string]string, sep string) (URLsMap, error) { var err error um := URLsMap{} for k, v := range m { um[k], err = NewURLs(strings.Split(v, sep)) if err != nil { return nil, err } } return um, nil }
[ "func", "NewURLsMapFromStringMap", "(", "m", "map", "[", "string", "]", "string", ",", "sep", "string", ")", "(", "URLsMap", ",", "error", ")", "{", "var", "err", "error", "\n", "um", ":=", "URLsMap", "{", "}", "\n", "for", "k", ",", "v", ":=", "ra...
// NewURLsMapFromStringMap takes a map of strings and returns a URLsMap. The // string values in the map can be multiple values separated by the sep string.
[ "NewURLsMapFromStringMap", "takes", "a", "map", "of", "strings", "and", "returns", "a", "URLsMap", ".", "The", "string", "values", "in", "the", "map", "can", "be", "multiple", "values", "separated", "by", "the", "sep", "string", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/urlsmap.go#L45-L55
test
etcd-io/etcd
pkg/types/urlsmap.go
String
func (c URLsMap) String() string { var pairs []string for name, urls := range c { for _, url := range urls { pairs = append(pairs, fmt.Sprintf("%s=%s", name, url.String())) } } sort.Strings(pairs) return strings.Join(pairs, ",") }
go
func (c URLsMap) String() string { var pairs []string for name, urls := range c { for _, url := range urls { pairs = append(pairs, fmt.Sprintf("%s=%s", name, url.String())) } } sort.Strings(pairs) return strings.Join(pairs, ",") }
[ "func", "(", "c", "URLsMap", ")", "String", "(", ")", "string", "{", "var", "pairs", "[", "]", "string", "\n", "for", "name", ",", "urls", ":=", "range", "c", "{", "for", "_", ",", "url", ":=", "range", "urls", "{", "pairs", "=", "append", "(", ...
// String turns URLsMap into discovery-formatted name-to-URLs sorted by name.
[ "String", "turns", "URLsMap", "into", "discovery", "-", "formatted", "name", "-", "to", "-", "URLs", "sorted", "by", "name", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/urlsmap.go#L58-L67
test
etcd-io/etcd
pkg/types/urlsmap.go
URLs
func (c URLsMap) URLs() []string { var urls []string for _, us := range c { for _, u := range us { urls = append(urls, u.String()) } } sort.Strings(urls) return urls }
go
func (c URLsMap) URLs() []string { var urls []string for _, us := range c { for _, u := range us { urls = append(urls, u.String()) } } sort.Strings(urls) return urls }
[ "func", "(", "c", "URLsMap", ")", "URLs", "(", ")", "[", "]", "string", "{", "var", "urls", "[", "]", "string", "\n", "for", "_", ",", "us", ":=", "range", "c", "{", "for", "_", ",", "u", ":=", "range", "us", "{", "urls", "=", "append", "(", ...
// URLs returns a list of all URLs. // The returned list is sorted in ascending lexicographical order.
[ "URLs", "returns", "a", "list", "of", "all", "URLs", ".", "The", "returned", "list", "is", "sorted", "in", "ascending", "lexicographical", "order", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/urlsmap.go#L71-L80
test
etcd-io/etcd
pkg/types/urlsmap.go
parse
func parse(s string) map[string][]string { m := make(map[string][]string) for s != "" { key := s if i := strings.IndexAny(key, ","); i >= 0 { key, s = key[:i], key[i+1:] } else { s = "" } if key == "" { continue } value := "" if i := strings.Index(key, "="); i >= 0 { key, value = key[:i], ...
go
func parse(s string) map[string][]string { m := make(map[string][]string) for s != "" { key := s if i := strings.IndexAny(key, ","); i >= 0 { key, s = key[:i], key[i+1:] } else { s = "" } if key == "" { continue } value := "" if i := strings.Index(key, "="); i >= 0 { key, value = key[:i], ...
[ "func", "parse", "(", "s", "string", ")", "map", "[", "string", "]", "[", "]", "string", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "[", "]", "string", ")", "\n", "for", "s", "!=", "\"\"", "{", "key", ":=", "s", "\n", "if", "i", ...
// parse parses the given string and returns a map listing the values specified for each key.
[ "parse", "parses", "the", "given", "string", "and", "returns", "a", "map", "listing", "the", "values", "specified", "for", "each", "key", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/urlsmap.go#L88-L107
test
etcd-io/etcd
etcdserver/api/v2http/client.go
NewClientHandler
func NewClientHandler(lg *zap.Logger, server etcdserver.ServerPeer, timeout time.Duration) http.Handler { mux := http.NewServeMux() etcdhttp.HandleBasic(mux, server) handleV2(lg, mux, server, timeout) return requestLogger(lg, mux) }
go
func NewClientHandler(lg *zap.Logger, server etcdserver.ServerPeer, timeout time.Duration) http.Handler { mux := http.NewServeMux() etcdhttp.HandleBasic(mux, server) handleV2(lg, mux, server, timeout) return requestLogger(lg, mux) }
[ "func", "NewClientHandler", "(", "lg", "*", "zap", ".", "Logger", ",", "server", "etcdserver", ".", "ServerPeer", ",", "timeout", "time", ".", "Duration", ")", "http", ".", "Handler", "{", "mux", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "etcdhtt...
// NewClientHandler generates a muxed http.Handler with the given parameters to serve etcd client requests.
[ "NewClientHandler", "generates", "a", "muxed", "http", ".", "Handler", "with", "the", "given", "parameters", "to", "serve", "etcd", "client", "requests", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L55-L60
test
etcd-io/etcd
etcdserver/api/v2http/client.go
writeKeyEvent
func writeKeyEvent(w http.ResponseWriter, resp etcdserver.Response, noValueOnSuccess bool) error { ev := resp.Event if ev == nil { return errors.New("cannot write empty Event") } w.Header().Set("Content-Type", "application/json") w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex)) w.Header().Set("X-Raft-In...
go
func writeKeyEvent(w http.ResponseWriter, resp etcdserver.Response, noValueOnSuccess bool) error { ev := resp.Event if ev == nil { return errors.New("cannot write empty Event") } w.Header().Set("Content-Type", "application/json") w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex)) w.Header().Set("X-Raft-In...
[ "func", "writeKeyEvent", "(", "w", "http", ".", "ResponseWriter", ",", "resp", "etcdserver", ".", "Response", ",", "noValueOnSuccess", "bool", ")", "error", "{", "ev", ":=", "resp", ".", "Event", "\n", "if", "ev", "==", "nil", "{", "return", "errors", "....
// writeKeyEvent trims the prefix of key path in a single Event under // StoreKeysPrefix, serializes it and writes the resulting JSON to the given // ResponseWriter, along with the appropriate headers.
[ "writeKeyEvent", "trims", "the", "prefix", "of", "key", "path", "in", "a", "single", "Event", "under", "StoreKeysPrefix", "serializes", "it", "and", "writes", "the", "resulting", "JSON", "to", "the", "given", "ResponseWriter", "along", "with", "the", "appropriat...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L556-L578
test
etcd-io/etcd
etcdserver/api/v2http/client.go
writeKeyError
func writeKeyError(lg *zap.Logger, w http.ResponseWriter, err error) { if err == nil { return } switch e := err.(type) { case *v2error.Error: e.WriteTo(w) default: switch err { case etcdserver.ErrTimeoutDueToLeaderFail, etcdserver.ErrTimeoutDueToConnectionLost: if lg != nil { lg.Warn( "v2 respo...
go
func writeKeyError(lg *zap.Logger, w http.ResponseWriter, err error) { if err == nil { return } switch e := err.(type) { case *v2error.Error: e.WriteTo(w) default: switch err { case etcdserver.ErrTimeoutDueToLeaderFail, etcdserver.ErrTimeoutDueToConnectionLost: if lg != nil { lg.Warn( "v2 respo...
[ "func", "writeKeyError", "(", "lg", "*", "zap", ".", "Logger", ",", "w", "http", ".", "ResponseWriter", ",", "err", "error", ")", "{", "if", "err", "==", "nil", "{", "return", "\n", "}", "\n", "switch", "e", ":=", "err", ".", "(", "type", ")", "{...
// writeKeyError logs and writes the given Error to the ResponseWriter. // If Error is not an etcdErr, the error will be converted to an etcd error.
[ "writeKeyError", "logs", "and", "writes", "the", "given", "Error", "to", "the", "ResponseWriter", ".", "If", "Error", "is", "not", "an", "etcdErr", "the", "error", "will", "be", "converted", "to", "an", "etcd", "error", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L587-L618
test
etcd-io/etcd
etcdserver/api/v2http/client.go
getUint64
func getUint64(form url.Values, key string) (i uint64, err error) { if vals, ok := form[key]; ok { i, err = strconv.ParseUint(vals[0], 10, 64) } return }
go
func getUint64(form url.Values, key string) (i uint64, err error) { if vals, ok := form[key]; ok { i, err = strconv.ParseUint(vals[0], 10, 64) } return }
[ "func", "getUint64", "(", "form", "url", ".", "Values", ",", "key", "string", ")", "(", "i", "uint64", ",", "err", "error", ")", "{", "if", "vals", ",", "ok", ":=", "form", "[", "key", "]", ";", "ok", "{", "i", ",", "err", "=", "strconv", ".", ...
// getUint64 extracts a uint64 by the given key from a Form. If the key does // not exist in the form, 0 is returned. If the key exists but the value is // badly formed, an error is returned. If multiple values are present only the // first is considered.
[ "getUint64", "extracts", "a", "uint64", "by", "the", "given", "key", "from", "a", "Form", ".", "If", "the", "key", "does", "not", "exist", "in", "the", "form", "0", "is", "returned", ".", "If", "the", "key", "exists", "but", "the", "value", "is", "ba...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L740-L745
test
etcd-io/etcd
etcdserver/api/v2http/client.go
getBool
func getBool(form url.Values, key string) (b bool, err error) { if vals, ok := form[key]; ok { b, err = strconv.ParseBool(vals[0]) } return }
go
func getBool(form url.Values, key string) (b bool, err error) { if vals, ok := form[key]; ok { b, err = strconv.ParseBool(vals[0]) } return }
[ "func", "getBool", "(", "form", "url", ".", "Values", ",", "key", "string", ")", "(", "b", "bool", ",", "err", "error", ")", "{", "if", "vals", ",", "ok", ":=", "form", "[", "key", "]", ";", "ok", "{", "b", ",", "err", "=", "strconv", ".", "P...
// getBool extracts a bool by the given key from a Form. If the key does not // exist in the form, false is returned. If the key exists but the value is // badly formed, an error is returned. If multiple values are present only the // first is considered.
[ "getBool", "extracts", "a", "bool", "by", "the", "given", "key", "from", "a", "Form", ".", "If", "the", "key", "does", "not", "exist", "in", "the", "form", "false", "is", "returned", ".", "If", "the", "key", "exists", "but", "the", "value", "is", "ba...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L751-L756
test
etcd-io/etcd
clientv3/concurrency/key.go
waitDeletes
func waitDeletes(ctx context.Context, client *v3.Client, pfx string, maxCreateRev int64) (*pb.ResponseHeader, error) { getOpts := append(v3.WithLastCreate(), v3.WithMaxCreateRev(maxCreateRev)) for { resp, err := client.Get(ctx, pfx, getOpts...) if err != nil { return nil, err } if len(resp.Kvs) == 0 { r...
go
func waitDeletes(ctx context.Context, client *v3.Client, pfx string, maxCreateRev int64) (*pb.ResponseHeader, error) { getOpts := append(v3.WithLastCreate(), v3.WithMaxCreateRev(maxCreateRev)) for { resp, err := client.Get(ctx, pfx, getOpts...) if err != nil { return nil, err } if len(resp.Kvs) == 0 { r...
[ "func", "waitDeletes", "(", "ctx", "context", ".", "Context", ",", "client", "*", "v3", ".", "Client", ",", "pfx", "string", ",", "maxCreateRev", "int64", ")", "(", "*", "pb", ".", "ResponseHeader", ",", "error", ")", "{", "getOpts", ":=", "append", "(...
// waitDeletes efficiently waits until all keys matching the prefix and no greater // than the create revision.
[ "waitDeletes", "efficiently", "waits", "until", "all", "keys", "matching", "the", "prefix", "and", "no", "greater", "than", "the", "create", "revision", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/key.go#L50-L65
test
etcd-io/etcd
pkg/logutil/zap.go
AddOutputPaths
func AddOutputPaths(cfg zap.Config, outputPaths, errorOutputPaths []string) zap.Config { outputs := make(map[string]struct{}) for _, v := range cfg.OutputPaths { outputs[v] = struct{}{} } for _, v := range outputPaths { outputs[v] = struct{}{} } outputSlice := make([]string, 0) if _, ok := outputs["/dev/null...
go
func AddOutputPaths(cfg zap.Config, outputPaths, errorOutputPaths []string) zap.Config { outputs := make(map[string]struct{}) for _, v := range cfg.OutputPaths { outputs[v] = struct{}{} } for _, v := range outputPaths { outputs[v] = struct{}{} } outputSlice := make([]string, 0) if _, ok := outputs["/dev/null...
[ "func", "AddOutputPaths", "(", "cfg", "zap", ".", "Config", ",", "outputPaths", ",", "errorOutputPaths", "[", "]", "string", ")", "zap", ".", "Config", "{", "outputs", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "for", ...
// AddOutputPaths adds output paths to the existing output paths, resolving conflicts.
[ "AddOutputPaths", "adds", "output", "paths", "to", "the", "existing", "output", "paths", "resolving", "conflicts", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/logutil/zap.go#L57-L97
test
etcd-io/etcd
embed/config.go
NewConfig
func NewConfig() *Config { lpurl, _ := url.Parse(DefaultListenPeerURLs) apurl, _ := url.Parse(DefaultInitialAdvertisePeerURLs) lcurl, _ := url.Parse(DefaultListenClientURLs) acurl, _ := url.Parse(DefaultAdvertiseClientURLs) cfg := &Config{ MaxSnapFiles: DefaultMaxSnapshots, MaxWalFiles: DefaultMaxWALs, Nam...
go
func NewConfig() *Config { lpurl, _ := url.Parse(DefaultListenPeerURLs) apurl, _ := url.Parse(DefaultInitialAdvertisePeerURLs) lcurl, _ := url.Parse(DefaultListenClientURLs) acurl, _ := url.Parse(DefaultAdvertiseClientURLs) cfg := &Config{ MaxSnapFiles: DefaultMaxSnapshots, MaxWalFiles: DefaultMaxWALs, Nam...
[ "func", "NewConfig", "(", ")", "*", "Config", "{", "lpurl", ",", "_", ":=", "url", ".", "Parse", "(", "DefaultListenPeerURLs", ")", "\n", "apurl", ",", "_", ":=", "url", ".", "Parse", "(", "DefaultInitialAdvertisePeerURLs", ")", "\n", "lcurl", ",", "_", ...
// NewConfig creates a new Config populated with default values.
[ "NewConfig", "creates", "a", "new", "Config", "populated", "with", "default", "values", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/embed/config.go#L366-L421
test
etcd-io/etcd
embed/config.go
PeerURLsMapAndToken
func (cfg *Config) PeerURLsMapAndToken(which string) (urlsmap types.URLsMap, token string, err error) { token = cfg.InitialClusterToken switch { case cfg.Durl != "": urlsmap = types.URLsMap{} // If using discovery, generate a temporary cluster based on // self's advertised peer URLs urlsmap[cfg.Name] = cfg.A...
go
func (cfg *Config) PeerURLsMapAndToken(which string) (urlsmap types.URLsMap, token string, err error) { token = cfg.InitialClusterToken switch { case cfg.Durl != "": urlsmap = types.URLsMap{} // If using discovery, generate a temporary cluster based on // self's advertised peer URLs urlsmap[cfg.Name] = cfg.A...
[ "func", "(", "cfg", "*", "Config", ")", "PeerURLsMapAndToken", "(", "which", "string", ")", "(", "urlsmap", "types", ".", "URLsMap", ",", "token", "string", ",", "err", "error", ")", "{", "token", "=", "cfg", ".", "InitialClusterToken", "\n", "switch", "...
// PeerURLsMapAndToken sets up an initial peer URLsMap and cluster token for bootstrap or discovery.
[ "PeerURLsMapAndToken", "sets", "up", "an", "initial", "peer", "URLsMap", "and", "cluster", "token", "for", "bootstrap", "or", "discovery", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/embed/config.go#L619-L665
test
etcd-io/etcd
embed/config.go
GetDNSClusterNames
func (cfg *Config) GetDNSClusterNames() ([]string, error) { var ( clusterStrs []string cerr error serviceNameSuffix string ) if cfg.DNSClusterServiceName != "" { serviceNameSuffix = "-" + cfg.DNSClusterServiceName } lg := cfg.GetLogger() // Use both etcd-server-ssl and etcd-server for...
go
func (cfg *Config) GetDNSClusterNames() ([]string, error) { var ( clusterStrs []string cerr error serviceNameSuffix string ) if cfg.DNSClusterServiceName != "" { serviceNameSuffix = "-" + cfg.DNSClusterServiceName } lg := cfg.GetLogger() // Use both etcd-server-ssl and etcd-server for...
[ "func", "(", "cfg", "*", "Config", ")", "GetDNSClusterNames", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "(", "clusterStrs", "[", "]", "string", "\n", "cerr", "error", "\n", "serviceNameSuffix", "string", "\n", ")", "\n", "if", ...
// GetDNSClusterNames uses DNS SRV records to get a list of initial nodes for cluster bootstrapping.
[ "GetDNSClusterNames", "uses", "DNS", "SRV", "records", "to", "get", "a", "list", "of", "initial", "nodes", "for", "cluster", "bootstrapping", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/embed/config.go#L668-L717
test
etcd-io/etcd
embed/config.go
checkBindURLs
func checkBindURLs(urls []url.URL) error { for _, url := range urls { if url.Scheme == "unix" || url.Scheme == "unixs" { continue } host, _, err := net.SplitHostPort(url.Host) if err != nil { return err } if host == "localhost" { // special case for local address // TODO: support /etc/hosts ? ...
go
func checkBindURLs(urls []url.URL) error { for _, url := range urls { if url.Scheme == "unix" || url.Scheme == "unixs" { continue } host, _, err := net.SplitHostPort(url.Host) if err != nil { return err } if host == "localhost" { // special case for local address // TODO: support /etc/hosts ? ...
[ "func", "checkBindURLs", "(", "urls", "[", "]", "url", ".", "URL", ")", "error", "{", "for", "_", ",", "url", ":=", "range", "urls", "{", "if", "url", ".", "Scheme", "==", "\"unix\"", "||", "url", ".", "Scheme", "==", "\"unixs\"", "{", "continue", ...
// checkBindURLs returns an error if any URL uses a domain name.
[ "checkBindURLs", "returns", "an", "error", "if", "any", "URL", "uses", "a", "domain", "name", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/embed/config.go#L831-L850
test
etcd-io/etcd
pkg/srv/srv.go
GetCluster
func GetCluster(serviceScheme, service, name, dns string, apurls types.URLs) ([]string, error) { tempName := int(0) tcp2ap := make(map[string]url.URL) // First, resolve the apurls for _, url := range apurls { tcpAddr, err := resolveTCPAddr("tcp", url.Host) if err != nil { return nil, err } tcp2ap[tcpAdd...
go
func GetCluster(serviceScheme, service, name, dns string, apurls types.URLs) ([]string, error) { tempName := int(0) tcp2ap := make(map[string]url.URL) // First, resolve the apurls for _, url := range apurls { tcpAddr, err := resolveTCPAddr("tcp", url.Host) if err != nil { return nil, err } tcp2ap[tcpAdd...
[ "func", "GetCluster", "(", "serviceScheme", ",", "service", ",", "name", ",", "dns", "string", ",", "apurls", "types", ".", "URLs", ")", "(", "[", "]", "string", ",", "error", ")", "{", "tempName", ":=", "int", "(", "0", ")", "\n", "tcp2ap", ":=", ...
// GetCluster gets the cluster information via DNS discovery. // Also sees each entry as a separate instance.
[ "GetCluster", "gets", "the", "cluster", "information", "via", "DNS", "discovery", ".", "Also", "sees", "each", "entry", "as", "a", "separate", "instance", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/srv/srv.go#L35-L91
test
etcd-io/etcd
pkg/srv/srv.go
GetClient
func GetClient(service, domain string, serviceName string) (*SRVClients, error) { var urls []*url.URL var srvs []*net.SRV updateURLs := func(service, scheme string) error { _, addrs, err := lookupSRV(service, "tcp", domain) if err != nil { return err } for _, srv := range addrs { urls = append(urls, &...
go
func GetClient(service, domain string, serviceName string) (*SRVClients, error) { var urls []*url.URL var srvs []*net.SRV updateURLs := func(service, scheme string) error { _, addrs, err := lookupSRV(service, "tcp", domain) if err != nil { return err } for _, srv := range addrs { urls = append(urls, &...
[ "func", "GetClient", "(", "service", ",", "domain", "string", ",", "serviceName", "string", ")", "(", "*", "SRVClients", ",", "error", ")", "{", "var", "urls", "[", "]", "*", "url", ".", "URL", "\n", "var", "srvs", "[", "]", "*", "net", ".", "SRV",...
// GetClient looks up the client endpoints for a service and domain.
[ "GetClient", "looks", "up", "the", "client", "endpoints", "for", "a", "service", "and", "domain", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/srv/srv.go#L99-L130
test
etcd-io/etcd
pkg/srv/srv.go
GetSRVService
func GetSRVService(service, serviceName string, scheme string) (SRVService string) { if scheme == "https" { service = fmt.Sprintf("%s-ssl", service) } if serviceName != "" { return fmt.Sprintf("%s-%s", service, serviceName) } return service }
go
func GetSRVService(service, serviceName string, scheme string) (SRVService string) { if scheme == "https" { service = fmt.Sprintf("%s-ssl", service) } if serviceName != "" { return fmt.Sprintf("%s-%s", service, serviceName) } return service }
[ "func", "GetSRVService", "(", "service", ",", "serviceName", "string", ",", "scheme", "string", ")", "(", "SRVService", "string", ")", "{", "if", "scheme", "==", "\"https\"", "{", "service", "=", "fmt", ".", "Sprintf", "(", "\"%s-ssl\"", ",", "service", ")...
// GetSRVService generates a SRV service including an optional suffix.
[ "GetSRVService", "generates", "a", "SRV", "service", "including", "an", "optional", "suffix", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/srv/srv.go#L133-L142
test
etcd-io/etcd
pkg/fileutil/read_dir.go
ReadDir
func ReadDir(d string, opts ...ReadDirOption) ([]string, error) { op := &ReadDirOp{} op.applyOpts(opts) dir, err := os.Open(d) if err != nil { return nil, err } defer dir.Close() names, err := dir.Readdirnames(-1) if err != nil { return nil, err } sort.Strings(names) if op.ext != "" { tss := make([]...
go
func ReadDir(d string, opts ...ReadDirOption) ([]string, error) { op := &ReadDirOp{} op.applyOpts(opts) dir, err := os.Open(d) if err != nil { return nil, err } defer dir.Close() names, err := dir.Readdirnames(-1) if err != nil { return nil, err } sort.Strings(names) if op.ext != "" { tss := make([]...
[ "func", "ReadDir", "(", "d", "string", ",", "opts", "...", "ReadDirOption", ")", "(", "[", "]", "string", ",", "error", ")", "{", "op", ":=", "&", "ReadDirOp", "{", "}", "\n", "op", ".", "applyOpts", "(", "opts", ")", "\n", "dir", ",", "err", ":=...
// ReadDir returns the filenames in the given directory in sorted order.
[ "ReadDir", "returns", "the", "filenames", "in", "the", "given", "directory", "in", "sorted", "order", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/fileutil/read_dir.go#L44-L70
test
etcd-io/etcd
etcdctl/ctlv3/command/util.go
compact
func compact(c *v3.Client, rev int64) { fmt.Printf("Compacting with revision %d\n", rev) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) _, err := c.Compact(ctx, rev, v3.WithCompactPhysical()) cancel() if err != nil { ExitWithError(ExitError, err) } fmt.Printf("Compacted with revision ...
go
func compact(c *v3.Client, rev int64) { fmt.Printf("Compacting with revision %d\n", rev) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) _, err := c.Compact(ctx, rev, v3.WithCompactPhysical()) cancel() if err != nil { ExitWithError(ExitError, err) } fmt.Printf("Compacted with revision ...
[ "func", "compact", "(", "c", "*", "v3", ".", "Client", ",", "rev", "int64", ")", "{", "fmt", ".", "Printf", "(", "\"Compacting with revision %d\\n\"", ",", "\\n", ")", "\n", "rev", "\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "...
// compact keyspace history to a provided revision
[ "compact", "keyspace", "history", "to", "a", "provided", "revision" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/util.go#L133-L142
test
etcd-io/etcd
etcdctl/ctlv3/command/util.go
defrag
func defrag(c *v3.Client, ep string) { fmt.Printf("Defragmenting %q\n", ep) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) _, err := c.Defragment(ctx, ep) cancel() if err != nil { ExitWithError(ExitError, err) } fmt.Printf("Defragmented %q\n", ep) }
go
func defrag(c *v3.Client, ep string) { fmt.Printf("Defragmenting %q\n", ep) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) _, err := c.Defragment(ctx, ep) cancel() if err != nil { ExitWithError(ExitError, err) } fmt.Printf("Defragmented %q\n", ep) }
[ "func", "defrag", "(", "c", "*", "v3", ".", "Client", ",", "ep", "string", ")", "{", "fmt", ".", "Printf", "(", "\"Defragmenting %q\\n\"", ",", "\\n", ")", "\n", "ep", "\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", "...
// defrag a given endpoint
[ "defrag", "a", "given", "endpoint" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/util.go#L145-L154
test
etcd-io/etcd
etcdctl/ctlv3/command/user_command.go
NewUserCommand
func NewUserCommand() *cobra.Command { ac := &cobra.Command{ Use: "user <subcommand>", Short: "User related commands", } ac.AddCommand(newUserAddCommand()) ac.AddCommand(newUserDeleteCommand()) ac.AddCommand(newUserGetCommand()) ac.AddCommand(newUserListCommand()) ac.AddCommand(newUserChangePasswordComman...
go
func NewUserCommand() *cobra.Command { ac := &cobra.Command{ Use: "user <subcommand>", Short: "User related commands", } ac.AddCommand(newUserAddCommand()) ac.AddCommand(newUserDeleteCommand()) ac.AddCommand(newUserGetCommand()) ac.AddCommand(newUserListCommand()) ac.AddCommand(newUserChangePasswordComman...
[ "func", "NewUserCommand", "(", ")", "*", "cobra", ".", "Command", "{", "ac", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"user <subcommand>\"", ",", "Short", ":", "\"User related commands\"", ",", "}", "\n", "ac", ".", "AddCommand", "(", "newUse...
// NewUserCommand returns the cobra command for "user".
[ "NewUserCommand", "returns", "the", "cobra", "command", "for", "user", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/user_command.go#L31-L46
test
etcd-io/etcd
etcdctl/ctlv3/command/user_command.go
userAddCommandFunc
func userAddCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("user add command requires user name as its argument")) } var password string var user string if passwordFromFlag != "" { user = args[0] password = passwordFromFlag } else { splitted :=...
go
func userAddCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("user add command requires user name as its argument")) } var password string var user string if passwordFromFlag != "" { user = args[0] password = passwordFromFlag } else { splitted :=...
[ "func", "userAddCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"user add command req...
// userAddCommandFunc executes the "user add" command.
[ "userAddCommandFunc", "executes", "the", "user", "add", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/user_command.go#L123-L158
test
etcd-io/etcd
etcdctl/ctlv3/command/user_command.go
userGetCommandFunc
func userGetCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("user get command requires user name as its argument")) } name := args[0] client := mustClientFromCmd(cmd) resp, err := client.Auth.UserGet(context.TODO(), name) if err != nil { ExitWithErro...
go
func userGetCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("user get command requires user name as its argument")) } name := args[0] client := mustClientFromCmd(cmd) resp, err := client.Auth.UserGet(context.TODO(), name) if err != nil { ExitWithErro...
[ "func", "userGetCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"user get command req...
// userGetCommandFunc executes the "user get" command.
[ "userGetCommandFunc", "executes", "the", "user", "get", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/user_command.go#L174-L199
test
etcd-io/etcd
etcdctl/ctlv3/command/user_command.go
userChangePasswordCommandFunc
func userChangePasswordCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("user passwd command requires user name as its argument")) } var password string if !passwordInteractive { fmt.Scanf("%s", &password) } else { password = readPasswordInteractive...
go
func userChangePasswordCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("user passwd command requires user name as its argument")) } var password string if !passwordInteractive { fmt.Scanf("%s", &password) } else { password = readPasswordInteractive...
[ "func", "userChangePasswordCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"user pass...
// userChangePasswordCommandFunc executes the "user passwd" command.
[ "userChangePasswordCommandFunc", "executes", "the", "user", "passwd", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/user_command.go#L216-L235
test
etcd-io/etcd
etcdserver/api/v2store/event_history.go
addEvent
func (eh *EventHistory) addEvent(e *Event) *Event { eh.rwl.Lock() defer eh.rwl.Unlock() eh.Queue.insert(e) eh.LastIndex = e.Index() eh.StartIndex = eh.Queue.Events[eh.Queue.Front].Index() return e }
go
func (eh *EventHistory) addEvent(e *Event) *Event { eh.rwl.Lock() defer eh.rwl.Unlock() eh.Queue.insert(e) eh.LastIndex = e.Index() eh.StartIndex = eh.Queue.Events[eh.Queue.Front].Index() return e }
[ "func", "(", "eh", "*", "EventHistory", ")", "addEvent", "(", "e", "*", "Event", ")", "*", "Event", "{", "eh", ".", "rwl", ".", "Lock", "(", ")", "\n", "defer", "eh", ".", "rwl", ".", "Unlock", "(", ")", "\n", "eh", ".", "Queue", ".", "insert",...
// addEvent function adds event into the eventHistory
[ "addEvent", "function", "adds", "event", "into", "the", "eventHistory" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/event_history.go#L43-L54
test
etcd-io/etcd
etcdserver/api/v2store/event_history.go
scan
func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event, *v2error.Error) { eh.rwl.RLock() defer eh.rwl.RUnlock() // index should be after the event history's StartIndex if index < eh.StartIndex { return nil, v2error.NewError(v2error.EcodeEventIndexCleared, fmt.Sprintf("the requested...
go
func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event, *v2error.Error) { eh.rwl.RLock() defer eh.rwl.RUnlock() // index should be after the event history's StartIndex if index < eh.StartIndex { return nil, v2error.NewError(v2error.EcodeEventIndexCleared, fmt.Sprintf("the requested...
[ "func", "(", "eh", "*", "EventHistory", ")", "scan", "(", "key", "string", ",", "recursive", "bool", ",", "index", "uint64", ")", "(", "*", "Event", ",", "*", "v2error", ".", "Error", ")", "{", "eh", ".", "rwl", ".", "RLock", "(", ")", "\n", "def...
// scan enumerates events from the index history and stops at the first point // where the key matches.
[ "scan", "enumerates", "events", "from", "the", "index", "history", "and", "stops", "at", "the", "first", "point", "where", "the", "key", "matches", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/event_history.go#L58-L109
test
etcd-io/etcd
etcdserver/api/v2store/event_history.go
clone
func (eh *EventHistory) clone() *EventHistory { clonedQueue := eventQueue{ Capacity: eh.Queue.Capacity, Events: make([]*Event, eh.Queue.Capacity), Size: eh.Queue.Size, Front: eh.Queue.Front, Back: eh.Queue.Back, } copy(clonedQueue.Events, eh.Queue.Events) return &EventHistory{ StartIndex: ...
go
func (eh *EventHistory) clone() *EventHistory { clonedQueue := eventQueue{ Capacity: eh.Queue.Capacity, Events: make([]*Event, eh.Queue.Capacity), Size: eh.Queue.Size, Front: eh.Queue.Front, Back: eh.Queue.Back, } copy(clonedQueue.Events, eh.Queue.Events) return &EventHistory{ StartIndex: ...
[ "func", "(", "eh", "*", "EventHistory", ")", "clone", "(", ")", "*", "EventHistory", "{", "clonedQueue", ":=", "eventQueue", "{", "Capacity", ":", "eh", ".", "Queue", ".", "Capacity", ",", "Events", ":", "make", "(", "[", "]", "*", "Event", ",", "eh"...
// clone will be protected by a stop-world lock // do not need to obtain internal lock
[ "clone", "will", "be", "protected", "by", "a", "stop", "-", "world", "lock", "do", "not", "need", "to", "obtain", "internal", "lock" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/event_history.go#L113-L129
test
etcd-io/etcd
etcdserver/backend.go
openSnapshotBackend
func openSnapshotBackend(cfg ServerConfig, ss *snap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) { snapPath, err := ss.DBFilePath(snapshot.Metadata.Index) if err != nil { return nil, fmt.Errorf("failed to find database snapshot file (%v)", err) } if err := os.Rename(snapPath, cfg.backendPath())...
go
func openSnapshotBackend(cfg ServerConfig, ss *snap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) { snapPath, err := ss.DBFilePath(snapshot.Metadata.Index) if err != nil { return nil, fmt.Errorf("failed to find database snapshot file (%v)", err) } if err := os.Rename(snapPath, cfg.backendPath())...
[ "func", "openSnapshotBackend", "(", "cfg", "ServerConfig", ",", "ss", "*", "snap", ".", "Snapshotter", ",", "snapshot", "raftpb", ".", "Snapshot", ")", "(", "backend", ".", "Backend", ",", "error", ")", "{", "snapPath", ",", "err", ":=", "ss", ".", "DBFi...
// openSnapshotBackend renames a snapshot db to the current etcd db and opens it.
[ "openSnapshotBackend", "renames", "a", "snapshot", "db", "to", "the", "current", "etcd", "db", "and", "opens", "it", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/backend.go#L56-L65
test
etcd-io/etcd
etcdserver/backend.go
openBackend
func openBackend(cfg ServerConfig) backend.Backend { fn := cfg.backendPath() now, beOpened := time.Now(), make(chan backend.Backend) go func() { beOpened <- newBackend(cfg) }() select { case be := <-beOpened: if cfg.Logger != nil { cfg.Logger.Info("opened backend db", zap.String("path", fn), zap.Duration...
go
func openBackend(cfg ServerConfig) backend.Backend { fn := cfg.backendPath() now, beOpened := time.Now(), make(chan backend.Backend) go func() { beOpened <- newBackend(cfg) }() select { case be := <-beOpened: if cfg.Logger != nil { cfg.Logger.Info("opened backend db", zap.String("path", fn), zap.Duration...
[ "func", "openBackend", "(", "cfg", "ServerConfig", ")", "backend", ".", "Backend", "{", "fn", ":=", "cfg", ".", "backendPath", "(", ")", "\n", "now", ",", "beOpened", ":=", "time", ".", "Now", "(", ")", ",", "make", "(", "chan", "backend", ".", "Back...
// openBackend returns a backend using the current etcd db.
[ "openBackend", "returns", "a", "backend", "using", "the", "current", "etcd", "db", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/backend.go#L68-L97
test
etcd-io/etcd
etcdserver/backend.go
recoverSnapshotBackend
func recoverSnapshotBackend(cfg ServerConfig, oldbe backend.Backend, snapshot raftpb.Snapshot) (backend.Backend, error) { var cIndex consistentIndex kv := mvcc.New(cfg.Logger, oldbe, &lease.FakeLessor{}, &cIndex) defer kv.Close() if snapshot.Metadata.Index <= kv.ConsistentIndex() { return oldbe, nil } oldbe.Clo...
go
func recoverSnapshotBackend(cfg ServerConfig, oldbe backend.Backend, snapshot raftpb.Snapshot) (backend.Backend, error) { var cIndex consistentIndex kv := mvcc.New(cfg.Logger, oldbe, &lease.FakeLessor{}, &cIndex) defer kv.Close() if snapshot.Metadata.Index <= kv.ConsistentIndex() { return oldbe, nil } oldbe.Clo...
[ "func", "recoverSnapshotBackend", "(", "cfg", "ServerConfig", ",", "oldbe", "backend", ".", "Backend", ",", "snapshot", "raftpb", ".", "Snapshot", ")", "(", "backend", ".", "Backend", ",", "error", ")", "{", "var", "cIndex", "consistentIndex", "\n", "kv", ":...
// recoverBackendSnapshot recovers the DB from a snapshot in case etcd crashes // before updating the backend db after persisting raft snapshot to disk, // violating the invariant snapshot.Metadata.Index < db.consistentIndex. In this // case, replace the db with the snapshot db sent by the leader.
[ "recoverBackendSnapshot", "recovers", "the", "DB", "from", "a", "snapshot", "in", "case", "etcd", "crashes", "before", "updating", "the", "backend", "db", "after", "persisting", "raft", "snapshot", "to", "disk", "violating", "the", "invariant", "snapshot", ".", ...
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/backend.go#L103-L112
test
etcd-io/etcd
etcdctl/ctlv2/command/update_command.go
NewUpdateCommand
func NewUpdateCommand() cli.Command { return cli.Command{ Name: "update", Usage: "update an existing key with a given value", ArgsUsage: "<key> <value>", Flags: []cli.Flag{ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"}, }, Action: func(c *cli.Context) error { updat...
go
func NewUpdateCommand() cli.Command { return cli.Command{ Name: "update", Usage: "update an existing key with a given value", ArgsUsage: "<key> <value>", Flags: []cli.Flag{ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"}, }, Action: func(c *cli.Context) error { updat...
[ "func", "NewUpdateCommand", "(", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"update\"", ",", "Usage", ":", "\"update an existing key with a given value\"", ",", "ArgsUsage", ":", "\"<key> <value>\"", ",", "Flags", ":", ...
// NewUpdateCommand returns the CLI command for "update".
[ "NewUpdateCommand", "returns", "the", "CLI", "command", "for", "update", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/update_command.go#L27-L40
test
etcd-io/etcd
etcdctl/ctlv2/command/update_command.go
updateCommandFunc
func updateCommandFunc(c *cli.Context, ki client.KeysAPI) { if len(c.Args()) == 0 { handleError(c, ExitBadArgs, errors.New("key required")) } key := c.Args()[0] value, err := argOrStdin(c.Args(), os.Stdin, 1) if err != nil { handleError(c, ExitBadArgs, errors.New("value required")) } ttl := c.Int("ttl") c...
go
func updateCommandFunc(c *cli.Context, ki client.KeysAPI) { if len(c.Args()) == 0 { handleError(c, ExitBadArgs, errors.New("key required")) } key := c.Args()[0] value, err := argOrStdin(c.Args(), os.Stdin, 1) if err != nil { handleError(c, ExitBadArgs, errors.New("value required")) } ttl := c.Int("ttl") c...
[ "func", "updateCommandFunc", "(", "c", "*", "cli", ".", "Context", ",", "ki", "client", ".", "KeysAPI", ")", "{", "if", "len", "(", "c", ".", "Args", "(", ")", ")", "==", "0", "{", "handleError", "(", "c", ",", "ExitBadArgs", ",", "errors", ".", ...
// updateCommandFunc executes the "update" command.
[ "updateCommandFunc", "executes", "the", "update", "command", "." ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/update_command.go#L43-L63
test
etcd-io/etcd
etcdserver/api/v2stats/queue.go
frontAndBack
func (q *statsQueue) frontAndBack() (*RequestStats, *RequestStats) { q.rwl.RLock() defer q.rwl.RUnlock() if q.size != 0 { return q.items[q.front], q.items[q.back] } return nil, nil }
go
func (q *statsQueue) frontAndBack() (*RequestStats, *RequestStats) { q.rwl.RLock() defer q.rwl.RUnlock() if q.size != 0 { return q.items[q.front], q.items[q.back] } return nil, nil }
[ "func", "(", "q", "*", "statsQueue", ")", "frontAndBack", "(", ")", "(", "*", "RequestStats", ",", "*", "RequestStats", ")", "{", "q", ".", "rwl", ".", "RLock", "(", ")", "\n", "defer", "q", ".", "rwl", ".", "RUnlock", "(", ")", "\n", "if", "q", ...
// FrontAndBack gets the front and back elements in the queue // We must grab front and back together with the protection of the lock
[ "FrontAndBack", "gets", "the", "front", "and", "back", "elements", "in", "the", "queue", "We", "must", "grab", "front", "and", "back", "together", "with", "the", "protection", "of", "the", "lock" ]
616592d9ba993e3fe9798eef581316016df98906
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/queue.go#L52-L59
test