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 | etcdserver/api/v2stats/queue.go | Insert | func (q *statsQueue) Insert(p *RequestStats) {
q.rwl.Lock()
defer q.rwl.Unlock()
q.back = (q.back + 1) % queueCapacity
if q.size == queueCapacity { //dequeue
q.totalReqSize -= q.items[q.front].Size
q.front = (q.back + 1) % queueCapacity
} else {
q.size++
}
q.items[q.back] = p
q.totalReqSize += q.items[... | go | func (q *statsQueue) Insert(p *RequestStats) {
q.rwl.Lock()
defer q.rwl.Unlock()
q.back = (q.back + 1) % queueCapacity
if q.size == queueCapacity { //dequeue
q.totalReqSize -= q.items[q.front].Size
q.front = (q.back + 1) % queueCapacity
} else {
q.size++
}
q.items[q.back] = p
q.totalReqSize += q.items[... | [
"func",
"(",
"q",
"*",
"statsQueue",
")",
"Insert",
"(",
"p",
"*",
"RequestStats",
")",
"{",
"q",
".",
"rwl",
".",
"Lock",
"(",
")",
"\n",
"defer",
"q",
".",
"rwl",
".",
"Unlock",
"(",
")",
"\n",
"q",
".",
"back",
"=",
"(",
"q",
".",
"back",
... | // Insert function insert a RequestStats into the queue and update the records | [
"Insert",
"function",
"insert",
"a",
"RequestStats",
"into",
"the",
"queue",
"and",
"update",
"the",
"records"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/queue.go#L62-L78 | test |
etcd-io/etcd | etcdserver/api/v2stats/queue.go | Rate | func (q *statsQueue) Rate() (float64, float64) {
front, back := q.frontAndBack()
if front == nil || back == nil {
return 0, 0
}
if time.Since(back.SendingTime) > time.Second {
q.Clear()
return 0, 0
}
sampleDuration := back.SendingTime.Sub(front.SendingTime)
pr := float64(q.Len()) / float64(sampleDurati... | go | func (q *statsQueue) Rate() (float64, float64) {
front, back := q.frontAndBack()
if front == nil || back == nil {
return 0, 0
}
if time.Since(back.SendingTime) > time.Second {
q.Clear()
return 0, 0
}
sampleDuration := back.SendingTime.Sub(front.SendingTime)
pr := float64(q.Len()) / float64(sampleDurati... | [
"func",
"(",
"q",
"*",
"statsQueue",
")",
"Rate",
"(",
")",
"(",
"float64",
",",
"float64",
")",
"{",
"front",
",",
"back",
":=",
"q",
".",
"frontAndBack",
"(",
")",
"\n",
"if",
"front",
"==",
"nil",
"||",
"back",
"==",
"nil",
"{",
"return",
"0",... | // Rate function returns the package rate and byte rate | [
"Rate",
"function",
"returns",
"the",
"package",
"rate",
"and",
"byte",
"rate"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/queue.go#L81-L100 | test |
etcd-io/etcd | etcdserver/api/v2stats/queue.go | Clear | func (q *statsQueue) Clear() {
q.rwl.Lock()
defer q.rwl.Unlock()
q.back = -1
q.front = 0
q.size = 0
q.totalReqSize = 0
} | go | func (q *statsQueue) Clear() {
q.rwl.Lock()
defer q.rwl.Unlock()
q.back = -1
q.front = 0
q.size = 0
q.totalReqSize = 0
} | [
"func",
"(",
"q",
"*",
"statsQueue",
")",
"Clear",
"(",
")",
"{",
"q",
".",
"rwl",
".",
"Lock",
"(",
")",
"\n",
"defer",
"q",
".",
"rwl",
".",
"Unlock",
"(",
")",
"\n",
"q",
".",
"back",
"=",
"-",
"1",
"\n",
"q",
".",
"front",
"=",
"0",
"... | // Clear function clear up the statsQueue | [
"Clear",
"function",
"clear",
"up",
"the",
"statsQueue"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/queue.go#L103-L110 | test |
etcd-io/etcd | pkg/stringutil/rand.go | UniqueStrings | func UniqueStrings(slen uint, n int) (ss []string) {
exist := make(map[string]struct{})
ss = make([]string, 0, n)
for len(ss) < n {
s := randString(slen)
if _, ok := exist[s]; !ok {
ss = append(ss, s)
exist[s] = struct{}{}
}
}
return ss
} | go | func UniqueStrings(slen uint, n int) (ss []string) {
exist := make(map[string]struct{})
ss = make([]string, 0, n)
for len(ss) < n {
s := randString(slen)
if _, ok := exist[s]; !ok {
ss = append(ss, s)
exist[s] = struct{}{}
}
}
return ss
} | [
"func",
"UniqueStrings",
"(",
"slen",
"uint",
",",
"n",
"int",
")",
"(",
"ss",
"[",
"]",
"string",
")",
"{",
"exist",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"\n",
"ss",
"=",
"make",
"(",
"[",
"]",
"string",
",",
... | // UniqueStrings returns a slice of randomly generated unique strings. | [
"UniqueStrings",
"returns",
"a",
"slice",
"of",
"randomly",
"generated",
"unique",
"strings",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/stringutil/rand.go#L23-L34 | test |
etcd-io/etcd | pkg/stringutil/rand.go | RandomStrings | func RandomStrings(slen uint, n int) (ss []string) {
ss = make([]string, 0, n)
for i := 0; i < n; i++ {
ss = append(ss, randString(slen))
}
return ss
} | go | func RandomStrings(slen uint, n int) (ss []string) {
ss = make([]string, 0, n)
for i := 0; i < n; i++ {
ss = append(ss, randString(slen))
}
return ss
} | [
"func",
"RandomStrings",
"(",
"slen",
"uint",
",",
"n",
"int",
")",
"(",
"ss",
"[",
"]",
"string",
")",
"{",
"ss",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"n",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"... | // RandomStrings returns a slice of randomly generated strings. | [
"RandomStrings",
"returns",
"a",
"slice",
"of",
"randomly",
"generated",
"strings",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/stringutil/rand.go#L37-L43 | test |
etcd-io/etcd | client/util.go | IsKeyNotFound | func IsKeyNotFound(err error) bool {
if cErr, ok := err.(Error); ok {
return cErr.Code == ErrorCodeKeyNotFound
}
return false
} | go | func IsKeyNotFound(err error) bool {
if cErr, ok := err.(Error); ok {
return cErr.Code == ErrorCodeKeyNotFound
}
return false
} | [
"func",
"IsKeyNotFound",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"cErr",
",",
"ok",
":=",
"err",
".",
"(",
"Error",
")",
";",
"ok",
"{",
"return",
"cErr",
".",
"Code",
"==",
"ErrorCodeKeyNotFound",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsKeyNotFound returns true if the error code is ErrorCodeKeyNotFound. | [
"IsKeyNotFound",
"returns",
"true",
"if",
"the",
"error",
"code",
"is",
"ErrorCodeKeyNotFound",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/util.go#L32-L37 | test |
etcd-io/etcd | client/util.go | IsRoleNotFound | func IsRoleNotFound(err error) bool {
if ae, ok := err.(authError); ok {
return roleNotFoundRegExp.MatchString(ae.Message)
}
return false
} | go | func IsRoleNotFound(err error) bool {
if ae, ok := err.(authError); ok {
return roleNotFoundRegExp.MatchString(ae.Message)
}
return false
} | [
"func",
"IsRoleNotFound",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"ae",
",",
"ok",
":=",
"err",
".",
"(",
"authError",
")",
";",
"ok",
"{",
"return",
"roleNotFoundRegExp",
".",
"MatchString",
"(",
"ae",
".",
"Message",
")",
"\n",
"}",
"\n",
"ret... | // IsRoleNotFound returns true if the error means role not found of v2 API. | [
"IsRoleNotFound",
"returns",
"true",
"if",
"the",
"error",
"means",
"role",
"not",
"found",
"of",
"v2",
"API",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/util.go#L40-L45 | test |
etcd-io/etcd | client/util.go | IsUserNotFound | func IsUserNotFound(err error) bool {
if ae, ok := err.(authError); ok {
return userNotFoundRegExp.MatchString(ae.Message)
}
return false
} | go | func IsUserNotFound(err error) bool {
if ae, ok := err.(authError); ok {
return userNotFoundRegExp.MatchString(ae.Message)
}
return false
} | [
"func",
"IsUserNotFound",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"ae",
",",
"ok",
":=",
"err",
".",
"(",
"authError",
")",
";",
"ok",
"{",
"return",
"userNotFoundRegExp",
".",
"MatchString",
"(",
"ae",
".",
"Message",
")",
"\n",
"}",
"\n",
"ret... | // IsUserNotFound returns true if the error means user not found of v2 API. | [
"IsUserNotFound",
"returns",
"true",
"if",
"the",
"error",
"means",
"user",
"not",
"found",
"of",
"v2",
"API",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/util.go#L48-L53 | test |
etcd-io/etcd | etcdserver/api/v2discovery/discovery.go | JoinCluster | func JoinCluster(lg *zap.Logger, durl, dproxyurl string, id types.ID, config string) (string, error) {
d, err := newDiscovery(lg, durl, dproxyurl, id)
if err != nil {
return "", err
}
return d.joinCluster(config)
} | go | func JoinCluster(lg *zap.Logger, durl, dproxyurl string, id types.ID, config string) (string, error) {
d, err := newDiscovery(lg, durl, dproxyurl, id)
if err != nil {
return "", err
}
return d.joinCluster(config)
} | [
"func",
"JoinCluster",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"durl",
",",
"dproxyurl",
"string",
",",
"id",
"types",
".",
"ID",
",",
"config",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"newDiscovery",
"(",
"l... | // JoinCluster will connect to the discovery service at the given url, and
// register the server represented by the given id and config to the cluster | [
"JoinCluster",
"will",
"connect",
"to",
"the",
"discovery",
"service",
"at",
"the",
"given",
"url",
"and",
"register",
"the",
"server",
"represented",
"by",
"the",
"given",
"id",
"and",
"config",
"to",
"the",
"cluster"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2discovery/discovery.go#L63-L69 | test |
etcd-io/etcd | etcdserver/api/v2discovery/discovery.go | GetCluster | func GetCluster(lg *zap.Logger, durl, dproxyurl string) (string, error) {
d, err := newDiscovery(lg, durl, dproxyurl, 0)
if err != nil {
return "", err
}
return d.getCluster()
} | go | func GetCluster(lg *zap.Logger, durl, dproxyurl string) (string, error) {
d, err := newDiscovery(lg, durl, dproxyurl, 0)
if err != nil {
return "", err
}
return d.getCluster()
} | [
"func",
"GetCluster",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"durl",
",",
"dproxyurl",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"newDiscovery",
"(",
"lg",
",",
"durl",
",",
"dproxyurl",
",",
"0",
")",
"\n",
... | // GetCluster will connect to the discovery service at the given url and
// retrieve a string describing the cluster | [
"GetCluster",
"will",
"connect",
"to",
"the",
"discovery",
"service",
"at",
"the",
"given",
"url",
"and",
"retrieve",
"a",
"string",
"describing",
"the",
"cluster"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2discovery/discovery.go#L73-L79 | test |
etcd-io/etcd | etcdserver/api/v2discovery/discovery.go | newProxyFunc | func newProxyFunc(lg *zap.Logger, proxy string) (func(*http.Request) (*url.URL, error), error) {
if proxy == "" {
return nil, nil
}
// Do a small amount of URL sanitization to help the user
// Derived from net/http.ProxyFromEnvironment
proxyURL, err := url.Parse(proxy)
if err != nil || !strings.HasPrefix(proxyU... | go | func newProxyFunc(lg *zap.Logger, proxy string) (func(*http.Request) (*url.URL, error), error) {
if proxy == "" {
return nil, nil
}
// Do a small amount of URL sanitization to help the user
// Derived from net/http.ProxyFromEnvironment
proxyURL, err := url.Parse(proxy)
if err != nil || !strings.HasPrefix(proxyU... | [
"func",
"newProxyFunc",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"proxy",
"string",
")",
"(",
"func",
"(",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
",",
"error",
")",
"{",
"if",
"proxy",
"==",
"\"\"",
... | // newProxyFunc builds a proxy function from the given string, which should
// represent a URL that can be used as a proxy. It performs basic
// sanitization of the URL and returns any error encountered. | [
"newProxyFunc",
"builds",
"a",
"proxy",
"function",
"from",
"the",
"given",
"string",
"which",
"should",
"represent",
"a",
"URL",
"that",
"can",
"be",
"used",
"as",
"a",
"proxy",
".",
"It",
"performs",
"basic",
"sanitization",
"of",
"the",
"URL",
"and",
"r... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2discovery/discovery.go#L95-L122 | test |
etcd-io/etcd | clientv3/retry_interceptor.go | isSafeRetry | func isSafeRetry(lg *zap.Logger, err error, callOpts *options) bool {
if isContextError(err) {
return false
}
switch callOpts.retryPolicy {
case repeatable:
return isSafeRetryImmutableRPC(err)
case nonRepeatable:
return isSafeRetryMutableRPC(err)
default:
lg.Warn("unrecognized retry policy", zap.String("r... | go | func isSafeRetry(lg *zap.Logger, err error, callOpts *options) bool {
if isContextError(err) {
return false
}
switch callOpts.retryPolicy {
case repeatable:
return isSafeRetryImmutableRPC(err)
case nonRepeatable:
return isSafeRetryMutableRPC(err)
default:
lg.Warn("unrecognized retry policy", zap.String("r... | [
"func",
"isSafeRetry",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"err",
"error",
",",
"callOpts",
"*",
"options",
")",
"bool",
"{",
"if",
"isContextError",
"(",
"err",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"callOpts",
".",
"retryPoli... | // isSafeRetry returns "true", if request is safe for retry with the given error. | [
"isSafeRetry",
"returns",
"true",
"if",
"request",
"is",
"safe",
"for",
"retry",
"with",
"the",
"given",
"error",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L277-L290 | test |
etcd-io/etcd | clientv3/retry_interceptor.go | withRetryPolicy | func withRetryPolicy(rp retryPolicy) retryOption {
return retryOption{applyFunc: func(o *options) {
o.retryPolicy = rp
}}
} | go | func withRetryPolicy(rp retryPolicy) retryOption {
return retryOption{applyFunc: func(o *options) {
o.retryPolicy = rp
}}
} | [
"func",
"withRetryPolicy",
"(",
"rp",
"retryPolicy",
")",
"retryOption",
"{",
"return",
"retryOption",
"{",
"applyFunc",
":",
"func",
"(",
"o",
"*",
"options",
")",
"{",
"o",
".",
"retryPolicy",
"=",
"rp",
"\n",
"}",
"}",
"\n",
"}"
] | // withRetryPolicy sets the retry policy of this call. | [
"withRetryPolicy",
"sets",
"the",
"retry",
"policy",
"of",
"this",
"call",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L325-L329 | test |
etcd-io/etcd | clientv3/retry_interceptor.go | withAuthRetry | func withAuthRetry(retryAuth bool) retryOption {
return retryOption{applyFunc: func(o *options) {
o.retryAuth = retryAuth
}}
} | go | func withAuthRetry(retryAuth bool) retryOption {
return retryOption{applyFunc: func(o *options) {
o.retryAuth = retryAuth
}}
} | [
"func",
"withAuthRetry",
"(",
"retryAuth",
"bool",
")",
"retryOption",
"{",
"return",
"retryOption",
"{",
"applyFunc",
":",
"func",
"(",
"o",
"*",
"options",
")",
"{",
"o",
".",
"retryAuth",
"=",
"retryAuth",
"\n",
"}",
"}",
"\n",
"}"
] | // withAuthRetry sets enables authentication retries. | [
"withAuthRetry",
"sets",
"enables",
"authentication",
"retries",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L332-L336 | test |
etcd-io/etcd | clientv3/retry_interceptor.go | withMax | func withMax(maxRetries uint) retryOption {
return retryOption{applyFunc: func(o *options) {
o.max = maxRetries
}}
} | go | func withMax(maxRetries uint) retryOption {
return retryOption{applyFunc: func(o *options) {
o.max = maxRetries
}}
} | [
"func",
"withMax",
"(",
"maxRetries",
"uint",
")",
"retryOption",
"{",
"return",
"retryOption",
"{",
"applyFunc",
":",
"func",
"(",
"o",
"*",
"options",
")",
"{",
"o",
".",
"max",
"=",
"maxRetries",
"\n",
"}",
"}",
"\n",
"}"
] | // withMax sets the maximum number of retries on this call, or this interceptor. | [
"withMax",
"sets",
"the",
"maximum",
"number",
"of",
"retries",
"on",
"this",
"call",
"or",
"this",
"interceptor",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L339-L343 | test |
etcd-io/etcd | clientv3/retry_interceptor.go | withBackoff | func withBackoff(bf backoffFunc) retryOption {
return retryOption{applyFunc: func(o *options) {
o.backoffFunc = bf
}}
} | go | func withBackoff(bf backoffFunc) retryOption {
return retryOption{applyFunc: func(o *options) {
o.backoffFunc = bf
}}
} | [
"func",
"withBackoff",
"(",
"bf",
"backoffFunc",
")",
"retryOption",
"{",
"return",
"retryOption",
"{",
"applyFunc",
":",
"func",
"(",
"o",
"*",
"options",
")",
"{",
"o",
".",
"backoffFunc",
"=",
"bf",
"\n",
"}",
"}",
"\n",
"}"
] | // WithBackoff sets the `BackoffFunc `used to control time between retries. | [
"WithBackoff",
"sets",
"the",
"BackoffFunc",
"used",
"to",
"control",
"time",
"between",
"retries",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L346-L350 | test |
etcd-io/etcd | etcdserver/api/v2stats/server.go | RecvAppendReq | func (ss *ServerStats) RecvAppendReq(leader string, reqSize int) {
ss.Lock()
defer ss.Unlock()
now := time.Now()
ss.State = raft.StateFollower
if leader != ss.LeaderInfo.Name {
ss.LeaderInfo.Name = leader
ss.LeaderInfo.StartTime = now
}
ss.recvRateQueue.Insert(
&RequestStats{
SendingTime: now,
Siz... | go | func (ss *ServerStats) RecvAppendReq(leader string, reqSize int) {
ss.Lock()
defer ss.Unlock()
now := time.Now()
ss.State = raft.StateFollower
if leader != ss.LeaderInfo.Name {
ss.LeaderInfo.Name = leader
ss.LeaderInfo.StartTime = now
}
ss.recvRateQueue.Insert(
&RequestStats{
SendingTime: now,
Siz... | [
"func",
"(",
"ss",
"*",
"ServerStats",
")",
"RecvAppendReq",
"(",
"leader",
"string",
",",
"reqSize",
"int",
")",
"{",
"ss",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ss",
".",
"Unlock",
"(",
")",
"\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n... | // RecvAppendReq updates the ServerStats in response to an AppendRequest
// from the given leader being received | [
"RecvAppendReq",
"updates",
"the",
"ServerStats",
"in",
"response",
"to",
"an",
"AppendRequest",
"from",
"the",
"given",
"leader",
"being",
"received"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/server.go#L91-L110 | test |
etcd-io/etcd | etcdserver/api/v2stats/server.go | SendAppendReq | func (ss *ServerStats) SendAppendReq(reqSize int) {
ss.Lock()
defer ss.Unlock()
ss.becomeLeader()
ss.sendRateQueue.Insert(
&RequestStats{
SendingTime: time.Now(),
Size: reqSize,
},
)
ss.SendAppendRequestCnt++
} | go | func (ss *ServerStats) SendAppendReq(reqSize int) {
ss.Lock()
defer ss.Unlock()
ss.becomeLeader()
ss.sendRateQueue.Insert(
&RequestStats{
SendingTime: time.Now(),
Size: reqSize,
},
)
ss.SendAppendRequestCnt++
} | [
"func",
"(",
"ss",
"*",
"ServerStats",
")",
"SendAppendReq",
"(",
"reqSize",
"int",
")",
"{",
"ss",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ss",
".",
"Unlock",
"(",
")",
"\n",
"ss",
".",
"becomeLeader",
"(",
")",
"\n",
"ss",
".",
"sendRateQueue",
".... | // SendAppendReq updates the ServerStats in response to an AppendRequest
// being sent by this server | [
"SendAppendReq",
"updates",
"the",
"ServerStats",
"in",
"response",
"to",
"an",
"AppendRequest",
"being",
"sent",
"by",
"this",
"server"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/server.go#L114-L128 | test |
etcd-io/etcd | mvcc/backend/tx_buffer.go | merge | func (bb *bucketBuffer) merge(bbsrc *bucketBuffer) {
for i := 0; i < bbsrc.used; i++ {
bb.add(bbsrc.buf[i].key, bbsrc.buf[i].val)
}
if bb.used == bbsrc.used {
return
}
if bytes.Compare(bb.buf[(bb.used-bbsrc.used)-1].key, bbsrc.buf[0].key) < 0 {
return
}
sort.Stable(bb)
// remove duplicates, using only n... | go | func (bb *bucketBuffer) merge(bbsrc *bucketBuffer) {
for i := 0; i < bbsrc.used; i++ {
bb.add(bbsrc.buf[i].key, bbsrc.buf[i].val)
}
if bb.used == bbsrc.used {
return
}
if bytes.Compare(bb.buf[(bb.used-bbsrc.used)-1].key, bbsrc.buf[0].key) < 0 {
return
}
sort.Stable(bb)
// remove duplicates, using only n... | [
"func",
"(",
"bb",
"*",
"bucketBuffer",
")",
"merge",
"(",
"bbsrc",
"*",
"bucketBuffer",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"bbsrc",
".",
"used",
";",
"i",
"++",
"{",
"bb",
".",
"add",
"(",
"bbsrc",
".",
"buf",
"[",
"i",
"]",
"."... | // merge merges data from bb into bbsrc. | [
"merge",
"merges",
"data",
"from",
"bb",
"into",
"bbsrc",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/tx_buffer.go#L153-L175 | test |
etcd-io/etcd | contrib/recipes/client.go | deleteRevKey | func deleteRevKey(kv v3.KV, key string, rev int64) (bool, error) {
cmp := v3.Compare(v3.ModRevision(key), "=", rev)
req := v3.OpDelete(key)
txnresp, err := kv.Txn(context.TODO()).If(cmp).Then(req).Commit()
if err != nil {
return false, err
} else if !txnresp.Succeeded {
return false, nil
}
return true, nil
} | go | func deleteRevKey(kv v3.KV, key string, rev int64) (bool, error) {
cmp := v3.Compare(v3.ModRevision(key), "=", rev)
req := v3.OpDelete(key)
txnresp, err := kv.Txn(context.TODO()).If(cmp).Then(req).Commit()
if err != nil {
return false, err
} else if !txnresp.Succeeded {
return false, nil
}
return true, nil
} | [
"func",
"deleteRevKey",
"(",
"kv",
"v3",
".",
"KV",
",",
"key",
"string",
",",
"rev",
"int64",
")",
"(",
"bool",
",",
"error",
")",
"{",
"cmp",
":=",
"v3",
".",
"Compare",
"(",
"v3",
".",
"ModRevision",
"(",
"key",
")",
",",
"\"=\"",
",",
"rev",
... | // deleteRevKey deletes a key by revision, returning false if key is missing | [
"deleteRevKey",
"deletes",
"a",
"key",
"by",
"revision",
"returning",
"false",
"if",
"key",
"is",
"missing"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/client.go#L33-L43 | test |
etcd-io/etcd | etcdserver/cluster_util.go | isMemberBootstrapped | func isMemberBootstrapped(lg *zap.Logger, cl *membership.RaftCluster, member string, rt http.RoundTripper, timeout time.Duration) bool {
rcl, err := getClusterFromRemotePeers(lg, getRemotePeerURLs(cl, member), timeout, false, rt)
if err != nil {
return false
}
id := cl.MemberByName(member).ID
m := rcl.Member(id)... | go | func isMemberBootstrapped(lg *zap.Logger, cl *membership.RaftCluster, member string, rt http.RoundTripper, timeout time.Duration) bool {
rcl, err := getClusterFromRemotePeers(lg, getRemotePeerURLs(cl, member), timeout, false, rt)
if err != nil {
return false
}
id := cl.MemberByName(member).ID
m := rcl.Member(id)... | [
"func",
"isMemberBootstrapped",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"cl",
"*",
"membership",
".",
"RaftCluster",
",",
"member",
"string",
",",
"rt",
"http",
".",
"RoundTripper",
",",
"timeout",
"time",
".",
"Duration",
")",
"bool",
"{",
"rcl",
","... | // isMemberBootstrapped tries to check if the given member has been bootstrapped
// in the given cluster. | [
"isMemberBootstrapped",
"tries",
"to",
"check",
"if",
"the",
"given",
"member",
"has",
"been",
"bootstrapped",
"in",
"the",
"given",
"cluster",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L35-L49 | test |
etcd-io/etcd | etcdserver/cluster_util.go | GetClusterFromRemotePeers | func GetClusterFromRemotePeers(lg *zap.Logger, urls []string, rt http.RoundTripper) (*membership.RaftCluster, error) {
return getClusterFromRemotePeers(lg, urls, 10*time.Second, true, rt)
} | go | func GetClusterFromRemotePeers(lg *zap.Logger, urls []string, rt http.RoundTripper) (*membership.RaftCluster, error) {
return getClusterFromRemotePeers(lg, urls, 10*time.Second, true, rt)
} | [
"func",
"GetClusterFromRemotePeers",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"urls",
"[",
"]",
"string",
",",
"rt",
"http",
".",
"RoundTripper",
")",
"(",
"*",
"membership",
".",
"RaftCluster",
",",
"error",
")",
"{",
"return",
"getClusterFromRemotePeers"... | // GetClusterFromRemotePeers takes a set of URLs representing etcd peers, and
// attempts to construct a Cluster by accessing the members endpoint on one of
// these URLs. The first URL to provide a response is used. If no URLs provide
// a response, or a Cluster cannot be successfully created from a received
// respon... | [
"GetClusterFromRemotePeers",
"takes",
"a",
"set",
"of",
"URLs",
"representing",
"etcd",
"peers",
"and",
"attempts",
"to",
"construct",
"a",
"Cluster",
"by",
"accessing",
"the",
"members",
"endpoint",
"on",
"one",
"of",
"these",
"URLs",
".",
"The",
"first",
"UR... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L58-L60 | test |
etcd-io/etcd | etcdserver/cluster_util.go | getClusterFromRemotePeers | func getClusterFromRemotePeers(lg *zap.Logger, urls []string, timeout time.Duration, logerr bool, rt http.RoundTripper) (*membership.RaftCluster, error) {
cc := &http.Client{
Transport: rt,
Timeout: timeout,
}
for _, u := range urls {
addr := u + "/members"
resp, err := cc.Get(addr)
if err != nil {
if... | go | func getClusterFromRemotePeers(lg *zap.Logger, urls []string, timeout time.Duration, logerr bool, rt http.RoundTripper) (*membership.RaftCluster, error) {
cc := &http.Client{
Transport: rt,
Timeout: timeout,
}
for _, u := range urls {
addr := u + "/members"
resp, err := cc.Get(addr)
if err != nil {
if... | [
"func",
"getClusterFromRemotePeers",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"urls",
"[",
"]",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"logerr",
"bool",
",",
"rt",
"http",
".",
"RoundTripper",
")",
"(",
"*",
"membership",
".",
"RaftClu... | // If logerr is true, it prints out more error messages. | [
"If",
"logerr",
"is",
"true",
"it",
"prints",
"out",
"more",
"error",
"messages",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L63-L131 | test |
etcd-io/etcd | etcdserver/cluster_util.go | getRemotePeerURLs | func getRemotePeerURLs(cl *membership.RaftCluster, local string) []string {
us := make([]string, 0)
for _, m := range cl.Members() {
if m.Name == local {
continue
}
us = append(us, m.PeerURLs...)
}
sort.Strings(us)
return us
} | go | func getRemotePeerURLs(cl *membership.RaftCluster, local string) []string {
us := make([]string, 0)
for _, m := range cl.Members() {
if m.Name == local {
continue
}
us = append(us, m.PeerURLs...)
}
sort.Strings(us)
return us
} | [
"func",
"getRemotePeerURLs",
"(",
"cl",
"*",
"membership",
".",
"RaftCluster",
",",
"local",
"string",
")",
"[",
"]",
"string",
"{",
"us",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"cl",
".",
... | // getRemotePeerURLs returns peer urls of remote members in the cluster. The
// returned list is sorted in ascending lexicographical order. | [
"getRemotePeerURLs",
"returns",
"peer",
"urls",
"of",
"remote",
"members",
"in",
"the",
"cluster",
".",
"The",
"returned",
"list",
"is",
"sorted",
"in",
"ascending",
"lexicographical",
"order",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L135-L145 | test |
etcd-io/etcd | etcdserver/cluster_util.go | getVersions | func getVersions(lg *zap.Logger, cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) map[string]*version.Versions {
members := cl.Members()
vers := make(map[string]*version.Versions)
for _, m := range members {
if m.ID == local {
cv := "not_decided"
if cl.Version() != nil {
cv = cl.Version(... | go | func getVersions(lg *zap.Logger, cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) map[string]*version.Versions {
members := cl.Members()
vers := make(map[string]*version.Versions)
for _, m := range members {
if m.ID == local {
cv := "not_decided"
if cl.Version() != nil {
cv = cl.Version(... | [
"func",
"getVersions",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"cl",
"*",
"membership",
".",
"RaftCluster",
",",
"local",
"types",
".",
"ID",
",",
"rt",
"http",
".",
"RoundTripper",
")",
"map",
"[",
"string",
"]",
"*",
"version",
".",
"Versions",
... | // getVersions returns the versions of the members in the given cluster.
// The key of the returned map is the member's ID. The value of the returned map
// is the semver versions string, including server and cluster.
// If it fails to get the version of a member, the key will be nil. | [
"getVersions",
"returns",
"the",
"versions",
"of",
"the",
"members",
"in",
"the",
"given",
"cluster",
".",
"The",
"key",
"of",
"the",
"returned",
"map",
"is",
"the",
"member",
"s",
"ID",
".",
"The",
"value",
"of",
"the",
"returned",
"map",
"is",
"the",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L151-L176 | test |
etcd-io/etcd | etcdserver/cluster_util.go | decideClusterVersion | func decideClusterVersion(lg *zap.Logger, vers map[string]*version.Versions) *semver.Version {
var cv *semver.Version
lv := semver.Must(semver.NewVersion(version.Version))
for mid, ver := range vers {
if ver == nil {
return nil
}
v, err := semver.NewVersion(ver.Server)
if err != nil {
if lg != nil {
... | go | func decideClusterVersion(lg *zap.Logger, vers map[string]*version.Versions) *semver.Version {
var cv *semver.Version
lv := semver.Must(semver.NewVersion(version.Version))
for mid, ver := range vers {
if ver == nil {
return nil
}
v, err := semver.NewVersion(ver.Server)
if err != nil {
if lg != nil {
... | [
"func",
"decideClusterVersion",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"vers",
"map",
"[",
"string",
"]",
"*",
"version",
".",
"Versions",
")",
"*",
"semver",
".",
"Version",
"{",
"var",
"cv",
"*",
"semver",
".",
"Version",
"\n",
"lv",
":=",
"sem... | // decideClusterVersion decides the cluster version based on the versions map.
// The returned version is the min server version in the map, or nil if the min
// version in unknown. | [
"decideClusterVersion",
"decides",
"the",
"cluster",
"version",
"based",
"on",
"the",
"versions",
"map",
".",
"The",
"returned",
"version",
"is",
"the",
"min",
"server",
"version",
"in",
"the",
"map",
"or",
"nil",
"if",
"the",
"min",
"version",
"in",
"unknow... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L181-L223 | test |
etcd-io/etcd | etcdserver/cluster_util.go | getVersion | func getVersion(lg *zap.Logger, m *membership.Member, rt http.RoundTripper) (*version.Versions, error) {
cc := &http.Client{
Transport: rt,
}
var (
err error
resp *http.Response
)
for _, u := range m.PeerURLs {
addr := u + "/version"
resp, err = cc.Get(addr)
if err != nil {
if lg != nil {
lg.W... | go | func getVersion(lg *zap.Logger, m *membership.Member, rt http.RoundTripper) (*version.Versions, error) {
cc := &http.Client{
Transport: rt,
}
var (
err error
resp *http.Response
)
for _, u := range m.PeerURLs {
addr := u + "/version"
resp, err = cc.Get(addr)
if err != nil {
if lg != nil {
lg.W... | [
"func",
"getVersion",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"m",
"*",
"membership",
".",
"Member",
",",
"rt",
"http",
".",
"RoundTripper",
")",
"(",
"*",
"version",
".",
"Versions",
",",
"error",
")",
"{",
"cc",
":=",
"&",
"http",
".",
"Client... | // getVersion returns the Versions of the given member via its
// peerURLs. Returns the last error if it fails to get the version. | [
"getVersion",
"returns",
"the",
"Versions",
"of",
"the",
"given",
"member",
"via",
"its",
"peerURLs",
".",
"Returns",
"the",
"last",
"error",
"if",
"it",
"fails",
"to",
"get",
"the",
"version",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L299-L357 | test |
etcd-io/etcd | pkg/contention/contention.go | NewTimeoutDetector | func NewTimeoutDetector(maxDuration time.Duration) *TimeoutDetector {
return &TimeoutDetector{
maxDuration: maxDuration,
records: make(map[uint64]time.Time),
}
} | go | func NewTimeoutDetector(maxDuration time.Duration) *TimeoutDetector {
return &TimeoutDetector{
maxDuration: maxDuration,
records: make(map[uint64]time.Time),
}
} | [
"func",
"NewTimeoutDetector",
"(",
"maxDuration",
"time",
".",
"Duration",
")",
"*",
"TimeoutDetector",
"{",
"return",
"&",
"TimeoutDetector",
"{",
"maxDuration",
":",
"maxDuration",
",",
"records",
":",
"make",
"(",
"map",
"[",
"uint64",
"]",
"time",
".",
"... | // NewTimeoutDetector creates the TimeoutDetector. | [
"NewTimeoutDetector",
"creates",
"the",
"TimeoutDetector",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/contention/contention.go#L36-L41 | test |
etcd-io/etcd | pkg/contention/contention.go | Reset | func (td *TimeoutDetector) Reset() {
td.mu.Lock()
defer td.mu.Unlock()
td.records = make(map[uint64]time.Time)
} | go | func (td *TimeoutDetector) Reset() {
td.mu.Lock()
defer td.mu.Unlock()
td.records = make(map[uint64]time.Time)
} | [
"func",
"(",
"td",
"*",
"TimeoutDetector",
")",
"Reset",
"(",
")",
"{",
"td",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"td",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"td",
".",
"records",
"=",
"make",
"(",
"map",
"[",
"uint64",
"]",
... | // Reset resets the NewTimeoutDetector. | [
"Reset",
"resets",
"the",
"NewTimeoutDetector",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/contention/contention.go#L44-L49 | test |
etcd-io/etcd | pkg/contention/contention.go | Observe | func (td *TimeoutDetector) Observe(which uint64) (bool, time.Duration) {
td.mu.Lock()
defer td.mu.Unlock()
ok := true
now := time.Now()
exceed := time.Duration(0)
if pt, found := td.records[which]; found {
exceed = now.Sub(pt) - td.maxDuration
if exceed > 0 {
ok = false
}
}
td.records[which] = now
r... | go | func (td *TimeoutDetector) Observe(which uint64) (bool, time.Duration) {
td.mu.Lock()
defer td.mu.Unlock()
ok := true
now := time.Now()
exceed := time.Duration(0)
if pt, found := td.records[which]; found {
exceed = now.Sub(pt) - td.maxDuration
if exceed > 0 {
ok = false
}
}
td.records[which] = now
r... | [
"func",
"(",
"td",
"*",
"TimeoutDetector",
")",
"Observe",
"(",
"which",
"uint64",
")",
"(",
"bool",
",",
"time",
".",
"Duration",
")",
"{",
"td",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"td",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
... | // Observe observes an event for given id. It returns false and exceeded duration
// if the interval is longer than the expectation. | [
"Observe",
"observes",
"an",
"event",
"for",
"given",
"id",
".",
"It",
"returns",
"false",
"and",
"exceeded",
"duration",
"if",
"the",
"interval",
"is",
"longer",
"than",
"the",
"expectation",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/contention/contention.go#L53-L69 | test |
etcd-io/etcd | etcdserver/api/etcdhttp/peer.go | NewPeerHandler | func NewPeerHandler(lg *zap.Logger, s etcdserver.ServerPeer) http.Handler {
return newPeerHandler(lg, s.Cluster(), s.RaftHandler(), s.LeaseHandler())
} | go | func NewPeerHandler(lg *zap.Logger, s etcdserver.ServerPeer) http.Handler {
return newPeerHandler(lg, s.Cluster(), s.RaftHandler(), s.LeaseHandler())
} | [
"func",
"NewPeerHandler",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"s",
"etcdserver",
".",
"ServerPeer",
")",
"http",
".",
"Handler",
"{",
"return",
"newPeerHandler",
"(",
"lg",
",",
"s",
".",
"Cluster",
"(",
")",
",",
"s",
".",
"RaftHandler",
"(",
... | // NewPeerHandler generates an http.Handler to handle etcd peer requests. | [
"NewPeerHandler",
"generates",
"an",
"http",
".",
"Handler",
"to",
"handle",
"etcd",
"peer",
"requests",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/peer.go#L34-L36 | test |
etcd-io/etcd | mvcc/key_index.go | put | func (ki *keyIndex) put(lg *zap.Logger, main int64, sub int64) {
rev := revision{main: main, sub: sub}
if !rev.GreaterThan(ki.modified) {
if lg != nil {
lg.Panic(
"'put' with an unexpected smaller revision",
zap.Int64("given-revision-main", rev.main),
zap.Int64("given-revision-sub", rev.sub),
za... | go | func (ki *keyIndex) put(lg *zap.Logger, main int64, sub int64) {
rev := revision{main: main, sub: sub}
if !rev.GreaterThan(ki.modified) {
if lg != nil {
lg.Panic(
"'put' with an unexpected smaller revision",
zap.Int64("given-revision-main", rev.main),
zap.Int64("given-revision-sub", rev.sub),
za... | [
"func",
"(",
"ki",
"*",
"keyIndex",
")",
"put",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"main",
"int64",
",",
"sub",
"int64",
")",
"{",
"rev",
":=",
"revision",
"{",
"main",
":",
"main",
",",
"sub",
":",
"sub",
"}",
"\n",
"if",
"!",
"rev",
... | // put puts a revision to the keyIndex. | [
"put",
"puts",
"a",
"revision",
"to",
"the",
"keyIndex",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/key_index.go#L77-L104 | test |
etcd-io/etcd | mvcc/key_index.go | tombstone | func (ki *keyIndex) tombstone(lg *zap.Logger, main int64, sub int64) error {
if ki.isEmpty() {
if lg != nil {
lg.Panic(
"'tombstone' got an unexpected empty keyIndex",
zap.String("key", string(ki.key)),
)
} else {
plog.Panicf("store.keyindex: unexpected tombstone on empty keyIndex %s", string(ki.k... | go | func (ki *keyIndex) tombstone(lg *zap.Logger, main int64, sub int64) error {
if ki.isEmpty() {
if lg != nil {
lg.Panic(
"'tombstone' got an unexpected empty keyIndex",
zap.String("key", string(ki.key)),
)
} else {
plog.Panicf("store.keyindex: unexpected tombstone on empty keyIndex %s", string(ki.k... | [
"func",
"(",
"ki",
"*",
"keyIndex",
")",
"tombstone",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"main",
"int64",
",",
"sub",
"int64",
")",
"error",
"{",
"if",
"ki",
".",
"isEmpty",
"(",
")",
"{",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Panic... | // tombstone puts a revision, pointing to a tombstone, to the keyIndex.
// It also creates a new empty generation in the keyIndex.
// It returns ErrRevisionNotFound when tombstone on an empty generation. | [
"tombstone",
"puts",
"a",
"revision",
"pointing",
"to",
"a",
"tombstone",
"to",
"the",
"keyIndex",
".",
"It",
"also",
"creates",
"a",
"new",
"empty",
"generation",
"in",
"the",
"keyIndex",
".",
"It",
"returns",
"ErrRevisionNotFound",
"when",
"tombstone",
"on",... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/key_index.go#L127-L145 | test |
etcd-io/etcd | mvcc/key_index.go | get | func (ki *keyIndex) get(lg *zap.Logger, atRev int64) (modified, created revision, ver int64, err error) {
if ki.isEmpty() {
if lg != nil {
lg.Panic(
"'get' got an unexpected empty keyIndex",
zap.String("key", string(ki.key)),
)
} else {
plog.Panicf("store.keyindex: unexpected get on empty keyIndex... | go | func (ki *keyIndex) get(lg *zap.Logger, atRev int64) (modified, created revision, ver int64, err error) {
if ki.isEmpty() {
if lg != nil {
lg.Panic(
"'get' got an unexpected empty keyIndex",
zap.String("key", string(ki.key)),
)
} else {
plog.Panicf("store.keyindex: unexpected get on empty keyIndex... | [
"func",
"(",
"ki",
"*",
"keyIndex",
")",
"get",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"atRev",
"int64",
")",
"(",
"modified",
",",
"created",
"revision",
",",
"ver",
"int64",
",",
"err",
"error",
")",
"{",
"if",
"ki",
".",
"isEmpty",
"(",
")... | // get gets the modified, created revision and version of the key that satisfies the given atRev.
// Rev must be higher than or equal to the given atRev. | [
"get",
"gets",
"the",
"modified",
"created",
"revision",
"and",
"version",
"of",
"the",
"key",
"that",
"satisfies",
"the",
"given",
"atRev",
".",
"Rev",
"must",
"be",
"higher",
"than",
"or",
"equal",
"to",
"the",
"given",
"atRev",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/key_index.go#L149-L171 | test |
etcd-io/etcd | mvcc/key_index.go | since | func (ki *keyIndex) since(lg *zap.Logger, rev int64) []revision {
if ki.isEmpty() {
if lg != nil {
lg.Panic(
"'since' got an unexpected empty keyIndex",
zap.String("key", string(ki.key)),
)
} else {
plog.Panicf("store.keyindex: unexpected get on empty keyIndex %s", string(ki.key))
}
}
since :=... | go | func (ki *keyIndex) since(lg *zap.Logger, rev int64) []revision {
if ki.isEmpty() {
if lg != nil {
lg.Panic(
"'since' got an unexpected empty keyIndex",
zap.String("key", string(ki.key)),
)
} else {
plog.Panicf("store.keyindex: unexpected get on empty keyIndex %s", string(ki.key))
}
}
since :=... | [
"func",
"(",
"ki",
"*",
"keyIndex",
")",
"since",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"rev",
"int64",
")",
"[",
"]",
"revision",
"{",
"if",
"ki",
".",
"isEmpty",
"(",
")",
"{",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Panic",
"(",
"\"... | // since returns revisions since the given rev. Only the revision with the
// largest sub revision will be returned if multiple revisions have the same
// main revision. | [
"since",
"returns",
"revisions",
"since",
"the",
"given",
"rev",
".",
"Only",
"the",
"revision",
"with",
"the",
"largest",
"sub",
"revision",
"will",
"be",
"returned",
"if",
"multiple",
"revisions",
"have",
"the",
"same",
"main",
"revision",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/key_index.go#L176-L218 | test |
etcd-io/etcd | mvcc/key_index.go | keep | func (ki *keyIndex) keep(atRev int64, available map[revision]struct{}) {
if ki.isEmpty() {
return
}
genIdx, revIndex := ki.doCompact(atRev, available)
g := &ki.generations[genIdx]
if !g.isEmpty() {
// remove any tombstone
if revIndex == len(g.revs)-1 && genIdx != len(ki.generations)-1 {
delete(available,... | go | func (ki *keyIndex) keep(atRev int64, available map[revision]struct{}) {
if ki.isEmpty() {
return
}
genIdx, revIndex := ki.doCompact(atRev, available)
g := &ki.generations[genIdx]
if !g.isEmpty() {
// remove any tombstone
if revIndex == len(g.revs)-1 && genIdx != len(ki.generations)-1 {
delete(available,... | [
"func",
"(",
"ki",
"*",
"keyIndex",
")",
"keep",
"(",
"atRev",
"int64",
",",
"available",
"map",
"[",
"revision",
"]",
"struct",
"{",
"}",
")",
"{",
"if",
"ki",
".",
"isEmpty",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"genIdx",
",",
"revIndex",
... | // keep finds the revision to be kept if compact is called at given atRev. | [
"keep",
"finds",
"the",
"revision",
"to",
"be",
"kept",
"if",
"compact",
"is",
"called",
"at",
"given",
"atRev",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/key_index.go#L256-L269 | test |
etcd-io/etcd | mvcc/key_index.go | findGeneration | func (ki *keyIndex) findGeneration(rev int64) *generation {
lastg := len(ki.generations) - 1
cg := lastg
for cg >= 0 {
if len(ki.generations[cg].revs) == 0 {
cg--
continue
}
g := ki.generations[cg]
if cg != lastg {
if tomb := g.revs[len(g.revs)-1].main; tomb <= rev {
return nil
}
}
if g.... | go | func (ki *keyIndex) findGeneration(rev int64) *generation {
lastg := len(ki.generations) - 1
cg := lastg
for cg >= 0 {
if len(ki.generations[cg].revs) == 0 {
cg--
continue
}
g := ki.generations[cg]
if cg != lastg {
if tomb := g.revs[len(g.revs)-1].main; tomb <= rev {
return nil
}
}
if g.... | [
"func",
"(",
"ki",
"*",
"keyIndex",
")",
"findGeneration",
"(",
"rev",
"int64",
")",
"*",
"generation",
"{",
"lastg",
":=",
"len",
"(",
"ki",
".",
"generations",
")",
"-",
"1",
"\n",
"cg",
":=",
"lastg",
"\n",
"for",
"cg",
">=",
"0",
"{",
"if",
"... | // findGeneration finds out the generation of the keyIndex that the
// given rev belongs to. If the given rev is at the gap of two generations,
// which means that the key does not exist at the given rev, it returns nil. | [
"findGeneration",
"finds",
"out",
"the",
"generation",
"of",
"the",
"keyIndex",
"that",
"the",
"given",
"rev",
"belongs",
"to",
".",
"If",
"the",
"given",
"rev",
"is",
"at",
"the",
"gap",
"of",
"two",
"generations",
"which",
"means",
"that",
"the",
"key",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/key_index.go#L304-L325 | test |
etcd-io/etcd | mvcc/watchable_store.go | cancelWatcher | func (s *watchableStore) cancelWatcher(wa *watcher) {
for {
s.mu.Lock()
if s.unsynced.delete(wa) {
slowWatcherGauge.Dec()
break
} else if s.synced.delete(wa) {
break
} else if wa.compacted {
break
} else if wa.ch == nil {
// already canceled (e.g., cancel/close race)
break
}
if !wa.vic... | go | func (s *watchableStore) cancelWatcher(wa *watcher) {
for {
s.mu.Lock()
if s.unsynced.delete(wa) {
slowWatcherGauge.Dec()
break
} else if s.synced.delete(wa) {
break
} else if wa.compacted {
break
} else if wa.ch == nil {
// already canceled (e.g., cancel/close race)
break
}
if !wa.vic... | [
"func",
"(",
"s",
"*",
"watchableStore",
")",
"cancelWatcher",
"(",
"wa",
"*",
"watcher",
")",
"{",
"for",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"s",
".",
"unsynced",
".",
"delete",
"(",
"wa",
")",
"{",
"slowWatcherGauge",
".",
... | // cancelWatcher removes references of the watcher from the watchableStore | [
"cancelWatcher",
"removes",
"references",
"of",
"the",
"watcher",
"from",
"the",
"watchableStore"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watchable_store.go#L145-L185 | test |
etcd-io/etcd | mvcc/watchable_store.go | syncWatchersLoop | func (s *watchableStore) syncWatchersLoop() {
defer s.wg.Done()
for {
s.mu.RLock()
st := time.Now()
lastUnsyncedWatchers := s.unsynced.size()
s.mu.RUnlock()
unsyncedWatchers := 0
if lastUnsyncedWatchers > 0 {
unsyncedWatchers = s.syncWatchers()
}
syncDuration := time.Since(st)
waitDuration := ... | go | func (s *watchableStore) syncWatchersLoop() {
defer s.wg.Done()
for {
s.mu.RLock()
st := time.Now()
lastUnsyncedWatchers := s.unsynced.size()
s.mu.RUnlock()
unsyncedWatchers := 0
if lastUnsyncedWatchers > 0 {
unsyncedWatchers = s.syncWatchers()
}
syncDuration := time.Since(st)
waitDuration := ... | [
"func",
"(",
"s",
"*",
"watchableStore",
")",
"syncWatchersLoop",
"(",
")",
"{",
"defer",
"s",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"for",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"st",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"... | // syncWatchersLoop syncs the watcher in the unsynced map every 100ms. | [
"syncWatchersLoop",
"syncs",
"the",
"watcher",
"in",
"the",
"unsynced",
"map",
"every",
"100ms",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watchable_store.go#L204-L232 | test |
etcd-io/etcd | mvcc/watchable_store.go | syncVictimsLoop | func (s *watchableStore) syncVictimsLoop() {
defer s.wg.Done()
for {
for s.moveVictims() != 0 {
// try to update all victim watchers
}
s.mu.RLock()
isEmpty := len(s.victims) == 0
s.mu.RUnlock()
var tickc <-chan time.Time
if !isEmpty {
tickc = time.After(10 * time.Millisecond)
}
select {
c... | go | func (s *watchableStore) syncVictimsLoop() {
defer s.wg.Done()
for {
for s.moveVictims() != 0 {
// try to update all victim watchers
}
s.mu.RLock()
isEmpty := len(s.victims) == 0
s.mu.RUnlock()
var tickc <-chan time.Time
if !isEmpty {
tickc = time.After(10 * time.Millisecond)
}
select {
c... | [
"func",
"(",
"s",
"*",
"watchableStore",
")",
"syncVictimsLoop",
"(",
")",
"{",
"defer",
"s",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"for",
"{",
"for",
"s",
".",
"moveVictims",
"(",
")",
"!=",
"0",
"{",
"}",
"\n",
"s",
".",
"mu",
".",
"RLock",... | // syncVictimsLoop tries to write precomputed watcher responses to
// watchers that had a blocked watcher channel | [
"syncVictimsLoop",
"tries",
"to",
"write",
"precomputed",
"watcher",
"responses",
"to",
"watchers",
"that",
"had",
"a",
"blocked",
"watcher",
"channel"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watchable_store.go#L236-L259 | test |
etcd-io/etcd | mvcc/watchable_store.go | moveVictims | func (s *watchableStore) moveVictims() (moved int) {
s.mu.Lock()
victims := s.victims
s.victims = nil
s.mu.Unlock()
var newVictim watcherBatch
for _, wb := range victims {
// try to send responses again
for w, eb := range wb {
// watcher has observed the store up to, but not including, w.minRev
rev := ... | go | func (s *watchableStore) moveVictims() (moved int) {
s.mu.Lock()
victims := s.victims
s.victims = nil
s.mu.Unlock()
var newVictim watcherBatch
for _, wb := range victims {
// try to send responses again
for w, eb := range wb {
// watcher has observed the store up to, but not including, w.minRev
rev := ... | [
"func",
"(",
"s",
"*",
"watchableStore",
")",
"moveVictims",
"(",
")",
"(",
"moved",
"int",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"victims",
":=",
"s",
".",
"victims",
"\n",
"s",
".",
"victims",
"=",
"nil",
"\n",
"s",
".",
"mu"... | // moveVictims tries to update watches with already pending event data | [
"moveVictims",
"tries",
"to",
"update",
"watches",
"with",
"already",
"pending",
"event",
"data"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watchable_store.go#L262-L317 | test |
etcd-io/etcd | mvcc/watchable_store.go | kvsToEvents | func kvsToEvents(lg *zap.Logger, wg *watcherGroup, revs, vals [][]byte) (evs []mvccpb.Event) {
for i, v := range vals {
var kv mvccpb.KeyValue
if err := kv.Unmarshal(v); err != nil {
if lg != nil {
lg.Panic("failed to unmarshal mvccpb.KeyValue", zap.Error(err))
} else {
plog.Panicf("cannot unmarshal ... | go | func kvsToEvents(lg *zap.Logger, wg *watcherGroup, revs, vals [][]byte) (evs []mvccpb.Event) {
for i, v := range vals {
var kv mvccpb.KeyValue
if err := kv.Unmarshal(v); err != nil {
if lg != nil {
lg.Panic("failed to unmarshal mvccpb.KeyValue", zap.Error(err))
} else {
plog.Panicf("cannot unmarshal ... | [
"func",
"kvsToEvents",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"wg",
"*",
"watcherGroup",
",",
"revs",
",",
"vals",
"[",
"]",
"[",
"]",
"byte",
")",
"(",
"evs",
"[",
"]",
"mvccpb",
".",
"Event",
")",
"{",
"for",
"i",
",",
"v",
":=",
"range",... | // kvsToEvents gets all events for the watchers from all key-value pairs | [
"kvsToEvents",
"gets",
"all",
"events",
"for",
"the",
"watchers",
"from",
"all",
"key",
"-",
"value",
"pairs"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watchable_store.go#L409-L433 | test |
etcd-io/etcd | mvcc/watchable_store.go | notify | func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
var victim watcherBatch
for w, eb := range newWatcherBatch(&s.synced, evs) {
if eb.revs != 1 {
if s.store != nil && s.store.lg != nil {
s.store.lg.Panic(
"unexpected multiple revisions in watch notification",
zap.Int("number-of-revisi... | go | func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
var victim watcherBatch
for w, eb := range newWatcherBatch(&s.synced, evs) {
if eb.revs != 1 {
if s.store != nil && s.store.lg != nil {
s.store.lg.Panic(
"unexpected multiple revisions in watch notification",
zap.Int("number-of-revisi... | [
"func",
"(",
"s",
"*",
"watchableStore",
")",
"notify",
"(",
"rev",
"int64",
",",
"evs",
"[",
"]",
"mvccpb",
".",
"Event",
")",
"{",
"var",
"victim",
"watcherBatch",
"\n",
"for",
"w",
",",
"eb",
":=",
"range",
"newWatcherBatch",
"(",
"&",
"s",
".",
... | // notify notifies the fact that given event at the given rev just happened to
// watchers that watch on the key of the event. | [
"notify",
"notifies",
"the",
"fact",
"that",
"given",
"event",
"at",
"the",
"given",
"rev",
"just",
"happened",
"to",
"watchers",
"that",
"watch",
"on",
"the",
"key",
"of",
"the",
"event",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watchable_store.go#L437-L465 | test |
etcd-io/etcd | clientv3/utils.go | isOpFuncCalled | func isOpFuncCalled(op string, opts []OpOption) bool {
for _, opt := range opts {
v := reflect.ValueOf(opt)
if v.Kind() == reflect.Func {
if opFunc := runtime.FuncForPC(v.Pointer()); opFunc != nil {
if strings.Contains(opFunc.Name(), op) {
return true
}
}
}
}
return false
} | go | func isOpFuncCalled(op string, opts []OpOption) bool {
for _, opt := range opts {
v := reflect.ValueOf(opt)
if v.Kind() == reflect.Func {
if opFunc := runtime.FuncForPC(v.Pointer()); opFunc != nil {
if strings.Contains(opFunc.Name(), op) {
return true
}
}
}
}
return false
} | [
"func",
"isOpFuncCalled",
"(",
"op",
"string",
",",
"opts",
"[",
"]",
"OpOption",
")",
"bool",
"{",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"opt",
")",
"\n",
"if",
"v",
".",
"Kind",
"(",
")",... | // Check if the provided function is being called in the op options. | [
"Check",
"if",
"the",
"provided",
"function",
"is",
"being",
"called",
"in",
"the",
"op",
"options",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/utils.go#L37-L49 | test |
etcd-io/etcd | mvcc/backend/batch_tx.go | UnsafePut | func (t *batchTx) UnsafePut(bucketName []byte, key []byte, value []byte) {
t.unsafePut(bucketName, key, value, false)
} | go | func (t *batchTx) UnsafePut(bucketName []byte, key []byte, value []byte) {
t.unsafePut(bucketName, key, value, false)
} | [
"func",
"(",
"t",
"*",
"batchTx",
")",
"UnsafePut",
"(",
"bucketName",
"[",
"]",
"byte",
",",
"key",
"[",
"]",
"byte",
",",
"value",
"[",
"]",
"byte",
")",
"{",
"t",
".",
"unsafePut",
"(",
"bucketName",
",",
"key",
",",
"value",
",",
"false",
")"... | // UnsafePut must be called holding the lock on the tx. | [
"UnsafePut",
"must",
"be",
"called",
"holding",
"the",
"lock",
"on",
"the",
"tx",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L88-L90 | test |
etcd-io/etcd | mvcc/backend/batch_tx.go | UnsafeSeqPut | func (t *batchTx) UnsafeSeqPut(bucketName []byte, key []byte, value []byte) {
t.unsafePut(bucketName, key, value, true)
} | go | func (t *batchTx) UnsafeSeqPut(bucketName []byte, key []byte, value []byte) {
t.unsafePut(bucketName, key, value, true)
} | [
"func",
"(",
"t",
"*",
"batchTx",
")",
"UnsafeSeqPut",
"(",
"bucketName",
"[",
"]",
"byte",
",",
"key",
"[",
"]",
"byte",
",",
"value",
"[",
"]",
"byte",
")",
"{",
"t",
".",
"unsafePut",
"(",
"bucketName",
",",
"key",
",",
"value",
",",
"true",
"... | // UnsafeSeqPut must be called holding the lock on the tx. | [
"UnsafeSeqPut",
"must",
"be",
"called",
"holding",
"the",
"lock",
"on",
"the",
"tx",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L93-L95 | test |
etcd-io/etcd | mvcc/backend/batch_tx.go | UnsafeRange | func (t *batchTx) UnsafeRange(bucketName, key, endKey []byte, limit int64) ([][]byte, [][]byte) {
bucket := t.tx.Bucket(bucketName)
if bucket == nil {
if t.backend.lg != nil {
t.backend.lg.Fatal(
"failed to find a bucket",
zap.String("bucket-name", string(bucketName)),
)
} else {
plog.Fatalf("buc... | go | func (t *batchTx) UnsafeRange(bucketName, key, endKey []byte, limit int64) ([][]byte, [][]byte) {
bucket := t.tx.Bucket(bucketName)
if bucket == nil {
if t.backend.lg != nil {
t.backend.lg.Fatal(
"failed to find a bucket",
zap.String("bucket-name", string(bucketName)),
)
} else {
plog.Fatalf("buc... | [
"func",
"(",
"t",
"*",
"batchTx",
")",
"UnsafeRange",
"(",
"bucketName",
",",
"key",
",",
"endKey",
"[",
"]",
"byte",
",",
"limit",
"int64",
")",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"[",
"]",
"[",
"]",
"byte",
")",
"{",
"bucket",
":=",
"t",
... | // UnsafeRange must be called holding the lock on the tx. | [
"UnsafeRange",
"must",
"be",
"called",
"holding",
"the",
"lock",
"on",
"the",
"tx",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L129-L142 | test |
etcd-io/etcd | mvcc/backend/batch_tx.go | UnsafeDelete | func (t *batchTx) UnsafeDelete(bucketName []byte, key []byte) {
bucket := t.tx.Bucket(bucketName)
if bucket == nil {
if t.backend.lg != nil {
t.backend.lg.Fatal(
"failed to find a bucket",
zap.String("bucket-name", string(bucketName)),
)
} else {
plog.Fatalf("bucket %s does not exist", bucketName... | go | func (t *batchTx) UnsafeDelete(bucketName []byte, key []byte) {
bucket := t.tx.Bucket(bucketName)
if bucket == nil {
if t.backend.lg != nil {
t.backend.lg.Fatal(
"failed to find a bucket",
zap.String("bucket-name", string(bucketName)),
)
} else {
plog.Fatalf("bucket %s does not exist", bucketName... | [
"func",
"(",
"t",
"*",
"batchTx",
")",
"UnsafeDelete",
"(",
"bucketName",
"[",
"]",
"byte",
",",
"key",
"[",
"]",
"byte",
")",
"{",
"bucket",
":=",
"t",
".",
"tx",
".",
"Bucket",
"(",
"bucketName",
")",
"\n",
"if",
"bucket",
"==",
"nil",
"{",
"if... | // UnsafeDelete must be called holding the lock on the tx. | [
"UnsafeDelete",
"must",
"be",
"called",
"holding",
"the",
"lock",
"on",
"the",
"tx",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L167-L192 | test |
etcd-io/etcd | mvcc/backend/batch_tx.go | UnsafeForEach | func (t *batchTx) UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error {
return unsafeForEach(t.tx, bucketName, visitor)
} | go | func (t *batchTx) UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error {
return unsafeForEach(t.tx, bucketName, visitor)
} | [
"func",
"(",
"t",
"*",
"batchTx",
")",
"UnsafeForEach",
"(",
"bucketName",
"[",
"]",
"byte",
",",
"visitor",
"func",
"(",
"k",
",",
"v",
"[",
"]",
"byte",
")",
"error",
")",
"error",
"{",
"return",
"unsafeForEach",
"(",
"t",
".",
"tx",
",",
"bucket... | // UnsafeForEach must be called holding the lock on the tx. | [
"UnsafeForEach",
"must",
"be",
"called",
"holding",
"the",
"lock",
"on",
"the",
"tx",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L195-L197 | test |
etcd-io/etcd | mvcc/backend/batch_tx.go | Commit | func (t *batchTx) Commit() {
t.Lock()
t.commit(false)
t.Unlock()
} | go | func (t *batchTx) Commit() {
t.Lock()
t.commit(false)
t.Unlock()
} | [
"func",
"(",
"t",
"*",
"batchTx",
")",
"Commit",
"(",
")",
"{",
"t",
".",
"Lock",
"(",
")",
"\n",
"t",
".",
"commit",
"(",
"false",
")",
"\n",
"t",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Commit commits a previous tx and begins a new writable one. | [
"Commit",
"commits",
"a",
"previous",
"tx",
"and",
"begins",
"a",
"new",
"writable",
"one",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L207-L211 | test |
etcd-io/etcd | mvcc/backend/batch_tx.go | CommitAndStop | func (t *batchTx) CommitAndStop() {
t.Lock()
t.commit(true)
t.Unlock()
} | go | func (t *batchTx) CommitAndStop() {
t.Lock()
t.commit(true)
t.Unlock()
} | [
"func",
"(",
"t",
"*",
"batchTx",
")",
"CommitAndStop",
"(",
")",
"{",
"t",
".",
"Lock",
"(",
")",
"\n",
"t",
".",
"commit",
"(",
"true",
")",
"\n",
"t",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // CommitAndStop commits the previous tx and does not create a new one. | [
"CommitAndStop",
"commits",
"the",
"previous",
"tx",
"and",
"does",
"not",
"create",
"a",
"new",
"one",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L214-L218 | test |
etcd-io/etcd | lease/lessor.go | Renew | func (le *lessor) Renew(id LeaseID) (int64, error) {
le.mu.RLock()
if !le.isPrimary() {
// forward renew request to primary instead of returning error.
le.mu.RUnlock()
return -1, ErrNotPrimary
}
demotec := le.demotec
l := le.leaseMap[id]
if l == nil {
le.mu.RUnlock()
return -1, ErrLeaseNotFound
}
//... | go | func (le *lessor) Renew(id LeaseID) (int64, error) {
le.mu.RLock()
if !le.isPrimary() {
// forward renew request to primary instead of returning error.
le.mu.RUnlock()
return -1, ErrNotPrimary
}
demotec := le.demotec
l := le.leaseMap[id]
if l == nil {
le.mu.RUnlock()
return -1, ErrLeaseNotFound
}
//... | [
"func",
"(",
"le",
"*",
"lessor",
")",
"Renew",
"(",
"id",
"LeaseID",
")",
"(",
"int64",
",",
"error",
")",
"{",
"le",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"if",
"!",
"le",
".",
"isPrimary",
"(",
")",
"{",
"le",
".",
"mu",
".",
"RUnlock",... | // Renew renews an existing lease. If the given lease does not exist or
// has expired, an error will be returned. | [
"Renew",
"renews",
"an",
"existing",
"lease",
".",
"If",
"the",
"given",
"lease",
"does",
"not",
"exist",
"or",
"has",
"expired",
"an",
"error",
"will",
"be",
"returned",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L351-L401 | test |
etcd-io/etcd | lease/lessor.go | Attach | func (le *lessor) Attach(id LeaseID, items []LeaseItem) error {
le.mu.Lock()
defer le.mu.Unlock()
l := le.leaseMap[id]
if l == nil {
return ErrLeaseNotFound
}
l.mu.Lock()
for _, it := range items {
l.itemSet[it] = struct{}{}
le.itemMap[it] = id
}
l.mu.Unlock()
return nil
} | go | func (le *lessor) Attach(id LeaseID, items []LeaseItem) error {
le.mu.Lock()
defer le.mu.Unlock()
l := le.leaseMap[id]
if l == nil {
return ErrLeaseNotFound
}
l.mu.Lock()
for _, it := range items {
l.itemSet[it] = struct{}{}
le.itemMap[it] = id
}
l.mu.Unlock()
return nil
} | [
"func",
"(",
"le",
"*",
"lessor",
")",
"Attach",
"(",
"id",
"LeaseID",
",",
"items",
"[",
"]",
"LeaseItem",
")",
"error",
"{",
"le",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"le",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"l",
":=",
"... | // Attach attaches items to the lease with given ID. When the lease
// expires, the attached items will be automatically removed.
// If the given lease does not exist, an error will be returned. | [
"Attach",
"attaches",
"items",
"to",
"the",
"lease",
"with",
"given",
"ID",
".",
"When",
"the",
"lease",
"expires",
"the",
"attached",
"items",
"will",
"be",
"automatically",
"removed",
".",
"If",
"the",
"given",
"lease",
"does",
"not",
"exist",
"an",
"err... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L504-L520 | test |
etcd-io/etcd | lease/lessor.go | revokeExpiredLeases | func (le *lessor) revokeExpiredLeases() {
var ls []*Lease
// rate limit
revokeLimit := leaseRevokeRate / 2
le.mu.RLock()
if le.isPrimary() {
ls = le.findExpiredLeases(revokeLimit)
}
le.mu.RUnlock()
if len(ls) != 0 {
select {
case <-le.stopC:
return
case le.expiredC <- ls:
default:
// the rece... | go | func (le *lessor) revokeExpiredLeases() {
var ls []*Lease
// rate limit
revokeLimit := leaseRevokeRate / 2
le.mu.RLock()
if le.isPrimary() {
ls = le.findExpiredLeases(revokeLimit)
}
le.mu.RUnlock()
if len(ls) != 0 {
select {
case <-le.stopC:
return
case le.expiredC <- ls:
default:
// the rece... | [
"func",
"(",
"le",
"*",
"lessor",
")",
"revokeExpiredLeases",
"(",
")",
"{",
"var",
"ls",
"[",
"]",
"*",
"Lease",
"\n",
"revokeLimit",
":=",
"leaseRevokeRate",
"/",
"2",
"\n",
"le",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"if",
"le",
".",
"isPrima... | // revokeExpiredLeases finds all leases past their expiry and sends them to epxired channel for
// to be revoked. | [
"revokeExpiredLeases",
"finds",
"all",
"leases",
"past",
"their",
"expiry",
"and",
"sends",
"them",
"to",
"epxired",
"channel",
"for",
"to",
"be",
"revoked",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L586-L609 | test |
etcd-io/etcd | lease/lessor.go | checkpointScheduledLeases | func (le *lessor) checkpointScheduledLeases() {
var cps []*pb.LeaseCheckpoint
// rate limit
for i := 0; i < leaseCheckpointRate/2; i++ {
le.mu.Lock()
if le.isPrimary() {
cps = le.findDueScheduledCheckpoints(maxLeaseCheckpointBatchSize)
}
le.mu.Unlock()
if len(cps) != 0 {
le.cp(context.Background(),... | go | func (le *lessor) checkpointScheduledLeases() {
var cps []*pb.LeaseCheckpoint
// rate limit
for i := 0; i < leaseCheckpointRate/2; i++ {
le.mu.Lock()
if le.isPrimary() {
cps = le.findDueScheduledCheckpoints(maxLeaseCheckpointBatchSize)
}
le.mu.Unlock()
if len(cps) != 0 {
le.cp(context.Background(),... | [
"func",
"(",
"le",
"*",
"lessor",
")",
"checkpointScheduledLeases",
"(",
")",
"{",
"var",
"cps",
"[",
"]",
"*",
"pb",
".",
"LeaseCheckpoint",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"leaseCheckpointRate",
"/",
"2",
";",
"i",
"++",
"{",
"le",
".... | // checkpointScheduledLeases finds all scheduled lease checkpoints that are due and
// submits them to the checkpointer to persist them to the consensus log. | [
"checkpointScheduledLeases",
"finds",
"all",
"scheduled",
"lease",
"checkpoints",
"that",
"are",
"due",
"and",
"submits",
"them",
"to",
"the",
"checkpointer",
"to",
"persist",
"them",
"to",
"the",
"consensus",
"log",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L613-L631 | test |
etcd-io/etcd | lease/lessor.go | expireExists | func (le *lessor) expireExists() (l *Lease, ok bool, next bool) {
if le.leaseHeap.Len() == 0 {
return nil, false, false
}
item := le.leaseHeap[0]
l = le.leaseMap[item.id]
if l == nil {
// lease has expired or been revoked
// no need to revoke (nothing is expiry)
heap.Pop(&le.leaseHeap) // O(log N)
retur... | go | func (le *lessor) expireExists() (l *Lease, ok bool, next bool) {
if le.leaseHeap.Len() == 0 {
return nil, false, false
}
item := le.leaseHeap[0]
l = le.leaseMap[item.id]
if l == nil {
// lease has expired or been revoked
// no need to revoke (nothing is expiry)
heap.Pop(&le.leaseHeap) // O(log N)
retur... | [
"func",
"(",
"le",
"*",
"lessor",
")",
"expireExists",
"(",
")",
"(",
"l",
"*",
"Lease",
",",
"ok",
"bool",
",",
"next",
"bool",
")",
"{",
"if",
"le",
".",
"leaseHeap",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"false",
",",
... | // expireExists returns true if expiry items exist.
// It pops only when expiry item exists.
// "next" is true, to indicate that it may exist in next attempt. | [
"expireExists",
"returns",
"true",
"if",
"expiry",
"items",
"exist",
".",
"It",
"pops",
"only",
"when",
"expiry",
"item",
"exists",
".",
"next",
"is",
"true",
"to",
"indicate",
"that",
"it",
"may",
"exist",
"in",
"next",
"attempt",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L640-L663 | test |
etcd-io/etcd | lease/lessor.go | findExpiredLeases | func (le *lessor) findExpiredLeases(limit int) []*Lease {
leases := make([]*Lease, 0, 16)
for {
l, ok, next := le.expireExists()
if !ok && !next {
break
}
if !ok {
continue
}
if next {
continue
}
if l.expired() {
leases = append(leases, l)
// reach expired limit
if len(leases) == ... | go | func (le *lessor) findExpiredLeases(limit int) []*Lease {
leases := make([]*Lease, 0, 16)
for {
l, ok, next := le.expireExists()
if !ok && !next {
break
}
if !ok {
continue
}
if next {
continue
}
if l.expired() {
leases = append(leases, l)
// reach expired limit
if len(leases) == ... | [
"func",
"(",
"le",
"*",
"lessor",
")",
"findExpiredLeases",
"(",
"limit",
"int",
")",
"[",
"]",
"*",
"Lease",
"{",
"leases",
":=",
"make",
"(",
"[",
"]",
"*",
"Lease",
",",
"0",
",",
"16",
")",
"\n",
"for",
"{",
"l",
",",
"ok",
",",
"next",
"... | // findExpiredLeases loops leases in the leaseMap until reaching expired limit
// and returns the expired leases that needed to be revoked. | [
"findExpiredLeases",
"loops",
"leases",
"in",
"the",
"leaseMap",
"until",
"reaching",
"expired",
"limit",
"and",
"returns",
"the",
"expired",
"leases",
"that",
"needed",
"to",
"be",
"revoked",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L667-L693 | test |
etcd-io/etcd | lease/lessor.go | refresh | func (l *Lease) refresh(extend time.Duration) {
newExpiry := time.Now().Add(extend + time.Duration(l.RemainingTTL())*time.Second)
l.expiryMu.Lock()
defer l.expiryMu.Unlock()
l.expiry = newExpiry
} | go | func (l *Lease) refresh(extend time.Duration) {
newExpiry := time.Now().Add(extend + time.Duration(l.RemainingTTL())*time.Second)
l.expiryMu.Lock()
defer l.expiryMu.Unlock()
l.expiry = newExpiry
} | [
"func",
"(",
"l",
"*",
"Lease",
")",
"refresh",
"(",
"extend",
"time",
".",
"Duration",
")",
"{",
"newExpiry",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"extend",
"+",
"time",
".",
"Duration",
"(",
"l",
".",
"RemainingTTL",
"(",
")",
"... | // refresh refreshes the expiry of the lease. | [
"refresh",
"refreshes",
"the",
"expiry",
"of",
"the",
"lease",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L833-L838 | test |
etcd-io/etcd | lease/lessor.go | forever | func (l *Lease) forever() {
l.expiryMu.Lock()
defer l.expiryMu.Unlock()
l.expiry = forever
} | go | func (l *Lease) forever() {
l.expiryMu.Lock()
defer l.expiryMu.Unlock()
l.expiry = forever
} | [
"func",
"(",
"l",
"*",
"Lease",
")",
"forever",
"(",
")",
"{",
"l",
".",
"expiryMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"expiryMu",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"expiry",
"=",
"forever",
"\n",
"}"
] | // forever sets the expiry of lease to be forever. | [
"forever",
"sets",
"the",
"expiry",
"of",
"lease",
"to",
"be",
"forever",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L841-L845 | test |
etcd-io/etcd | lease/lessor.go | Keys | func (l *Lease) Keys() []string {
l.mu.RLock()
keys := make([]string, 0, len(l.itemSet))
for k := range l.itemSet {
keys = append(keys, k.Key)
}
l.mu.RUnlock()
return keys
} | go | func (l *Lease) Keys() []string {
l.mu.RLock()
keys := make([]string, 0, len(l.itemSet))
for k := range l.itemSet {
keys = append(keys, k.Key)
}
l.mu.RUnlock()
return keys
} | [
"func",
"(",
"l",
"*",
"Lease",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"l",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"l",
".",
"itemSet",
")",
")",
"\n",
"... | // Keys returns all the keys attached to the lease. | [
"Keys",
"returns",
"all",
"the",
"keys",
"attached",
"to",
"the",
"lease",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L848-L856 | test |
etcd-io/etcd | lease/lessor.go | Remaining | func (l *Lease) Remaining() time.Duration {
l.expiryMu.RLock()
defer l.expiryMu.RUnlock()
if l.expiry.IsZero() {
return time.Duration(math.MaxInt64)
}
return time.Until(l.expiry)
} | go | func (l *Lease) Remaining() time.Duration {
l.expiryMu.RLock()
defer l.expiryMu.RUnlock()
if l.expiry.IsZero() {
return time.Duration(math.MaxInt64)
}
return time.Until(l.expiry)
} | [
"func",
"(",
"l",
"*",
"Lease",
")",
"Remaining",
"(",
")",
"time",
".",
"Duration",
"{",
"l",
".",
"expiryMu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"l",
".",
"expiryMu",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"l",
".",
"expiry",
".",
"IsZero",
... | // Remaining returns the remaining time of the lease. | [
"Remaining",
"returns",
"the",
"remaining",
"time",
"of",
"the",
"lease",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L859-L866 | test |
etcd-io/etcd | etcdctl/ctlv3/command/compaction_command.go | NewCompactionCommand | func NewCompactionCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "compaction [options] <revision>",
Short: "Compacts the event history in etcd",
Run: compactionCommandFunc,
}
cmd.Flags().BoolVar(&compactPhysical, "physical", false, "'true' to wait for compaction to physically remove all old revisio... | go | func NewCompactionCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "compaction [options] <revision>",
Short: "Compacts the event history in etcd",
Run: compactionCommandFunc,
}
cmd.Flags().BoolVar(&compactPhysical, "physical", false, "'true' to wait for compaction to physically remove all old revisio... | [
"func",
"NewCompactionCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"compaction [options] <revision>\"",
",",
"Short",
":",
"\"Compacts the event history in etcd\"",
",",
"Run",
":",
"compactio... | // NewCompactionCommand returns the cobra command for "compaction". | [
"NewCompactionCommand",
"returns",
"the",
"cobra",
"command",
"for",
"compaction",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/compaction_command.go#L28-L36 | test |
etcd-io/etcd | etcdctl/ctlv3/command/compaction_command.go | compactionCommandFunc | func compactionCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("compaction command needs 1 argument"))
}
rev, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
ExitWithError(ExitError, err)
}
var opts []clientv3.CompactOption
if compactPhysi... | go | func compactionCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("compaction command needs 1 argument"))
}
rev, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
ExitWithError(ExitError, err)
}
var opts []clientv3.CompactOption
if compactPhysi... | [
"func",
"compactionCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"compaction comman... | // compactionCommandFunc executes the "compaction" command. | [
"compactionCommandFunc",
"executes",
"the",
"compaction",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/compaction_command.go#L39-L62 | test |
etcd-io/etcd | etcdctl/ctlv3/command/put_command.go | NewPutCommand | func NewPutCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "put [options] <key> <value> (<value> can also be given from stdin)",
Short: "Puts the given key into the store",
Long: `
Puts the given key into the store.
When <value> begins with '-', <value> is interpreted as a flag.
Insert '--' for workaro... | go | func NewPutCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "put [options] <key> <value> (<value> can also be given from stdin)",
Short: "Puts the given key into the store",
Long: `
Puts the given key into the store.
When <value> begins with '-', <value> is interpreted as a flag.
Insert '--' for workaro... | [
"func",
"NewPutCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"put [options] <key> <value> (<value> can also be given from stdin)\"",
",",
"Short",
":",
"\"Puts the given key into the store\"",
",",
... | // NewPutCommand returns the cobra command for "put". | [
"NewPutCommand",
"returns",
"the",
"cobra",
"command",
"for",
"put",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/put_command.go#L34-L64 | test |
etcd-io/etcd | etcdctl/ctlv3/command/put_command.go | putCommandFunc | func putCommandFunc(cmd *cobra.Command, args []string) {
key, value, opts := getPutOp(args)
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Put(ctx, key, value, opts...)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
display.Put(*resp)
} | go | func putCommandFunc(cmd *cobra.Command, args []string) {
key, value, opts := getPutOp(args)
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Put(ctx, key, value, opts...)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
display.Put(*resp)
} | [
"func",
"putCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"key",
",",
"value",
",",
"opts",
":=",
"getPutOp",
"(",
"args",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"commandCtx",
"(",
"cmd",
")",
"\... | // putCommandFunc executes the "put" command. | [
"putCommandFunc",
"executes",
"the",
"put",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/put_command.go#L67-L77 | test |
etcd-io/etcd | proxy/httpproxy/proxy.go | NewHandler | func NewHandler(t *http.Transport, urlsFunc GetProxyURLs, failureWait time.Duration, refreshInterval time.Duration) http.Handler {
if t.TLSClientConfig != nil {
// Enable http2, see Issue 5033.
err := http2.ConfigureTransport(t)
if err != nil {
plog.Infof("Error enabling Transport HTTP/2 support: %v", err)
... | go | func NewHandler(t *http.Transport, urlsFunc GetProxyURLs, failureWait time.Duration, refreshInterval time.Duration) http.Handler {
if t.TLSClientConfig != nil {
// Enable http2, see Issue 5033.
err := http2.ConfigureTransport(t)
if err != nil {
plog.Infof("Error enabling Transport HTTP/2 support: %v", err)
... | [
"func",
"NewHandler",
"(",
"t",
"*",
"http",
".",
"Transport",
",",
"urlsFunc",
"GetProxyURLs",
",",
"failureWait",
"time",
".",
"Duration",
",",
"refreshInterval",
"time",
".",
"Duration",
")",
"http",
".",
"Handler",
"{",
"if",
"t",
".",
"TLSClientConfig",... | // NewHandler creates a new HTTP handler, listening on the given transport,
// which will proxy requests to an etcd cluster.
// The handler will periodically update its view of the cluster. | [
"NewHandler",
"creates",
"a",
"new",
"HTTP",
"handler",
"listening",
"on",
"the",
"given",
"transport",
"which",
"will",
"proxy",
"requests",
"to",
"an",
"etcd",
"cluster",
".",
"The",
"handler",
"will",
"periodically",
"update",
"its",
"view",
"of",
"the",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/httpproxy/proxy.go#L46-L65 | test |
etcd-io/etcd | proxy/httpproxy/proxy.go | NewReadonlyHandler | func NewReadonlyHandler(hdlr http.Handler) http.Handler {
readonly := readonlyHandlerFunc(hdlr)
return http.HandlerFunc(readonly)
} | go | func NewReadonlyHandler(hdlr http.Handler) http.Handler {
readonly := readonlyHandlerFunc(hdlr)
return http.HandlerFunc(readonly)
} | [
"func",
"NewReadonlyHandler",
"(",
"hdlr",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"readonly",
":=",
"readonlyHandlerFunc",
"(",
"hdlr",
")",
"\n",
"return",
"http",
".",
"HandlerFunc",
"(",
"readonly",
")",
"\n",
"}"
] | // NewReadonlyHandler wraps the given HTTP handler to allow only GET requests | [
"NewReadonlyHandler",
"wraps",
"the",
"given",
"HTTP",
"handler",
"to",
"allow",
"only",
"GET",
"requests"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/httpproxy/proxy.go#L68-L71 | test |
etcd-io/etcd | etcdctl/ctlv2/command/set_command.go | NewSetCommand | func NewSetCommand() cli.Command {
return cli.Command{
Name: "set",
Usage: "set the value of a key",
ArgsUsage: "<key> <value>",
Description: `Set sets the value of a key.
When <value> begins with '-', <value> is interpreted as a flag.
Insert '--' for workaround:
$ set -- <key> <value>`,
... | go | func NewSetCommand() cli.Command {
return cli.Command{
Name: "set",
Usage: "set the value of a key",
ArgsUsage: "<key> <value>",
Description: `Set sets the value of a key.
When <value> begins with '-', <value> is interpreted as a flag.
Insert '--' for workaround:
$ set -- <key> <value>`,
... | [
"func",
"NewSetCommand",
"(",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"set\"",
",",
"Usage",
":",
"\"set the value of a key\"",
",",
"ArgsUsage",
":",
"\"<key> <value>\"",
",",
"Description",
":",
"`Set sets the valu... | // NewSetCommand returns the CLI command for "set". | [
"NewSetCommand",
"returns",
"the",
"CLI",
"command",
"for",
"set",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/set_command.go#L27-L48 | test |
etcd-io/etcd | etcdctl/ctlv2/command/set_command.go | setCommandFunc | func setCommandFunc(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")
prevV... | go | func setCommandFunc(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")
prevV... | [
"func",
"setCommandFunc",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"ki",
"client",
".",
"KeysAPI",
")",
"{",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"==",
"0",
"{",
"handleError",
"(",
"c",
",",
"ExitBadArgs",
",",
"errors",
".",
"Ne... | // setCommandFunc executes the "set" command. | [
"setCommandFunc",
"executes",
"the",
"set",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/set_command.go#L51-L73 | test |
etcd-io/etcd | contrib/recipes/rwmutex.go | waitOnLastRev | func (rwm *RWMutex) waitOnLastRev(pfx string) (bool, error) {
client := rwm.s.Client()
// get key that's blocking myKey
opts := append(v3.WithLastRev(), v3.WithMaxModRev(rwm.myKey.Revision()-1))
lastKey, err := client.Get(rwm.ctx, pfx, opts...)
if err != nil {
return false, err
}
if len(lastKey.Kvs) == 0 {
r... | go | func (rwm *RWMutex) waitOnLastRev(pfx string) (bool, error) {
client := rwm.s.Client()
// get key that's blocking myKey
opts := append(v3.WithLastRev(), v3.WithMaxModRev(rwm.myKey.Revision()-1))
lastKey, err := client.Get(rwm.ctx, pfx, opts...)
if err != nil {
return false, err
}
if len(lastKey.Kvs) == 0 {
r... | [
"func",
"(",
"rwm",
"*",
"RWMutex",
")",
"waitOnLastRev",
"(",
"pfx",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"client",
":=",
"rwm",
".",
"s",
".",
"Client",
"(",
")",
"\n",
"opts",
":=",
"append",
"(",
"v3",
".",
"WithLastRev",
"(",
... | // waitOnLowest will wait on the last key with a revision < rwm.myKey.Revision with a
// given prefix. If there are no keys left to wait on, return true. | [
"waitOnLowest",
"will",
"wait",
"on",
"the",
"last",
"key",
"with",
"a",
"revision",
"<",
"rwm",
".",
"myKey",
".",
"Revision",
"with",
"a",
"given",
"prefix",
".",
"If",
"there",
"are",
"no",
"keys",
"left",
"to",
"wait",
"on",
"return",
"true",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/rwmutex.go#L68-L86 | test |
etcd-io/etcd | pkg/netutil/routes.go | GetDefaultInterfaces | func GetDefaultInterfaces() (map[string]uint8, error) {
return nil, fmt.Errorf("default host not supported on %s_%s", runtime.GOOS, runtime.GOARCH)
} | go | func GetDefaultInterfaces() (map[string]uint8, error) {
return nil, fmt.Errorf("default host not supported on %s_%s", runtime.GOOS, runtime.GOARCH)
} | [
"func",
"GetDefaultInterfaces",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"uint8",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"default host not supported on %s_%s\"",
",",
"runtime",
".",
"GOOS",
",",
"runtime",
".",
"GOARCH",... | // GetDefaultInterfaces fetches the device name of default routable interface. | [
"GetDefaultInterfaces",
"fetches",
"the",
"device",
"name",
"of",
"default",
"routable",
"interface",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/routes.go#L31-L33 | test |
etcd-io/etcd | etcdctl/ctlv3/command/snapshot_command.go | NewSnapshotCommand | func NewSnapshotCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "snapshot <subcommand>",
Short: "Manages etcd node snapshots",
}
cmd.AddCommand(NewSnapshotSaveCommand())
cmd.AddCommand(NewSnapshotRestoreCommand())
cmd.AddCommand(newSnapshotStatusCommand())
return cmd
} | go | func NewSnapshotCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "snapshot <subcommand>",
Short: "Manages etcd node snapshots",
}
cmd.AddCommand(NewSnapshotSaveCommand())
cmd.AddCommand(NewSnapshotRestoreCommand())
cmd.AddCommand(newSnapshotStatusCommand())
return cmd
} | [
"func",
"NewSnapshotCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"snapshot <subcommand>\"",
",",
"Short",
":",
"\"Manages etcd node snapshots\"",
",",
"}",
"\n",
"cmd",
".",
"AddCommand",
... | // NewSnapshotCommand returns the cobra command for "snapshot". | [
"NewSnapshotCommand",
"returns",
"the",
"cobra",
"command",
"for",
"snapshot",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/snapshot_command.go#L45-L54 | test |
etcd-io/etcd | etcdctl/ctlv3/command/move_leader_command.go | NewMoveLeaderCommand | func NewMoveLeaderCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "move-leader <transferee-member-id>",
Short: "Transfers leadership to another etcd cluster member.",
Run: transferLeadershipCommandFunc,
}
return cmd
} | go | func NewMoveLeaderCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "move-leader <transferee-member-id>",
Short: "Transfers leadership to another etcd cluster member.",
Run: transferLeadershipCommandFunc,
}
return cmd
} | [
"func",
"NewMoveLeaderCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"move-leader <transferee-member-id>\"",
",",
"Short",
":",
"\"Transfers leadership to another etcd cluster member.\"",
",",
"Run"... | // NewMoveLeaderCommand returns the cobra command for "move-leader". | [
"NewMoveLeaderCommand",
"returns",
"the",
"cobra",
"command",
"for",
"move",
"-",
"leader",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/move_leader_command.go#L26-L33 | test |
etcd-io/etcd | etcdctl/ctlv3/command/move_leader_command.go | transferLeadershipCommandFunc | func transferLeadershipCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("move-leader command needs 1 argument"))
}
target, err := strconv.ParseUint(args[0], 16, 64)
if err != nil {
ExitWithError(ExitBadArgs, err)
}
c := mustClientFromCmd(cmd)
eps := ... | go | func transferLeadershipCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("move-leader command needs 1 argument"))
}
target, err := strconv.ParseUint(args[0], 16, 64)
if err != nil {
ExitWithError(ExitBadArgs, err)
}
c := mustClientFromCmd(cmd)
eps := ... | [
"func",
"transferLeadershipCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"move-lead... | // transferLeadershipCommandFunc executes the "compaction" command. | [
"transferLeadershipCommandFunc",
"executes",
"the",
"compaction",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/move_leader_command.go#L36-L82 | test |
etcd-io/etcd | pkg/fileutil/dir_windows.go | OpenDir | func OpenDir(path string) (*os.File, error) {
fd, err := openDir(path)
if err != nil {
return nil, err
}
return os.NewFile(uintptr(fd), path), nil
} | go | func OpenDir(path string) (*os.File, error) {
fd, err := openDir(path)
if err != nil {
return nil, err
}
return os.NewFile(uintptr(fd), path), nil
} | [
"func",
"OpenDir",
"(",
"path",
"string",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"fd",
",",
"err",
":=",
"openDir",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return"... | // OpenDir opens a directory in windows with write access for syncing. | [
"OpenDir",
"opens",
"a",
"directory",
"in",
"windows",
"with",
"write",
"access",
"for",
"syncing",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/fileutil/dir_windows.go#L25-L31 | test |
etcd-io/etcd | etcdctl/ctlv2/command/rmdir_command.go | NewRemoveDirCommand | func NewRemoveDirCommand() cli.Command {
return cli.Command{
Name: "rmdir",
Usage: "removes the key if it is an empty directory or a key-value pair",
ArgsUsage: "<key>",
Action: func(c *cli.Context) error {
rmdirCommandFunc(c, mustNewKeyAPI(c))
return nil
},
}
} | go | func NewRemoveDirCommand() cli.Command {
return cli.Command{
Name: "rmdir",
Usage: "removes the key if it is an empty directory or a key-value pair",
ArgsUsage: "<key>",
Action: func(c *cli.Context) error {
rmdirCommandFunc(c, mustNewKeyAPI(c))
return nil
},
}
} | [
"func",
"NewRemoveDirCommand",
"(",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"rmdir\"",
",",
"Usage",
":",
"\"removes the key if it is an empty directory or a key-value pair\"",
",",
"ArgsUsage",
":",
"\"<key>\"",
",",
"A... | // NewRemoveDirCommand returns the CLI command for "rmdir". | [
"NewRemoveDirCommand",
"returns",
"the",
"CLI",
"command",
"for",
"rmdir",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/rmdir_command.go#L25-L35 | test |
etcd-io/etcd | etcdctl/ctlv2/command/rmdir_command.go | rmdirCommandFunc | func rmdirCommandFunc(c *cli.Context, ki client.KeysAPI) {
if len(c.Args()) == 0 {
handleError(c, ExitBadArgs, errors.New("key required"))
}
key := c.Args()[0]
ctx, cancel := contextWithTotalTimeout(c)
resp, err := ki.Delete(ctx, key, &client.DeleteOptions{Dir: true})
cancel()
if err != nil {
handleError(c,... | go | func rmdirCommandFunc(c *cli.Context, ki client.KeysAPI) {
if len(c.Args()) == 0 {
handleError(c, ExitBadArgs, errors.New("key required"))
}
key := c.Args()[0]
ctx, cancel := contextWithTotalTimeout(c)
resp, err := ki.Delete(ctx, key, &client.DeleteOptions{Dir: true})
cancel()
if err != nil {
handleError(c,... | [
"func",
"rmdirCommandFunc",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"ki",
"client",
".",
"KeysAPI",
")",
"{",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"==",
"0",
"{",
"handleError",
"(",
"c",
",",
"ExitBadArgs",
",",
"errors",
".",
"... | // rmdirCommandFunc executes the "rmdir" command. | [
"rmdirCommandFunc",
"executes",
"the",
"rmdir",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/rmdir_command.go#L38-L54 | test |
etcd-io/etcd | etcdctl/ctlv3/command/del_command.go | NewDelCommand | func NewDelCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "del [options] <key> [range_end]",
Short: "Removes the specified key or range of keys [key, range_end)",
Run: delCommandFunc,
}
cmd.Flags().BoolVar(&delPrefix, "prefix", false, "delete keys with matching prefix")
cmd.Flags().BoolVar(&delPr... | go | func NewDelCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "del [options] <key> [range_end]",
Short: "Removes the specified key or range of keys [key, range_end)",
Run: delCommandFunc,
}
cmd.Flags().BoolVar(&delPrefix, "prefix", false, "delete keys with matching prefix")
cmd.Flags().BoolVar(&delPr... | [
"func",
"NewDelCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"del [options] <key> [range_end]\"",
",",
"Short",
":",
"\"Removes the specified key or range of keys [key, range_end)\"",
",",
"Run",
... | // NewDelCommand returns the cobra command for "del". | [
"NewDelCommand",
"returns",
"the",
"cobra",
"command",
"for",
"del",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/del_command.go#L31-L42 | test |
etcd-io/etcd | etcdctl/ctlv3/command/del_command.go | delCommandFunc | func delCommandFunc(cmd *cobra.Command, args []string) {
key, opts := getDelOp(args)
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
display.Del(*resp)
} | go | func delCommandFunc(cmd *cobra.Command, args []string) {
key, opts := getDelOp(args)
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
display.Del(*resp)
} | [
"func",
"delCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"key",
",",
"opts",
":=",
"getDelOp",
"(",
"args",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"commandCtx",
"(",
"cmd",
")",
"\n",
"resp",
",... | // delCommandFunc executes the "del" command. | [
"delCommandFunc",
"executes",
"the",
"del",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/del_command.go#L45-L54 | test |
etcd-io/etcd | pkg/expect/expect.go | NewExpect | func NewExpect(name string, arg ...string) (ep *ExpectProcess, err error) {
// if env[] is nil, use current system env
return NewExpectWithEnv(name, arg, nil)
} | go | func NewExpect(name string, arg ...string) (ep *ExpectProcess, err error) {
// if env[] is nil, use current system env
return NewExpectWithEnv(name, arg, nil)
} | [
"func",
"NewExpect",
"(",
"name",
"string",
",",
"arg",
"...",
"string",
")",
"(",
"ep",
"*",
"ExpectProcess",
",",
"err",
"error",
")",
"{",
"return",
"NewExpectWithEnv",
"(",
"name",
",",
"arg",
",",
"nil",
")",
"\n",
"}"
] | // NewExpect creates a new process for expect testing. | [
"NewExpect",
"creates",
"a",
"new",
"process",
"for",
"expect",
"testing",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/expect/expect.go#L47-L50 | test |
etcd-io/etcd | pkg/expect/expect.go | NewExpectWithEnv | func NewExpectWithEnv(name string, args []string, env []string) (ep *ExpectProcess, err error) {
cmd := exec.Command(name, args...)
cmd.Env = env
ep = &ExpectProcess{
cmd: cmd,
StopSignal: syscall.SIGKILL,
}
ep.cond = sync.NewCond(&ep.mu)
ep.cmd.Stderr = ep.cmd.Stdout
ep.cmd.Stdin = nil
if ep.fpty, ... | go | func NewExpectWithEnv(name string, args []string, env []string) (ep *ExpectProcess, err error) {
cmd := exec.Command(name, args...)
cmd.Env = env
ep = &ExpectProcess{
cmd: cmd,
StopSignal: syscall.SIGKILL,
}
ep.cond = sync.NewCond(&ep.mu)
ep.cmd.Stderr = ep.cmd.Stdout
ep.cmd.Stdin = nil
if ep.fpty, ... | [
"func",
"NewExpectWithEnv",
"(",
"name",
"string",
",",
"args",
"[",
"]",
"string",
",",
"env",
"[",
"]",
"string",
")",
"(",
"ep",
"*",
"ExpectProcess",
",",
"err",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"name",
",",
"args",
... | // NewExpectWithEnv creates a new process with user defined env variables for expect testing. | [
"NewExpectWithEnv",
"creates",
"a",
"new",
"process",
"with",
"user",
"defined",
"env",
"variables",
"for",
"expect",
"testing",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/expect/expect.go#L53-L71 | test |
etcd-io/etcd | pkg/expect/expect.go | ExpectFunc | func (ep *ExpectProcess) ExpectFunc(f func(string) bool) (string, error) {
ep.mu.Lock()
for {
for len(ep.lines) == 0 && ep.err == nil {
ep.cond.Wait()
}
if len(ep.lines) == 0 {
break
}
l := ep.lines[0]
ep.lines = ep.lines[1:]
if f(l) {
ep.mu.Unlock()
return l, nil
}
}
ep.mu.Unlock()
ret... | go | func (ep *ExpectProcess) ExpectFunc(f func(string) bool) (string, error) {
ep.mu.Lock()
for {
for len(ep.lines) == 0 && ep.err == nil {
ep.cond.Wait()
}
if len(ep.lines) == 0 {
break
}
l := ep.lines[0]
ep.lines = ep.lines[1:]
if f(l) {
ep.mu.Unlock()
return l, nil
}
}
ep.mu.Unlock()
ret... | [
"func",
"(",
"ep",
"*",
"ExpectProcess",
")",
"ExpectFunc",
"(",
"f",
"func",
"(",
"string",
")",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"ep",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"for",
"{",
"for",
"len",
"(",
"ep",
".",
"lines... | // ExpectFunc returns the first line satisfying the function f. | [
"ExpectFunc",
"returns",
"the",
"first",
"line",
"satisfying",
"the",
"function",
"f",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/expect/expect.go#L97-L115 | test |
etcd-io/etcd | pkg/expect/expect.go | Expect | func (ep *ExpectProcess) Expect(s string) (string, error) {
return ep.ExpectFunc(func(txt string) bool { return strings.Contains(txt, s) })
} | go | func (ep *ExpectProcess) Expect(s string) (string, error) {
return ep.ExpectFunc(func(txt string) bool { return strings.Contains(txt, s) })
} | [
"func",
"(",
"ep",
"*",
"ExpectProcess",
")",
"Expect",
"(",
"s",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"ep",
".",
"ExpectFunc",
"(",
"func",
"(",
"txt",
"string",
")",
"bool",
"{",
"return",
"strings",
".",
"Contains",
"(",... | // Expect returns the first line containing the given string. | [
"Expect",
"returns",
"the",
"first",
"line",
"containing",
"the",
"given",
"string",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/expect/expect.go#L118-L120 | test |
etcd-io/etcd | pkg/expect/expect.go | LineCount | func (ep *ExpectProcess) LineCount() int {
ep.mu.Lock()
defer ep.mu.Unlock()
return ep.count
} | go | func (ep *ExpectProcess) LineCount() int {
ep.mu.Lock()
defer ep.mu.Unlock()
return ep.count
} | [
"func",
"(",
"ep",
"*",
"ExpectProcess",
")",
"LineCount",
"(",
")",
"int",
"{",
"ep",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ep",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"ep",
".",
"count",
"\n",
"}"
] | // LineCount returns the number of recorded lines since
// the beginning of the process. | [
"LineCount",
"returns",
"the",
"number",
"of",
"recorded",
"lines",
"since",
"the",
"beginning",
"of",
"the",
"process",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/expect/expect.go#L124-L128 | test |
etcd-io/etcd | pkg/expect/expect.go | Signal | func (ep *ExpectProcess) Signal(sig os.Signal) error {
return ep.cmd.Process.Signal(sig)
} | go | func (ep *ExpectProcess) Signal(sig os.Signal) error {
return ep.cmd.Process.Signal(sig)
} | [
"func",
"(",
"ep",
"*",
"ExpectProcess",
")",
"Signal",
"(",
"sig",
"os",
".",
"Signal",
")",
"error",
"{",
"return",
"ep",
".",
"cmd",
".",
"Process",
".",
"Signal",
"(",
"sig",
")",
"\n",
"}"
] | // Signal sends a signal to the expect process | [
"Signal",
"sends",
"a",
"signal",
"to",
"the",
"expect",
"process"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/expect/expect.go#L134-L136 | test |
etcd-io/etcd | proxy/grpcproxy/cache/store.go | keyFunc | func keyFunc(req *pb.RangeRequest) string {
// TODO: use marshalTo to reduce allocation
b, err := req.Marshal()
if err != nil {
panic(err)
}
return string(b)
} | go | func keyFunc(req *pb.RangeRequest) string {
// TODO: use marshalTo to reduce allocation
b, err := req.Marshal()
if err != nil {
panic(err)
}
return string(b)
} | [
"func",
"keyFunc",
"(",
"req",
"*",
"pb",
".",
"RangeRequest",
")",
"string",
"{",
"b",
",",
"err",
":=",
"req",
".",
"Marshal",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
... | // keyFunc returns the key of a request, which is used to look up its caching response in the cache. | [
"keyFunc",
"returns",
"the",
"key",
"of",
"a",
"request",
"which",
"is",
"used",
"to",
"look",
"up",
"its",
"caching",
"response",
"in",
"the",
"cache",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cache/store.go#L44-L51 | test |
etcd-io/etcd | proxy/grpcproxy/cache/store.go | Add | func (c *cache) Add(req *pb.RangeRequest, resp *pb.RangeResponse) {
key := keyFunc(req)
c.mu.Lock()
defer c.mu.Unlock()
if req.Revision > c.compactedRev {
c.lru.Add(key, resp)
}
// we do not need to invalidate a request with a revision specified.
// so we do not need to add it into the reverse index.
if req... | go | func (c *cache) Add(req *pb.RangeRequest, resp *pb.RangeResponse) {
key := keyFunc(req)
c.mu.Lock()
defer c.mu.Unlock()
if req.Revision > c.compactedRev {
c.lru.Add(key, resp)
}
// we do not need to invalidate a request with a revision specified.
// so we do not need to add it into the reverse index.
if req... | [
"func",
"(",
"c",
"*",
"cache",
")",
"Add",
"(",
"req",
"*",
"pb",
".",
"RangeRequest",
",",
"resp",
"*",
"pb",
".",
"RangeResponse",
")",
"{",
"key",
":=",
"keyFunc",
"(",
"req",
")",
"\n",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",... | // Add adds the response of a request to the cache if its revision is larger than the compacted revision of the cache. | [
"Add",
"adds",
"the",
"response",
"of",
"a",
"request",
"to",
"the",
"cache",
"if",
"its",
"revision",
"is",
"larger",
"than",
"the",
"compacted",
"revision",
"of",
"the",
"cache",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cache/store.go#L74-L109 | test |
etcd-io/etcd | proxy/grpcproxy/cache/store.go | Get | func (c *cache) Get(req *pb.RangeRequest) (*pb.RangeResponse, error) {
key := keyFunc(req)
c.mu.Lock()
defer c.mu.Unlock()
if req.Revision > 0 && req.Revision < c.compactedRev {
c.lru.Remove(key)
return nil, ErrCompacted
}
if resp, ok := c.lru.Get(key); ok {
return resp.(*pb.RangeResponse), nil
}
retur... | go | func (c *cache) Get(req *pb.RangeRequest) (*pb.RangeResponse, error) {
key := keyFunc(req)
c.mu.Lock()
defer c.mu.Unlock()
if req.Revision > 0 && req.Revision < c.compactedRev {
c.lru.Remove(key)
return nil, ErrCompacted
}
if resp, ok := c.lru.Get(key); ok {
return resp.(*pb.RangeResponse), nil
}
retur... | [
"func",
"(",
"c",
"*",
"cache",
")",
"Get",
"(",
"req",
"*",
"pb",
".",
"RangeRequest",
")",
"(",
"*",
"pb",
".",
"RangeResponse",
",",
"error",
")",
"{",
"key",
":=",
"keyFunc",
"(",
"req",
")",
"\n",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"... | // Get looks up the caching response for a given request.
// Get is also responsible for lazy eviction when accessing compacted entries. | [
"Get",
"looks",
"up",
"the",
"caching",
"response",
"for",
"a",
"given",
"request",
".",
"Get",
"is",
"also",
"responsible",
"for",
"lazy",
"eviction",
"when",
"accessing",
"compacted",
"entries",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cache/store.go#L113-L128 | test |
etcd-io/etcd | proxy/grpcproxy/cache/store.go | Invalidate | func (c *cache) Invalidate(key, endkey []byte) {
c.mu.Lock()
defer c.mu.Unlock()
var (
ivs []*adt.IntervalValue
ivl adt.Interval
)
if len(endkey) == 0 {
ivl = adt.NewStringAffinePoint(string(key))
} else {
ivl = adt.NewStringAffineInterval(string(key), string(endkey))
}
ivs = c.cachedRanges.Stab(ivl)
... | go | func (c *cache) Invalidate(key, endkey []byte) {
c.mu.Lock()
defer c.mu.Unlock()
var (
ivs []*adt.IntervalValue
ivl adt.Interval
)
if len(endkey) == 0 {
ivl = adt.NewStringAffinePoint(string(key))
} else {
ivl = adt.NewStringAffineInterval(string(key), string(endkey))
}
ivs = c.cachedRanges.Stab(ivl)
... | [
"func",
"(",
"c",
"*",
"cache",
")",
"Invalidate",
"(",
"key",
",",
"endkey",
"[",
"]",
"byte",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"var",
"(",
"ivs",
"[",
"]",
"*",... | // Invalidate invalidates the cache entries that intersecting with the given range from key to endkey. | [
"Invalidate",
"invalidates",
"the",
"cache",
"entries",
"that",
"intersecting",
"with",
"the",
"given",
"range",
"from",
"key",
"to",
"endkey",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cache/store.go#L131-L154 | test |
etcd-io/etcd | proxy/grpcproxy/cache/store.go | Compact | func (c *cache) Compact(revision int64) {
c.mu.Lock()
defer c.mu.Unlock()
if revision > c.compactedRev {
c.compactedRev = revision
}
} | go | func (c *cache) Compact(revision int64) {
c.mu.Lock()
defer c.mu.Unlock()
if revision > c.compactedRev {
c.compactedRev = revision
}
} | [
"func",
"(",
"c",
"*",
"cache",
")",
"Compact",
"(",
"revision",
"int64",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"revision",
">",
"c",
".",
"compactedRev",
"{",
"c",
... | // Compact invalidate all caching response before the given rev.
// Replace with the invalidation is lazy. The actual removal happens when the entries is accessed. | [
"Compact",
"invalidate",
"all",
"caching",
"response",
"before",
"the",
"given",
"rev",
".",
"Replace",
"with",
"the",
"invalidation",
"is",
"lazy",
".",
"The",
"actual",
"removal",
"happens",
"when",
"the",
"entries",
"is",
"accessed",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cache/store.go#L158-L165 | test |
etcd-io/etcd | pkg/flags/unique_urls.go | NewUniqueURLsWithExceptions | func NewUniqueURLsWithExceptions(s string, exceptions ...string) *UniqueURLs {
us := &UniqueURLs{Values: make(map[string]struct{}), Allowed: make(map[string]struct{})}
for _, v := range exceptions {
us.Allowed[v] = struct{}{}
}
if s == "" {
return us
}
if err := us.Set(s); err != nil {
plog.Panicf("new Uniq... | go | func NewUniqueURLsWithExceptions(s string, exceptions ...string) *UniqueURLs {
us := &UniqueURLs{Values: make(map[string]struct{}), Allowed: make(map[string]struct{})}
for _, v := range exceptions {
us.Allowed[v] = struct{}{}
}
if s == "" {
return us
}
if err := us.Set(s); err != nil {
plog.Panicf("new Uniq... | [
"func",
"NewUniqueURLsWithExceptions",
"(",
"s",
"string",
",",
"exceptions",
"...",
"string",
")",
"*",
"UniqueURLs",
"{",
"us",
":=",
"&",
"UniqueURLs",
"{",
"Values",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
",",
"Allowed"... | // NewUniqueURLsWithExceptions implements "url.URL" slice as flag.Value interface.
// Given value is to be separated by comma. | [
"NewUniqueURLsWithExceptions",
"implements",
"url",
".",
"URL",
"slice",
"as",
"flag",
".",
"Value",
"interface",
".",
"Given",
"value",
"is",
"to",
"be",
"separated",
"by",
"comma",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/unique_urls.go#L70-L82 | test |
etcd-io/etcd | pkg/flags/unique_urls.go | UniqueURLsFromFlag | func UniqueURLsFromFlag(fs *flag.FlagSet, urlsFlagName string) []url.URL {
return (*fs.Lookup(urlsFlagName).Value.(*UniqueURLs)).uss
} | go | func UniqueURLsFromFlag(fs *flag.FlagSet, urlsFlagName string) []url.URL {
return (*fs.Lookup(urlsFlagName).Value.(*UniqueURLs)).uss
} | [
"func",
"UniqueURLsFromFlag",
"(",
"fs",
"*",
"flag",
".",
"FlagSet",
",",
"urlsFlagName",
"string",
")",
"[",
"]",
"url",
".",
"URL",
"{",
"return",
"(",
"*",
"fs",
".",
"Lookup",
"(",
"urlsFlagName",
")",
".",
"Value",
".",
"(",
"*",
"UniqueURLs",
... | // UniqueURLsFromFlag returns a slice from urls got from the flag. | [
"UniqueURLsFromFlag",
"returns",
"a",
"slice",
"from",
"urls",
"got",
"from",
"the",
"flag",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/unique_urls.go#L85-L87 | test |
etcd-io/etcd | pkg/flags/unique_urls.go | UniqueURLsMapFromFlag | func UniqueURLsMapFromFlag(fs *flag.FlagSet, urlsFlagName string) map[string]struct{} {
return (*fs.Lookup(urlsFlagName).Value.(*UniqueURLs)).Values
} | go | func UniqueURLsMapFromFlag(fs *flag.FlagSet, urlsFlagName string) map[string]struct{} {
return (*fs.Lookup(urlsFlagName).Value.(*UniqueURLs)).Values
} | [
"func",
"UniqueURLsMapFromFlag",
"(",
"fs",
"*",
"flag",
".",
"FlagSet",
",",
"urlsFlagName",
"string",
")",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"return",
"(",
"*",
"fs",
".",
"Lookup",
"(",
"urlsFlagName",
")",
".",
"Value",
".",
"(",
... | // UniqueURLsMapFromFlag returns a map from url strings got from the flag. | [
"UniqueURLsMapFromFlag",
"returns",
"a",
"map",
"from",
"url",
"strings",
"got",
"from",
"the",
"flag",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/unique_urls.go#L90-L92 | test |
etcd-io/etcd | contrib/recipes/barrier.go | Hold | func (b *Barrier) Hold() error {
_, err := newKey(b.client, b.key, v3.NoLease)
return err
} | go | func (b *Barrier) Hold() error {
_, err := newKey(b.client, b.key, v3.NoLease)
return err
} | [
"func",
"(",
"b",
"*",
"Barrier",
")",
"Hold",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"newKey",
"(",
"b",
".",
"client",
",",
"b",
".",
"key",
",",
"v3",
".",
"NoLease",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Hold creates the barrier key causing processes to block on Wait. | [
"Hold",
"creates",
"the",
"barrier",
"key",
"causing",
"processes",
"to",
"block",
"on",
"Wait",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/barrier.go#L38-L41 | test |
etcd-io/etcd | contrib/recipes/barrier.go | Release | func (b *Barrier) Release() error {
_, err := b.client.Delete(b.ctx, b.key)
return err
} | go | func (b *Barrier) Release() error {
_, err := b.client.Delete(b.ctx, b.key)
return err
} | [
"func",
"(",
"b",
"*",
"Barrier",
")",
"Release",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"b",
".",
"client",
".",
"Delete",
"(",
"b",
".",
"ctx",
",",
"b",
".",
"key",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Release deletes the barrier key to unblock all waiting processes. | [
"Release",
"deletes",
"the",
"barrier",
"key",
"to",
"unblock",
"all",
"waiting",
"processes",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/barrier.go#L44-L47 | test |
etcd-io/etcd | contrib/recipes/barrier.go | Wait | func (b *Barrier) Wait() error {
resp, err := b.client.Get(b.ctx, b.key, v3.WithFirstKey()...)
if err != nil {
return err
}
if len(resp.Kvs) == 0 {
// key already removed
return nil
}
_, err = WaitEvents(
b.client,
b.key,
resp.Header.Revision,
[]mvccpb.Event_EventType{mvccpb.PUT, mvccpb.DELETE})
re... | go | func (b *Barrier) Wait() error {
resp, err := b.client.Get(b.ctx, b.key, v3.WithFirstKey()...)
if err != nil {
return err
}
if len(resp.Kvs) == 0 {
// key already removed
return nil
}
_, err = WaitEvents(
b.client,
b.key,
resp.Header.Revision,
[]mvccpb.Event_EventType{mvccpb.PUT, mvccpb.DELETE})
re... | [
"func",
"(",
"b",
"*",
"Barrier",
")",
"Wait",
"(",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"b",
".",
"client",
".",
"Get",
"(",
"b",
".",
"ctx",
",",
"b",
".",
"key",
",",
"v3",
".",
"WithFirstKey",
"(",
")",
"...",
")",
"\n",
"if",
"... | // Wait blocks on the barrier key until it is deleted. If there is no key, Wait
// assumes Release has already been called and returns immediately. | [
"Wait",
"blocks",
"on",
"the",
"barrier",
"key",
"until",
"it",
"is",
"deleted",
".",
"If",
"there",
"is",
"no",
"key",
"Wait",
"assumes",
"Release",
"has",
"already",
"been",
"called",
"and",
"returns",
"immediately",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/barrier.go#L51-L66 | test |
etcd-io/etcd | functional/runner/lock_racer_command.go | NewLockRacerCommand | func NewLockRacerCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "lock-racer [name of lock (defaults to 'racers')]",
Short: "Performs lock race operation",
Run: runRacerFunc,
}
cmd.Flags().IntVar(&totalClientConnections, "total-client-connections", 10, "total number of client connections")
return c... | go | func NewLockRacerCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "lock-racer [name of lock (defaults to 'racers')]",
Short: "Performs lock race operation",
Run: runRacerFunc,
}
cmd.Flags().IntVar(&totalClientConnections, "total-client-connections", 10, "total number of client connections")
return c... | [
"func",
"NewLockRacerCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"lock-racer [name of lock (defaults to 'racers')]\"",
",",
"Short",
":",
"\"Performs lock race operation\"",
",",
"Run",
":",
... | // NewLockRacerCommand returns the cobra command for "lock-racer runner". | [
"NewLockRacerCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lock",
"-",
"racer",
"runner",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/runner/lock_racer_command.go#L29-L37 | test |
etcd-io/etcd | functional/rpcpb/member.go | ElectionTimeout | func (m *Member) ElectionTimeout() time.Duration {
return time.Duration(m.Etcd.ElectionTimeoutMs) * time.Millisecond
} | go | func (m *Member) ElectionTimeout() time.Duration {
return time.Duration(m.Etcd.ElectionTimeoutMs) * time.Millisecond
} | [
"func",
"(",
"m",
"*",
"Member",
")",
"ElectionTimeout",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"m",
".",
"Etcd",
".",
"ElectionTimeoutMs",
")",
"*",
"time",
".",
"Millisecond",
"\n",
"}"
] | // ElectionTimeout returns an election timeout duration. | [
"ElectionTimeout",
"returns",
"an",
"election",
"timeout",
"duration",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/rpcpb/member.go#L37-L39 | test |
etcd-io/etcd | functional/rpcpb/member.go | DialEtcdGRPCServer | func (m *Member) DialEtcdGRPCServer(opts ...grpc.DialOption) (*grpc.ClientConn, error) {
dialOpts := []grpc.DialOption{
grpc.WithTimeout(5 * time.Second),
grpc.WithBlock(),
}
secure := false
for _, cu := range m.Etcd.AdvertiseClientURLs {
u, err := url.Parse(cu)
if err != nil {
return nil, err
}
if ... | go | func (m *Member) DialEtcdGRPCServer(opts ...grpc.DialOption) (*grpc.ClientConn, error) {
dialOpts := []grpc.DialOption{
grpc.WithTimeout(5 * time.Second),
grpc.WithBlock(),
}
secure := false
for _, cu := range m.Etcd.AdvertiseClientURLs {
u, err := url.Parse(cu)
if err != nil {
return nil, err
}
if ... | [
"func",
"(",
"m",
"*",
"Member",
")",
"DialEtcdGRPCServer",
"(",
"opts",
"...",
"grpc",
".",
"DialOption",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"dialOpts",
":=",
"[",
"]",
"grpc",
".",
"DialOption",
"{",
"grpc",
".",
"Wit... | // DialEtcdGRPCServer creates a raw gRPC connection to an etcd member. | [
"DialEtcdGRPCServer",
"creates",
"a",
"raw",
"gRPC",
"connection",
"to",
"an",
"etcd",
"member",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/rpcpb/member.go#L42-L81 | test |
etcd-io/etcd | functional/rpcpb/member.go | CreateEtcdClientConfig | func (m *Member) CreateEtcdClientConfig(opts ...grpc.DialOption) (cfg *clientv3.Config, err error) {
secure := false
for _, cu := range m.Etcd.AdvertiseClientURLs {
var u *url.URL
u, err = url.Parse(cu)
if err != nil {
return nil, err
}
if u.Scheme == "https" { // TODO: handle unix
secure = true
}
... | go | func (m *Member) CreateEtcdClientConfig(opts ...grpc.DialOption) (cfg *clientv3.Config, err error) {
secure := false
for _, cu := range m.Etcd.AdvertiseClientURLs {
var u *url.URL
u, err = url.Parse(cu)
if err != nil {
return nil, err
}
if u.Scheme == "https" { // TODO: handle unix
secure = true
}
... | [
"func",
"(",
"m",
"*",
"Member",
")",
"CreateEtcdClientConfig",
"(",
"opts",
"...",
"grpc",
".",
"DialOption",
")",
"(",
"cfg",
"*",
"clientv3",
".",
"Config",
",",
"err",
"error",
")",
"{",
"secure",
":=",
"false",
"\n",
"for",
"_",
",",
"cu",
":=",... | // CreateEtcdClientConfig creates a client configuration from member. | [
"CreateEtcdClientConfig",
"creates",
"a",
"client",
"configuration",
"from",
"member",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/rpcpb/member.go#L84-L121 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.