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 | pkg/adt/interval_tree.go | replaceParent | func (ivt *IntervalTree) replaceParent(x *intervalNode, y *intervalNode) {
y.parent = x.parent
if x.parent == nil {
ivt.root = y
} else {
if x == x.parent.left {
x.parent.left = y
} else {
x.parent.right = y
}
x.parent.updateMax()
}
x.parent = y
} | go | func (ivt *IntervalTree) replaceParent(x *intervalNode, y *intervalNode) {
y.parent = x.parent
if x.parent == nil {
ivt.root = y
} else {
if x == x.parent.left {
x.parent.left = y
} else {
x.parent.right = y
}
x.parent.updateMax()
}
x.parent = y
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"replaceParent",
"(",
"x",
"*",
"intervalNode",
",",
"y",
"*",
"intervalNode",
")",
"{",
"y",
".",
"parent",
"=",
"x",
".",
"parent",
"\n",
"if",
"x",
".",
"parent",
"==",
"nil",
"{",
"ivt",
".",
"root"... | // replaceParent replaces x's parent with y | [
"replaceParent",
"replaces",
"x",
"s",
"parent",
"with",
"y"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L384-L397 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | MaxHeight | func (ivt *IntervalTree) MaxHeight() int {
return int((2 * math.Log2(float64(ivt.Len()+1))) + 0.5)
} | go | func (ivt *IntervalTree) MaxHeight() int {
return int((2 * math.Log2(float64(ivt.Len()+1))) + 0.5)
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"MaxHeight",
"(",
")",
"int",
"{",
"return",
"int",
"(",
"(",
"2",
"*",
"math",
".",
"Log2",
"(",
"float64",
"(",
"ivt",
".",
"Len",
"(",
")",
"+",
"1",
")",
")",
")",
"+",
"0.5",
")",
"\n",
"}"
] | // MaxHeight is the expected maximum tree height given the number of nodes | [
"MaxHeight",
"is",
"the",
"expected",
"maximum",
"tree",
"height",
"given",
"the",
"number",
"of",
"nodes"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L406-L408 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Visit | func (ivt *IntervalTree) Visit(ivl Interval, ivv IntervalVisitor) {
ivt.root.visit(&ivl, func(n *intervalNode) bool { return ivv(&n.iv) })
} | go | func (ivt *IntervalTree) Visit(ivl Interval, ivv IntervalVisitor) {
ivt.root.visit(&ivl, func(n *intervalNode) bool { return ivv(&n.iv) })
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Visit",
"(",
"ivl",
"Interval",
",",
"ivv",
"IntervalVisitor",
")",
"{",
"ivt",
".",
"root",
".",
"visit",
"(",
"&",
"ivl",
",",
"func",
"(",
"n",
"*",
"intervalNode",
")",
"bool",
"{",
"return",
"ivv",
... | // Visit calls a visitor function on every tree node intersecting the given interval.
// It will visit each interval [x, y) in ascending order sorted on x. | [
"Visit",
"calls",
"a",
"visitor",
"function",
"on",
"every",
"tree",
"node",
"intersecting",
"the",
"given",
"interval",
".",
"It",
"will",
"visit",
"each",
"interval",
"[",
"x",
"y",
")",
"in",
"ascending",
"order",
"sorted",
"on",
"x",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L415-L417 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | find | func (ivt *IntervalTree) find(ivl Interval) (ret *intervalNode) {
f := func(n *intervalNode) bool {
if n.iv.Ivl != ivl {
return true
}
ret = n
return false
}
ivt.root.visit(&ivl, f)
return ret
} | go | func (ivt *IntervalTree) find(ivl Interval) (ret *intervalNode) {
f := func(n *intervalNode) bool {
if n.iv.Ivl != ivl {
return true
}
ret = n
return false
}
ivt.root.visit(&ivl, f)
return ret
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"find",
"(",
"ivl",
"Interval",
")",
"(",
"ret",
"*",
"intervalNode",
")",
"{",
"f",
":=",
"func",
"(",
"n",
"*",
"intervalNode",
")",
"bool",
"{",
"if",
"n",
".",
"iv",
".",
"Ivl",
"!=",
"ivl",
"{",
... | // find the exact node for a given interval | [
"find",
"the",
"exact",
"node",
"for",
"a",
"given",
"interval"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L420-L430 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Find | func (ivt *IntervalTree) Find(ivl Interval) (ret *IntervalValue) {
n := ivt.find(ivl)
if n == nil {
return nil
}
return &n.iv
} | go | func (ivt *IntervalTree) Find(ivl Interval) (ret *IntervalValue) {
n := ivt.find(ivl)
if n == nil {
return nil
}
return &n.iv
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Find",
"(",
"ivl",
"Interval",
")",
"(",
"ret",
"*",
"IntervalValue",
")",
"{",
"n",
":=",
"ivt",
".",
"find",
"(",
"ivl",
")",
"\n",
"if",
"n",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
... | // Find gets the IntervalValue for the node matching the given interval | [
"Find",
"gets",
"the",
"IntervalValue",
"for",
"the",
"node",
"matching",
"the",
"given",
"interval"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L433-L439 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Intersects | func (ivt *IntervalTree) Intersects(iv Interval) bool {
x := ivt.root
for x != nil && iv.Compare(&x.iv.Ivl) != 0 {
if x.left != nil && x.left.max.Compare(iv.Begin) > 0 {
x = x.left
} else {
x = x.right
}
}
return x != nil
} | go | func (ivt *IntervalTree) Intersects(iv Interval) bool {
x := ivt.root
for x != nil && iv.Compare(&x.iv.Ivl) != 0 {
if x.left != nil && x.left.max.Compare(iv.Begin) > 0 {
x = x.left
} else {
x = x.right
}
}
return x != nil
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Intersects",
"(",
"iv",
"Interval",
")",
"bool",
"{",
"x",
":=",
"ivt",
".",
"root",
"\n",
"for",
"x",
"!=",
"nil",
"&&",
"iv",
".",
"Compare",
"(",
"&",
"x",
".",
"iv",
".",
"Ivl",
")",
"!=",
"0",... | // Intersects returns true if there is some tree node intersecting the given interval. | [
"Intersects",
"returns",
"true",
"if",
"there",
"is",
"some",
"tree",
"node",
"intersecting",
"the",
"given",
"interval",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L442-L452 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Contains | func (ivt *IntervalTree) Contains(ivl Interval) bool {
var maxEnd, minBegin Comparable
isContiguous := true
ivt.Visit(ivl, func(n *IntervalValue) bool {
if minBegin == nil {
minBegin = n.Ivl.Begin
maxEnd = n.Ivl.End
return true
}
if maxEnd.Compare(n.Ivl.Begin) < 0 {
isContiguous = false
return ... | go | func (ivt *IntervalTree) Contains(ivl Interval) bool {
var maxEnd, minBegin Comparable
isContiguous := true
ivt.Visit(ivl, func(n *IntervalValue) bool {
if minBegin == nil {
minBegin = n.Ivl.Begin
maxEnd = n.Ivl.End
return true
}
if maxEnd.Compare(n.Ivl.Begin) < 0 {
isContiguous = false
return ... | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Contains",
"(",
"ivl",
"Interval",
")",
"bool",
"{",
"var",
"maxEnd",
",",
"minBegin",
"Comparable",
"\n",
"isContiguous",
":=",
"true",
"\n",
"ivt",
".",
"Visit",
"(",
"ivl",
",",
"func",
"(",
"n",
"*",
... | // Contains returns true if the interval tree's keys cover the entire given interval. | [
"Contains",
"returns",
"true",
"if",
"the",
"interval",
"tree",
"s",
"keys",
"cover",
"the",
"entire",
"given",
"interval",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L455-L476 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Stab | func (ivt *IntervalTree) Stab(iv Interval) (ivs []*IntervalValue) {
if ivt.count == 0 {
return nil
}
f := func(n *IntervalValue) bool { ivs = append(ivs, n); return true }
ivt.Visit(iv, f)
return ivs
} | go | func (ivt *IntervalTree) Stab(iv Interval) (ivs []*IntervalValue) {
if ivt.count == 0 {
return nil
}
f := func(n *IntervalValue) bool { ivs = append(ivs, n); return true }
ivt.Visit(iv, f)
return ivs
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Stab",
"(",
"iv",
"Interval",
")",
"(",
"ivs",
"[",
"]",
"*",
"IntervalValue",
")",
"{",
"if",
"ivt",
".",
"count",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"f",
":=",
"func",
"(",
"n",
"*... | // Stab returns a slice with all elements in the tree intersecting the interval. | [
"Stab",
"returns",
"a",
"slice",
"with",
"all",
"elements",
"in",
"the",
"tree",
"intersecting",
"the",
"interval",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L479-L486 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Union | func (ivt *IntervalTree) Union(inIvt IntervalTree, ivl Interval) {
f := func(n *IntervalValue) bool {
ivt.Insert(n.Ivl, n.Val)
return true
}
inIvt.Visit(ivl, f)
} | go | func (ivt *IntervalTree) Union(inIvt IntervalTree, ivl Interval) {
f := func(n *IntervalValue) bool {
ivt.Insert(n.Ivl, n.Val)
return true
}
inIvt.Visit(ivl, f)
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Union",
"(",
"inIvt",
"IntervalTree",
",",
"ivl",
"Interval",
")",
"{",
"f",
":=",
"func",
"(",
"n",
"*",
"IntervalValue",
")",
"bool",
"{",
"ivt",
".",
"Insert",
"(",
"n",
".",
"Ivl",
",",
"n",
".",
... | // Union merges a given interval tree into the receiver. | [
"Union",
"merges",
"a",
"given",
"interval",
"tree",
"into",
"the",
"receiver",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L489-L495 | test |
etcd-io/etcd | pkg/ioutil/readcloser.go | NewExactReadCloser | func NewExactReadCloser(rc io.ReadCloser, totalBytes int64) io.ReadCloser {
return &exactReadCloser{rc: rc, totalBytes: totalBytes}
} | go | func NewExactReadCloser(rc io.ReadCloser, totalBytes int64) io.ReadCloser {
return &exactReadCloser{rc: rc, totalBytes: totalBytes}
} | [
"func",
"NewExactReadCloser",
"(",
"rc",
"io",
".",
"ReadCloser",
",",
"totalBytes",
"int64",
")",
"io",
".",
"ReadCloser",
"{",
"return",
"&",
"exactReadCloser",
"{",
"rc",
":",
"rc",
",",
"totalBytes",
":",
"totalBytes",
"}",
"\n",
"}"
] | // NewExactReadCloser returns a ReadCloser that returns errors if the underlying
// reader does not read back exactly the requested number of bytes. | [
"NewExactReadCloser",
"returns",
"a",
"ReadCloser",
"that",
"returns",
"errors",
"if",
"the",
"underlying",
"reader",
"does",
"not",
"read",
"back",
"exactly",
"the",
"requested",
"number",
"of",
"bytes",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/ioutil/readcloser.go#L36-L38 | test |
etcd-io/etcd | clientv3/concurrency/election.go | NewElection | func NewElection(s *Session, pfx string) *Election {
return &Election{session: s, keyPrefix: pfx + "/"}
} | go | func NewElection(s *Session, pfx string) *Election {
return &Election{session: s, keyPrefix: pfx + "/"}
} | [
"func",
"NewElection",
"(",
"s",
"*",
"Session",
",",
"pfx",
"string",
")",
"*",
"Election",
"{",
"return",
"&",
"Election",
"{",
"session",
":",
"s",
",",
"keyPrefix",
":",
"pfx",
"+",
"\"/\"",
"}",
"\n",
"}"
] | // NewElection returns a new election on a given key prefix. | [
"NewElection",
"returns",
"a",
"new",
"election",
"on",
"a",
"given",
"key",
"prefix",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/election.go#L44-L46 | test |
etcd-io/etcd | clientv3/concurrency/election.go | ResumeElection | func ResumeElection(s *Session, pfx string, leaderKey string, leaderRev int64) *Election {
return &Election{
keyPrefix: pfx,
session: s,
leaderKey: leaderKey,
leaderRev: leaderRev,
leaderSession: s,
}
} | go | func ResumeElection(s *Session, pfx string, leaderKey string, leaderRev int64) *Election {
return &Election{
keyPrefix: pfx,
session: s,
leaderKey: leaderKey,
leaderRev: leaderRev,
leaderSession: s,
}
} | [
"func",
"ResumeElection",
"(",
"s",
"*",
"Session",
",",
"pfx",
"string",
",",
"leaderKey",
"string",
",",
"leaderRev",
"int64",
")",
"*",
"Election",
"{",
"return",
"&",
"Election",
"{",
"keyPrefix",
":",
"pfx",
",",
"session",
":",
"s",
",",
"leaderKey... | // ResumeElection initializes an election with a known leader. | [
"ResumeElection",
"initializes",
"an",
"election",
"with",
"a",
"known",
"leader",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/election.go#L49-L57 | test |
etcd-io/etcd | clientv3/concurrency/election.go | Proclaim | func (e *Election) Proclaim(ctx context.Context, val string) error {
if e.leaderSession == nil {
return ErrElectionNotLeader
}
client := e.session.Client()
cmp := v3.Compare(v3.CreateRevision(e.leaderKey), "=", e.leaderRev)
txn := client.Txn(ctx).If(cmp)
txn = txn.Then(v3.OpPut(e.leaderKey, val, v3.WithLease(e.... | go | func (e *Election) Proclaim(ctx context.Context, val string) error {
if e.leaderSession == nil {
return ErrElectionNotLeader
}
client := e.session.Client()
cmp := v3.Compare(v3.CreateRevision(e.leaderKey), "=", e.leaderRev)
txn := client.Txn(ctx).If(cmp)
txn = txn.Then(v3.OpPut(e.leaderKey, val, v3.WithLease(e.... | [
"func",
"(",
"e",
"*",
"Election",
")",
"Proclaim",
"(",
"ctx",
"context",
".",
"Context",
",",
"val",
"string",
")",
"error",
"{",
"if",
"e",
".",
"leaderSession",
"==",
"nil",
"{",
"return",
"ErrElectionNotLeader",
"\n",
"}",
"\n",
"client",
":=",
"e... | // Proclaim lets the leader announce a new value without another election. | [
"Proclaim",
"lets",
"the",
"leader",
"announce",
"a",
"new",
"value",
"without",
"another",
"election",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/election.go#L110-L129 | test |
etcd-io/etcd | clientv3/concurrency/election.go | Resign | func (e *Election) Resign(ctx context.Context) (err error) {
if e.leaderSession == nil {
return nil
}
client := e.session.Client()
cmp := v3.Compare(v3.CreateRevision(e.leaderKey), "=", e.leaderRev)
resp, err := client.Txn(ctx).If(cmp).Then(v3.OpDelete(e.leaderKey)).Commit()
if err == nil {
e.hdr = resp.Heade... | go | func (e *Election) Resign(ctx context.Context) (err error) {
if e.leaderSession == nil {
return nil
}
client := e.session.Client()
cmp := v3.Compare(v3.CreateRevision(e.leaderKey), "=", e.leaderRev)
resp, err := client.Txn(ctx).If(cmp).Then(v3.OpDelete(e.leaderKey)).Commit()
if err == nil {
e.hdr = resp.Heade... | [
"func",
"(",
"e",
"*",
"Election",
")",
"Resign",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"if",
"e",
".",
"leaderSession",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"client",
":=",
"e",
".",
"session",
... | // Resign lets a leader start a new election. | [
"Resign",
"lets",
"a",
"leader",
"start",
"a",
"new",
"election",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/election.go#L132-L145 | test |
etcd-io/etcd | clientv3/concurrency/election.go | Leader | func (e *Election) Leader(ctx context.Context) (*v3.GetResponse, error) {
client := e.session.Client()
resp, err := client.Get(ctx, e.keyPrefix, v3.WithFirstCreate()...)
if err != nil {
return nil, err
} else if len(resp.Kvs) == 0 {
// no leader currently elected
return nil, ErrElectionNoLeader
}
return res... | go | func (e *Election) Leader(ctx context.Context) (*v3.GetResponse, error) {
client := e.session.Client()
resp, err := client.Get(ctx, e.keyPrefix, v3.WithFirstCreate()...)
if err != nil {
return nil, err
} else if len(resp.Kvs) == 0 {
// no leader currently elected
return nil, ErrElectionNoLeader
}
return res... | [
"func",
"(",
"e",
"*",
"Election",
")",
"Leader",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"v3",
".",
"GetResponse",
",",
"error",
")",
"{",
"client",
":=",
"e",
".",
"session",
".",
"Client",
"(",
")",
"\n",
"resp",
",",
"err",
":="... | // Leader returns the leader value for the current election. | [
"Leader",
"returns",
"the",
"leader",
"value",
"for",
"the",
"current",
"election",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/election.go#L148-L158 | test |
etcd-io/etcd | clientv3/concurrency/election.go | Observe | func (e *Election) Observe(ctx context.Context) <-chan v3.GetResponse {
retc := make(chan v3.GetResponse)
go e.observe(ctx, retc)
return retc
} | go | func (e *Election) Observe(ctx context.Context) <-chan v3.GetResponse {
retc := make(chan v3.GetResponse)
go e.observe(ctx, retc)
return retc
} | [
"func",
"(",
"e",
"*",
"Election",
")",
"Observe",
"(",
"ctx",
"context",
".",
"Context",
")",
"<-",
"chan",
"v3",
".",
"GetResponse",
"{",
"retc",
":=",
"make",
"(",
"chan",
"v3",
".",
"GetResponse",
")",
"\n",
"go",
"e",
".",
"observe",
"(",
"ctx... | // Observe returns a channel that reliably observes ordered leader proposals
// as GetResponse values on every current elected leader key. It will not
// necessarily fetch all historical leader updates, but will always post the
// most recent leader value.
//
// The channel closes when the context is canceled or the un... | [
"Observe",
"returns",
"a",
"channel",
"that",
"reliably",
"observes",
"ordered",
"leader",
"proposals",
"as",
"GetResponse",
"values",
"on",
"every",
"current",
"elected",
"leader",
"key",
".",
"It",
"will",
"not",
"necessarily",
"fetch",
"all",
"historical",
"l... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/election.go#L167-L171 | test |
etcd-io/etcd | etcdserver/api/v3rpc/quota.go | check | func (qa *quotaAlarmer) check(ctx context.Context, r interface{}) error {
if qa.q.Available(r) {
return nil
}
req := &pb.AlarmRequest{
MemberID: uint64(qa.id),
Action: pb.AlarmRequest_ACTIVATE,
Alarm: pb.AlarmType_NOSPACE,
}
qa.a.Alarm(ctx, req)
return rpctypes.ErrGRPCNoSpace
} | go | func (qa *quotaAlarmer) check(ctx context.Context, r interface{}) error {
if qa.q.Available(r) {
return nil
}
req := &pb.AlarmRequest{
MemberID: uint64(qa.id),
Action: pb.AlarmRequest_ACTIVATE,
Alarm: pb.AlarmType_NOSPACE,
}
qa.a.Alarm(ctx, req)
return rpctypes.ErrGRPCNoSpace
} | [
"func",
"(",
"qa",
"*",
"quotaAlarmer",
")",
"check",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"qa",
".",
"q",
".",
"Available",
"(",
"r",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"req",
... | // check whether request satisfies the quota. If there is not enough space,
// ignore request and raise the free space alarm. | [
"check",
"whether",
"request",
"satisfies",
"the",
"quota",
".",
"If",
"there",
"is",
"not",
"enough",
"space",
"ignore",
"request",
"and",
"raise",
"the",
"free",
"space",
"alarm",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3rpc/quota.go#L39-L50 | test |
etcd-io/etcd | etcdctl/ctlv2/command/exec_watch_command.go | NewExecWatchCommand | func NewExecWatchCommand() cli.Command {
return cli.Command{
Name: "exec-watch",
Usage: "watch a key for changes and exec an executable",
ArgsUsage: "<key> <command> [args...]",
Flags: []cli.Flag{
cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"},
cli.BoolFlag{Name... | go | func NewExecWatchCommand() cli.Command {
return cli.Command{
Name: "exec-watch",
Usage: "watch a key for changes and exec an executable",
ArgsUsage: "<key> <command> [args...]",
Flags: []cli.Flag{
cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"},
cli.BoolFlag{Name... | [
"func",
"NewExecWatchCommand",
"(",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"exec-watch\"",
",",
"Usage",
":",
"\"watch a key for changes and exec an executable\"",
",",
"ArgsUsage",
":",
"\"<key> <command> [args...]\"",
"... | // NewExecWatchCommand returns the CLI command for "exec-watch". | [
"NewExecWatchCommand",
"returns",
"the",
"CLI",
"command",
"for",
"exec",
"-",
"watch",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/exec_watch_command.go#L31-L45 | test |
etcd-io/etcd | etcdctl/ctlv2/command/exec_watch_command.go | execWatchCommandFunc | func execWatchCommandFunc(c *cli.Context, ki client.KeysAPI) {
args := c.Args()
argslen := len(args)
if argslen < 2 {
handleError(c, ExitBadArgs, errors.New("key and command to exec required"))
}
var (
key string
cmdArgs []string
)
foundSep := false
for i := range args {
if args[i] == "--" && i !... | go | func execWatchCommandFunc(c *cli.Context, ki client.KeysAPI) {
args := c.Args()
argslen := len(args)
if argslen < 2 {
handleError(c, ExitBadArgs, errors.New("key and command to exec required"))
}
var (
key string
cmdArgs []string
)
foundSep := false
for i := range args {
if args[i] == "--" && i !... | [
"func",
"execWatchCommandFunc",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"ki",
"client",
".",
"KeysAPI",
")",
"{",
"args",
":=",
"c",
".",
"Args",
"(",
")",
"\n",
"argslen",
":=",
"len",
"(",
"args",
")",
"\n",
"if",
"argslen",
"<",
"2",
"{",
"... | // execWatchCommandFunc executes the "exec-watch" command. | [
"execWatchCommandFunc",
"executes",
"the",
"exec",
"-",
"watch",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/exec_watch_command.go#L48-L121 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | NewListener | func NewListener(u url.URL, tlsinfo *transport.TLSInfo) (net.Listener, error) {
return transport.NewTimeoutListener(u.Host, u.Scheme, tlsinfo, ConnReadTimeout, ConnWriteTimeout)
} | go | func NewListener(u url.URL, tlsinfo *transport.TLSInfo) (net.Listener, error) {
return transport.NewTimeoutListener(u.Host, u.Scheme, tlsinfo, ConnReadTimeout, ConnWriteTimeout)
} | [
"func",
"NewListener",
"(",
"u",
"url",
".",
"URL",
",",
"tlsinfo",
"*",
"transport",
".",
"TLSInfo",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"return",
"transport",
".",
"NewTimeoutListener",
"(",
"u",
".",
"Host",
",",
"u",
".",
"S... | // NewListener returns a listener for raft message transfer between peers.
// It uses timeout listener to identify broken streams promptly. | [
"NewListener",
"returns",
"a",
"listener",
"for",
"raft",
"message",
"transfer",
"between",
"peers",
".",
"It",
"uses",
"timeout",
"listener",
"to",
"identify",
"broken",
"streams",
"promptly",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L40-L42 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | NewRoundTripper | func NewRoundTripper(tlsInfo transport.TLSInfo, dialTimeout time.Duration) (http.RoundTripper, error) {
// It uses timeout transport to pair with remote timeout listeners.
// It sets no read/write timeout, because message in requests may
// take long time to write out before reading out the response.
return transpo... | go | func NewRoundTripper(tlsInfo transport.TLSInfo, dialTimeout time.Duration) (http.RoundTripper, error) {
// It uses timeout transport to pair with remote timeout listeners.
// It sets no read/write timeout, because message in requests may
// take long time to write out before reading out the response.
return transpo... | [
"func",
"NewRoundTripper",
"(",
"tlsInfo",
"transport",
".",
"TLSInfo",
",",
"dialTimeout",
"time",
".",
"Duration",
")",
"(",
"http",
".",
"RoundTripper",
",",
"error",
")",
"{",
"return",
"transport",
".",
"NewTimeoutTransport",
"(",
"tlsInfo",
",",
"dialTim... | // NewRoundTripper returns a roundTripper used to send requests
// to rafthttp listener of remote peers. | [
"NewRoundTripper",
"returns",
"a",
"roundTripper",
"used",
"to",
"send",
"requests",
"to",
"rafthttp",
"listener",
"of",
"remote",
"peers",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L46-L51 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | createPostRequest | func createPostRequest(u url.URL, path string, body io.Reader, ct string, urls types.URLs, from, cid types.ID) *http.Request {
uu := u
uu.Path = path
req, err := http.NewRequest("POST", uu.String(), body)
if err != nil {
plog.Panicf("unexpected new request error (%v)", err)
}
req.Header.Set("Content-Type", ct)
... | go | func createPostRequest(u url.URL, path string, body io.Reader, ct string, urls types.URLs, from, cid types.ID) *http.Request {
uu := u
uu.Path = path
req, err := http.NewRequest("POST", uu.String(), body)
if err != nil {
plog.Panicf("unexpected new request error (%v)", err)
}
req.Header.Set("Content-Type", ct)
... | [
"func",
"createPostRequest",
"(",
"u",
"url",
".",
"URL",
",",
"path",
"string",
",",
"body",
"io",
".",
"Reader",
",",
"ct",
"string",
",",
"urls",
"types",
".",
"URLs",
",",
"from",
",",
"cid",
"types",
".",
"ID",
")",
"*",
"http",
".",
"Request"... | // createPostRequest creates a HTTP POST request that sends raft message. | [
"createPostRequest",
"creates",
"a",
"HTTP",
"POST",
"request",
"that",
"sends",
"raft",
"message",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L63-L78 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | checkPostResponse | func checkPostResponse(resp *http.Response, body []byte, req *http.Request, to types.ID) error {
switch resp.StatusCode {
case http.StatusPreconditionFailed:
switch strings.TrimSuffix(string(body), "\n") {
case errIncompatibleVersion.Error():
plog.Errorf("request sent was ignored by peer %s (server version inc... | go | func checkPostResponse(resp *http.Response, body []byte, req *http.Request, to types.ID) error {
switch resp.StatusCode {
case http.StatusPreconditionFailed:
switch strings.TrimSuffix(string(body), "\n") {
case errIncompatibleVersion.Error():
plog.Errorf("request sent was ignored by peer %s (server version inc... | [
"func",
"checkPostResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"body",
"[",
"]",
"byte",
",",
"req",
"*",
"http",
".",
"Request",
",",
"to",
"types",
".",
"ID",
")",
"error",
"{",
"switch",
"resp",
".",
"StatusCode",
"{",
"case",
"http"... | // checkPostResponse checks the response of the HTTP POST request that sends
// raft message. | [
"checkPostResponse",
"checks",
"the",
"response",
"of",
"the",
"HTTP",
"POST",
"request",
"that",
"sends",
"raft",
"message",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L82-L103 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | serverVersion | func serverVersion(h http.Header) *semver.Version {
verStr := h.Get("X-Server-Version")
// backward compatibility with etcd 2.0
if verStr == "" {
verStr = "2.0.0"
}
return semver.Must(semver.NewVersion(verStr))
} | go | func serverVersion(h http.Header) *semver.Version {
verStr := h.Get("X-Server-Version")
// backward compatibility with etcd 2.0
if verStr == "" {
verStr = "2.0.0"
}
return semver.Must(semver.NewVersion(verStr))
} | [
"func",
"serverVersion",
"(",
"h",
"http",
".",
"Header",
")",
"*",
"semver",
".",
"Version",
"{",
"verStr",
":=",
"h",
".",
"Get",
"(",
"\"X-Server-Version\"",
")",
"\n",
"if",
"verStr",
"==",
"\"\"",
"{",
"verStr",
"=",
"\"2.0.0\"",
"\n",
"}",
"\n",
... | // serverVersion returns the server version from the given header. | [
"serverVersion",
"returns",
"the",
"server",
"version",
"from",
"the",
"given",
"header",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L134-L141 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | checkVersionCompatibility | func checkVersionCompatibility(name string, server, minCluster *semver.Version) (
localServer *semver.Version,
localMinCluster *semver.Version,
err error) {
localServer = semver.Must(semver.NewVersion(version.Version))
localMinCluster = semver.Must(semver.NewVersion(version.MinClusterVersion))
if compareMajorMino... | go | func checkVersionCompatibility(name string, server, minCluster *semver.Version) (
localServer *semver.Version,
localMinCluster *semver.Version,
err error) {
localServer = semver.Must(semver.NewVersion(version.Version))
localMinCluster = semver.Must(semver.NewVersion(version.MinClusterVersion))
if compareMajorMino... | [
"func",
"checkVersionCompatibility",
"(",
"name",
"string",
",",
"server",
",",
"minCluster",
"*",
"semver",
".",
"Version",
")",
"(",
"localServer",
"*",
"semver",
".",
"Version",
",",
"localMinCluster",
"*",
"semver",
".",
"Version",
",",
"err",
"error",
"... | // checkVersionCompatibility checks whether the given version is compatible
// with the local version. | [
"checkVersionCompatibility",
"checks",
"whether",
"the",
"given",
"version",
"is",
"compatible",
"with",
"the",
"local",
"version",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L155-L168 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | setPeerURLsHeader | func setPeerURLsHeader(req *http.Request, urls types.URLs) {
if urls == nil {
// often not set in unit tests
return
}
peerURLs := make([]string, urls.Len())
for i := range urls {
peerURLs[i] = urls[i].String()
}
req.Header.Set("X-PeerURLs", strings.Join(peerURLs, ","))
} | go | func setPeerURLsHeader(req *http.Request, urls types.URLs) {
if urls == nil {
// often not set in unit tests
return
}
peerURLs := make([]string, urls.Len())
for i := range urls {
peerURLs[i] = urls[i].String()
}
req.Header.Set("X-PeerURLs", strings.Join(peerURLs, ","))
} | [
"func",
"setPeerURLsHeader",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"urls",
"types",
".",
"URLs",
")",
"{",
"if",
"urls",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"peerURLs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"urls",
".",
"Len"... | // setPeerURLsHeader reports local urls for peer discovery | [
"setPeerURLsHeader",
"reports",
"local",
"urls",
"for",
"peer",
"discovery"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L171-L181 | test |
etcd-io/etcd | etcdserver/api/rafthttp/util.go | addRemoteFromRequest | func addRemoteFromRequest(tr Transporter, r *http.Request) {
if from, err := types.IDFromString(r.Header.Get("X-Server-From")); err == nil {
if urls := r.Header.Get("X-PeerURLs"); urls != "" {
tr.AddRemote(from, strings.Split(urls, ","))
}
}
} | go | func addRemoteFromRequest(tr Transporter, r *http.Request) {
if from, err := types.IDFromString(r.Header.Get("X-Server-From")); err == nil {
if urls := r.Header.Get("X-PeerURLs"); urls != "" {
tr.AddRemote(from, strings.Split(urls, ","))
}
}
} | [
"func",
"addRemoteFromRequest",
"(",
"tr",
"Transporter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"from",
",",
"err",
":=",
"types",
".",
"IDFromString",
"(",
"r",
".",
"Header",
".",
"Get",
"(",
"\"X-Server-From\"",
")",
")",
";",
"err"... | // addRemoteFromRequest adds a remote peer according to an http request header | [
"addRemoteFromRequest",
"adds",
"a",
"remote",
"peer",
"according",
"to",
"an",
"http",
"request",
"header"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L184-L190 | test |
etcd-io/etcd | client/keys.go | NewKeysAPIWithPrefix | func NewKeysAPIWithPrefix(c Client, p string) KeysAPI {
return &httpKeysAPI{
client: c,
prefix: p,
}
} | go | func NewKeysAPIWithPrefix(c Client, p string) KeysAPI {
return &httpKeysAPI{
client: c,
prefix: p,
}
} | [
"func",
"NewKeysAPIWithPrefix",
"(",
"c",
"Client",
",",
"p",
"string",
")",
"KeysAPI",
"{",
"return",
"&",
"httpKeysAPI",
"{",
"client",
":",
"c",
",",
"prefix",
":",
"p",
",",
"}",
"\n",
"}"
] | // NewKeysAPIWithPrefix acts like NewKeysAPI, but allows the caller
// to provide a custom base URL path. This should only be used in
// very rare cases. | [
"NewKeysAPIWithPrefix",
"acts",
"like",
"NewKeysAPI",
"but",
"allows",
"the",
"caller",
"to",
"provide",
"a",
"custom",
"base",
"URL",
"path",
".",
"This",
"should",
"only",
"be",
"used",
"in",
"very",
"rare",
"cases",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/keys.go#L92-L97 | test |
etcd-io/etcd | client/keys.go | TTLDuration | func (n *Node) TTLDuration() time.Duration {
return time.Duration(n.TTL) * time.Second
} | go | func (n *Node) TTLDuration() time.Duration {
return time.Duration(n.TTL) * time.Second
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"TTLDuration",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"n",
".",
"TTL",
")",
"*",
"time",
".",
"Second",
"\n",
"}"
] | // TTLDuration returns the Node's TTL as a time.Duration object | [
"TTLDuration",
"returns",
"the",
"Node",
"s",
"TTL",
"as",
"a",
"time",
".",
"Duration",
"object"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/keys.go#L311-L313 | test |
etcd-io/etcd | pkg/flags/flag.go | SetPflagsFromEnv | func SetPflagsFromEnv(prefix string, fs *pflag.FlagSet) error {
var err error
alreadySet := make(map[string]bool)
usedEnvKey := make(map[string]bool)
fs.VisitAll(func(f *pflag.Flag) {
if f.Changed {
alreadySet[FlagToEnv(prefix, f.Name)] = true
}
if serr := setFlagFromEnv(fs, prefix, f.Name, usedEnvKey, alr... | go | func SetPflagsFromEnv(prefix string, fs *pflag.FlagSet) error {
var err error
alreadySet := make(map[string]bool)
usedEnvKey := make(map[string]bool)
fs.VisitAll(func(f *pflag.Flag) {
if f.Changed {
alreadySet[FlagToEnv(prefix, f.Name)] = true
}
if serr := setFlagFromEnv(fs, prefix, f.Name, usedEnvKey, alr... | [
"func",
"SetPflagsFromEnv",
"(",
"prefix",
"string",
",",
"fs",
"*",
"pflag",
".",
"FlagSet",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"alreadySet",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"usedEnvKey",
":=",
"make",
"("... | // SetPflagsFromEnv is similar to SetFlagsFromEnv. However, the accepted flagset type is pflag.FlagSet
// and it does not do any logging. | [
"SetPflagsFromEnv",
"is",
"similar",
"to",
"SetFlagsFromEnv",
".",
"However",
"the",
"accepted",
"flagset",
"type",
"is",
"pflag",
".",
"FlagSet",
"and",
"it",
"does",
"not",
"do",
"any",
"logging",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/flag.go#L53-L67 | test |
etcd-io/etcd | pkg/flags/flag.go | FlagToEnv | func FlagToEnv(prefix, name string) string {
return prefix + "_" + strings.ToUpper(strings.Replace(name, "-", "_", -1))
} | go | func FlagToEnv(prefix, name string) string {
return prefix + "_" + strings.ToUpper(strings.Replace(name, "-", "_", -1))
} | [
"func",
"FlagToEnv",
"(",
"prefix",
",",
"name",
"string",
")",
"string",
"{",
"return",
"prefix",
"+",
"\"_\"",
"+",
"strings",
".",
"ToUpper",
"(",
"strings",
".",
"Replace",
"(",
"name",
",",
"\"-\"",
",",
"\"_\"",
",",
"-",
"1",
")",
")",
"\n",
... | // FlagToEnv converts flag string to upper-case environment variable key string. | [
"FlagToEnv",
"converts",
"flag",
"string",
"to",
"upper",
"-",
"case",
"environment",
"variable",
"key",
"string",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/flag.go#L70-L72 | test |
etcd-io/etcd | tools/etcd-dump-logs/main.go | excerpt | func excerpt(str string, pre, suf int) string {
if pre+suf > len(str) {
return fmt.Sprintf("%q", str)
}
return fmt.Sprintf("%q...%q", str[:pre], str[len(str)-suf:])
} | go | func excerpt(str string, pre, suf int) string {
if pre+suf > len(str) {
return fmt.Sprintf("%q", str)
}
return fmt.Sprintf("%q...%q", str[:pre], str[len(str)-suf:])
} | [
"func",
"excerpt",
"(",
"str",
"string",
",",
"pre",
",",
"suf",
"int",
")",
"string",
"{",
"if",
"pre",
"+",
"suf",
">",
"len",
"(",
"str",
")",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%q\"",
",",
"str",
")",
"\n",
"}",
"\n",
"return",
"... | // excerpt replaces middle part with ellipsis and returns a double-quoted
// string safely escaped with Go syntax. | [
"excerpt",
"replaces",
"middle",
"part",
"with",
"ellipsis",
"and",
"returns",
"a",
"double",
"-",
"quoted",
"string",
"safely",
"escaped",
"with",
"Go",
"syntax",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/tools/etcd-dump-logs/main.go#L145-L150 | test |
etcd-io/etcd | tools/etcd-dump-logs/main.go | passConfChange | func passConfChange(entry raftpb.Entry) (bool, string) {
return entry.Type == raftpb.EntryConfChange, "ConfigChange"
} | go | func passConfChange(entry raftpb.Entry) (bool, string) {
return entry.Type == raftpb.EntryConfChange, "ConfigChange"
} | [
"func",
"passConfChange",
"(",
"entry",
"raftpb",
".",
"Entry",
")",
"(",
"bool",
",",
"string",
")",
"{",
"return",
"entry",
".",
"Type",
"==",
"raftpb",
".",
"EntryConfChange",
",",
"\"ConfigChange\"",
"\n",
"}"
] | // The 9 pass functions below takes the raftpb.Entry and return if the entry should be printed and the type of entry,
// the type of the entry will used in the following print function | [
"The",
"9",
"pass",
"functions",
"below",
"takes",
"the",
"raftpb",
".",
"Entry",
"and",
"return",
"if",
"the",
"entry",
"should",
"be",
"printed",
"and",
"the",
"type",
"of",
"entry",
"the",
"type",
"of",
"the",
"entry",
"will",
"used",
"in",
"the",
"... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/tools/etcd-dump-logs/main.go#L156-L158 | test |
etcd-io/etcd | tools/etcd-dump-logs/main.go | printInternalRaftRequest | func printInternalRaftRequest(entry raftpb.Entry) {
var rr etcdserverpb.InternalRaftRequest
if err := rr.Unmarshal(entry.Data); err == nil {
fmt.Printf("%4d\t%10d\tnorm\t%s", entry.Term, entry.Index, rr.String())
}
} | go | func printInternalRaftRequest(entry raftpb.Entry) {
var rr etcdserverpb.InternalRaftRequest
if err := rr.Unmarshal(entry.Data); err == nil {
fmt.Printf("%4d\t%10d\tnorm\t%s", entry.Term, entry.Index, rr.String())
}
} | [
"func",
"printInternalRaftRequest",
"(",
"entry",
"raftpb",
".",
"Entry",
")",
"{",
"var",
"rr",
"etcdserverpb",
".",
"InternalRaftRequest",
"\n",
"if",
"err",
":=",
"rr",
".",
"Unmarshal",
"(",
"entry",
".",
"Data",
")",
";",
"err",
"==",
"nil",
"{",
"f... | // The 4 print functions below print the entry format based on there types
// printInternalRaftRequest is used to print entry information for IRRRange, IRRPut,
// IRRDeleteRange and IRRTxn entries | [
"The",
"4",
"print",
"functions",
"below",
"print",
"the",
"entry",
"format",
"based",
"on",
"there",
"types",
"printInternalRaftRequest",
"is",
"used",
"to",
"print",
"entry",
"information",
"for",
"IRRRange",
"IRRPut",
"IRRDeleteRange",
"and",
"IRRTxn",
"entries... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/tools/etcd-dump-logs/main.go#L223-L228 | test |
etcd-io/etcd | tools/etcd-dump-logs/main.go | listEntriesType | func listEntriesType(entrytype string, streamdecoder string, ents []raftpb.Entry) {
entryFilters := evaluateEntrytypeFlag(entrytype)
printerMap := map[string]EntryPrinter{"InternalRaftRequest": printInternalRaftRequest,
"Request": printRequest,
"ConfigChange": printConfChange,
"UnknownNormal": printUnkno... | go | func listEntriesType(entrytype string, streamdecoder string, ents []raftpb.Entry) {
entryFilters := evaluateEntrytypeFlag(entrytype)
printerMap := map[string]EntryPrinter{"InternalRaftRequest": printInternalRaftRequest,
"Request": printRequest,
"ConfigChange": printConfChange,
"UnknownNormal": printUnkno... | [
"func",
"listEntriesType",
"(",
"entrytype",
"string",
",",
"streamdecoder",
"string",
",",
"ents",
"[",
"]",
"raftpb",
".",
"Entry",
")",
"{",
"entryFilters",
":=",
"evaluateEntrytypeFlag",
"(",
"entrytype",
")",
"\n",
"printerMap",
":=",
"map",
"[",
"string"... | // listEntriesType filters and prints entries based on the entry-type flag, | [
"listEntriesType",
"filters",
"and",
"prints",
"entries",
"based",
"on",
"the",
"entry",
"-",
"type",
"flag"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/tools/etcd-dump-logs/main.go#L305-L378 | test |
etcd-io/etcd | raft/log.go | newLog | func newLog(storage Storage, logger Logger) *raftLog {
return newLogWithSize(storage, logger, noLimit)
} | go | func newLog(storage Storage, logger Logger) *raftLog {
return newLogWithSize(storage, logger, noLimit)
} | [
"func",
"newLog",
"(",
"storage",
"Storage",
",",
"logger",
"Logger",
")",
"*",
"raftLog",
"{",
"return",
"newLogWithSize",
"(",
"storage",
",",
"logger",
",",
"noLimit",
")",
"\n",
"}"
] | // newLog returns log using the given storage and default options. It
// recovers the log to the state that it just commits and applies the
// latest snapshot. | [
"newLog",
"returns",
"log",
"using",
"the",
"given",
"storage",
"and",
"default",
"options",
".",
"It",
"recovers",
"the",
"log",
"to",
"the",
"state",
"that",
"it",
"just",
"commits",
"and",
"applies",
"the",
"latest",
"snapshot",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log.go#L50-L52 | test |
etcd-io/etcd | raft/log.go | newLogWithSize | func newLogWithSize(storage Storage, logger Logger, maxNextEntsSize uint64) *raftLog {
if storage == nil {
log.Panic("storage must not be nil")
}
log := &raftLog{
storage: storage,
logger: logger,
maxNextEntsSize: maxNextEntsSize,
}
firstIndex, err := storage.FirstIndex()
if err != nil {
... | go | func newLogWithSize(storage Storage, logger Logger, maxNextEntsSize uint64) *raftLog {
if storage == nil {
log.Panic("storage must not be nil")
}
log := &raftLog{
storage: storage,
logger: logger,
maxNextEntsSize: maxNextEntsSize,
}
firstIndex, err := storage.FirstIndex()
if err != nil {
... | [
"func",
"newLogWithSize",
"(",
"storage",
"Storage",
",",
"logger",
"Logger",
",",
"maxNextEntsSize",
"uint64",
")",
"*",
"raftLog",
"{",
"if",
"storage",
"==",
"nil",
"{",
"log",
".",
"Panic",
"(",
"\"storage must not be nil\"",
")",
"\n",
"}",
"\n",
"log",... | // newLogWithSize returns a log using the given storage and max
// message size. | [
"newLogWithSize",
"returns",
"a",
"log",
"using",
"the",
"given",
"storage",
"and",
"max",
"message",
"size",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log.go#L56-L80 | test |
etcd-io/etcd | raft/log.go | findConflict | func (l *raftLog) findConflict(ents []pb.Entry) uint64 {
for _, ne := range ents {
if !l.matchTerm(ne.Index, ne.Term) {
if ne.Index <= l.lastIndex() {
l.logger.Infof("found conflict at index %d [existing term: %d, conflicting term: %d]",
ne.Index, l.zeroTermOnErrCompacted(l.term(ne.Index)), ne.Term)
}... | go | func (l *raftLog) findConflict(ents []pb.Entry) uint64 {
for _, ne := range ents {
if !l.matchTerm(ne.Index, ne.Term) {
if ne.Index <= l.lastIndex() {
l.logger.Infof("found conflict at index %d [existing term: %d, conflicting term: %d]",
ne.Index, l.zeroTermOnErrCompacted(l.term(ne.Index)), ne.Term)
}... | [
"func",
"(",
"l",
"*",
"raftLog",
")",
"findConflict",
"(",
"ents",
"[",
"]",
"pb",
".",
"Entry",
")",
"uint64",
"{",
"for",
"_",
",",
"ne",
":=",
"range",
"ents",
"{",
"if",
"!",
"l",
".",
"matchTerm",
"(",
"ne",
".",
"Index",
",",
"ne",
".",
... | // findConflict finds the index of the conflict.
// It returns the first pair of conflicting entries between the existing
// entries and the given entries, if there are any.
// If there is no conflicting entries, and the existing entries contains
// all the given entries, zero will be returned.
// If there is no confli... | [
"findConflict",
"finds",
"the",
"index",
"of",
"the",
"conflict",
".",
"It",
"returns",
"the",
"first",
"pair",
"of",
"conflicting",
"entries",
"between",
"the",
"existing",
"entries",
"and",
"the",
"given",
"entries",
"if",
"there",
"are",
"any",
".",
"If",... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log.go#L128-L139 | test |
etcd-io/etcd | raft/log.go | nextEnts | func (l *raftLog) nextEnts() (ents []pb.Entry) {
off := max(l.applied+1, l.firstIndex())
if l.committed+1 > off {
ents, err := l.slice(off, l.committed+1, l.maxNextEntsSize)
if err != nil {
l.logger.Panicf("unexpected error when getting unapplied entries (%v)", err)
}
return ents
}
return nil
} | go | func (l *raftLog) nextEnts() (ents []pb.Entry) {
off := max(l.applied+1, l.firstIndex())
if l.committed+1 > off {
ents, err := l.slice(off, l.committed+1, l.maxNextEntsSize)
if err != nil {
l.logger.Panicf("unexpected error when getting unapplied entries (%v)", err)
}
return ents
}
return nil
} | [
"func",
"(",
"l",
"*",
"raftLog",
")",
"nextEnts",
"(",
")",
"(",
"ents",
"[",
"]",
"pb",
".",
"Entry",
")",
"{",
"off",
":=",
"max",
"(",
"l",
".",
"applied",
"+",
"1",
",",
"l",
".",
"firstIndex",
"(",
")",
")",
"\n",
"if",
"l",
".",
"com... | // nextEnts returns all the available entries for execution.
// If applied is smaller than the index of snapshot, it returns all committed
// entries after the index of snapshot. | [
"nextEnts",
"returns",
"all",
"the",
"available",
"entries",
"for",
"execution",
".",
"If",
"applied",
"is",
"smaller",
"than",
"the",
"index",
"of",
"snapshot",
"it",
"returns",
"all",
"committed",
"entries",
"after",
"the",
"index",
"of",
"snapshot",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log.go#L151-L161 | test |
etcd-io/etcd | raft/log.go | allEntries | func (l *raftLog) allEntries() []pb.Entry {
ents, err := l.entries(l.firstIndex(), noLimit)
if err == nil {
return ents
}
if err == ErrCompacted { // try again if there was a racing compaction
return l.allEntries()
}
// TODO (xiangli): handle error?
panic(err)
} | go | func (l *raftLog) allEntries() []pb.Entry {
ents, err := l.entries(l.firstIndex(), noLimit)
if err == nil {
return ents
}
if err == ErrCompacted { // try again if there was a racing compaction
return l.allEntries()
}
// TODO (xiangli): handle error?
panic(err)
} | [
"func",
"(",
"l",
"*",
"raftLog",
")",
"allEntries",
"(",
")",
"[",
"]",
"pb",
".",
"Entry",
"{",
"ents",
",",
"err",
":=",
"l",
".",
"entries",
"(",
"l",
".",
"firstIndex",
"(",
")",
",",
"noLimit",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
... | // allEntries returns all entries in the log. | [
"allEntries",
"returns",
"all",
"entries",
"in",
"the",
"log",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log.go#L261-L271 | test |
etcd-io/etcd | raft/log.go | slice | func (l *raftLog) slice(lo, hi, maxSize uint64) ([]pb.Entry, error) {
err := l.mustCheckOutOfBounds(lo, hi)
if err != nil {
return nil, err
}
if lo == hi {
return nil, nil
}
var ents []pb.Entry
if lo < l.unstable.offset {
storedEnts, err := l.storage.Entries(lo, min(hi, l.unstable.offset), maxSize)
if er... | go | func (l *raftLog) slice(lo, hi, maxSize uint64) ([]pb.Entry, error) {
err := l.mustCheckOutOfBounds(lo, hi)
if err != nil {
return nil, err
}
if lo == hi {
return nil, nil
}
var ents []pb.Entry
if lo < l.unstable.offset {
storedEnts, err := l.storage.Entries(lo, min(hi, l.unstable.offset), maxSize)
if er... | [
"func",
"(",
"l",
"*",
"raftLog",
")",
"slice",
"(",
"lo",
",",
"hi",
",",
"maxSize",
"uint64",
")",
"(",
"[",
"]",
"pb",
".",
"Entry",
",",
"error",
")",
"{",
"err",
":=",
"l",
".",
"mustCheckOutOfBounds",
"(",
"lo",
",",
"hi",
")",
"\n",
"if"... | // slice returns a slice of log entries from lo through hi-1, inclusive. | [
"slice",
"returns",
"a",
"slice",
"of",
"log",
"entries",
"from",
"lo",
"through",
"hi",
"-",
"1",
"inclusive",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log.go#L306-L344 | test |
etcd-io/etcd | clientv3/concurrency/session.go | NewSession | func NewSession(client *v3.Client, opts ...SessionOption) (*Session, error) {
ops := &sessionOptions{ttl: defaultSessionTTL, ctx: client.Ctx()}
for _, opt := range opts {
opt(ops)
}
id := ops.leaseID
if id == v3.NoLease {
resp, err := client.Grant(ops.ctx, int64(ops.ttl))
if err != nil {
return nil, err
... | go | func NewSession(client *v3.Client, opts ...SessionOption) (*Session, error) {
ops := &sessionOptions{ttl: defaultSessionTTL, ctx: client.Ctx()}
for _, opt := range opts {
opt(ops)
}
id := ops.leaseID
if id == v3.NoLease {
resp, err := client.Grant(ops.ctx, int64(ops.ttl))
if err != nil {
return nil, err
... | [
"func",
"NewSession",
"(",
"client",
"*",
"v3",
".",
"Client",
",",
"opts",
"...",
"SessionOption",
")",
"(",
"*",
"Session",
",",
"error",
")",
"{",
"ops",
":=",
"&",
"sessionOptions",
"{",
"ttl",
":",
"defaultSessionTTL",
",",
"ctx",
":",
"client",
"... | // NewSession gets the leased session for a client. | [
"NewSession",
"gets",
"the",
"leased",
"session",
"for",
"a",
"client",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/session.go#L38-L72 | test |
etcd-io/etcd | clientv3/concurrency/session.go | Close | func (s *Session) Close() error {
s.Orphan()
// if revoke takes longer than the ttl, lease is expired anyway
ctx, cancel := context.WithTimeout(s.opts.ctx, time.Duration(s.opts.ttl)*time.Second)
_, err := s.client.Revoke(ctx, s.id)
cancel()
return err
} | go | func (s *Session) Close() error {
s.Orphan()
// if revoke takes longer than the ttl, lease is expired anyway
ctx, cancel := context.WithTimeout(s.opts.ctx, time.Duration(s.opts.ttl)*time.Second)
_, err := s.client.Revoke(ctx, s.id)
cancel()
return err
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Close",
"(",
")",
"error",
"{",
"s",
".",
"Orphan",
"(",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"s",
".",
"opts",
".",
"ctx",
",",
"time",
".",
"Duration",
"(",
"s",
".... | // Close orphans the session and revokes the session lease. | [
"Close",
"orphans",
"the",
"session",
"and",
"revokes",
"the",
"session",
"lease",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/session.go#L95-L102 | test |
etcd-io/etcd | clientv3/concurrency/session.go | WithTTL | func WithTTL(ttl int) SessionOption {
return func(so *sessionOptions) {
if ttl > 0 {
so.ttl = ttl
}
}
} | go | func WithTTL(ttl int) SessionOption {
return func(so *sessionOptions) {
if ttl > 0 {
so.ttl = ttl
}
}
} | [
"func",
"WithTTL",
"(",
"ttl",
"int",
")",
"SessionOption",
"{",
"return",
"func",
"(",
"so",
"*",
"sessionOptions",
")",
"{",
"if",
"ttl",
">",
"0",
"{",
"so",
".",
"ttl",
"=",
"ttl",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // WithTTL configures the session's TTL in seconds.
// If TTL is <= 0, the default 60 seconds TTL will be used. | [
"WithTTL",
"configures",
"the",
"session",
"s",
"TTL",
"in",
"seconds",
".",
"If",
"TTL",
"is",
"<",
"=",
"0",
"the",
"default",
"60",
"seconds",
"TTL",
"will",
"be",
"used",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/session.go#L115-L121 | test |
etcd-io/etcd | clientv3/concurrency/session.go | WithLease | func WithLease(leaseID v3.LeaseID) SessionOption {
return func(so *sessionOptions) {
so.leaseID = leaseID
}
} | go | func WithLease(leaseID v3.LeaseID) SessionOption {
return func(so *sessionOptions) {
so.leaseID = leaseID
}
} | [
"func",
"WithLease",
"(",
"leaseID",
"v3",
".",
"LeaseID",
")",
"SessionOption",
"{",
"return",
"func",
"(",
"so",
"*",
"sessionOptions",
")",
"{",
"so",
".",
"leaseID",
"=",
"leaseID",
"\n",
"}",
"\n",
"}"
] | // WithLease specifies the existing leaseID to be used for the session.
// This is useful in process restart scenario, for example, to reclaim
// leadership from an election prior to restart. | [
"WithLease",
"specifies",
"the",
"existing",
"leaseID",
"to",
"be",
"used",
"for",
"the",
"session",
".",
"This",
"is",
"useful",
"in",
"process",
"restart",
"scenario",
"for",
"example",
"to",
"reclaim",
"leadership",
"from",
"an",
"election",
"prior",
"to",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/session.go#L126-L130 | test |
etcd-io/etcd | raft/read_only.go | addRequest | func (ro *readOnly) addRequest(index uint64, m pb.Message) {
ctx := string(m.Entries[0].Data)
if _, ok := ro.pendingReadIndex[ctx]; ok {
return
}
ro.pendingReadIndex[ctx] = &readIndexStatus{index: index, req: m, acks: make(map[uint64]struct{})}
ro.readIndexQueue = append(ro.readIndexQueue, ctx)
} | go | func (ro *readOnly) addRequest(index uint64, m pb.Message) {
ctx := string(m.Entries[0].Data)
if _, ok := ro.pendingReadIndex[ctx]; ok {
return
}
ro.pendingReadIndex[ctx] = &readIndexStatus{index: index, req: m, acks: make(map[uint64]struct{})}
ro.readIndexQueue = append(ro.readIndexQueue, ctx)
} | [
"func",
"(",
"ro",
"*",
"readOnly",
")",
"addRequest",
"(",
"index",
"uint64",
",",
"m",
"pb",
".",
"Message",
")",
"{",
"ctx",
":=",
"string",
"(",
"m",
".",
"Entries",
"[",
"0",
"]",
".",
"Data",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"ro",
... | // addRequest adds a read only reuqest into readonly struct.
// `index` is the commit index of the raft state machine when it received
// the read only request.
// `m` is the original read only request message from the local or remote node. | [
"addRequest",
"adds",
"a",
"read",
"only",
"reuqest",
"into",
"readonly",
"struct",
".",
"index",
"is",
"the",
"commit",
"index",
"of",
"the",
"raft",
"state",
"machine",
"when",
"it",
"received",
"the",
"read",
"only",
"request",
".",
"m",
"is",
"the",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/read_only.go#L52-L59 | test |
etcd-io/etcd | raft/read_only.go | recvAck | func (ro *readOnly) recvAck(m pb.Message) int {
rs, ok := ro.pendingReadIndex[string(m.Context)]
if !ok {
return 0
}
rs.acks[m.From] = struct{}{}
// add one to include an ack from local node
return len(rs.acks) + 1
} | go | func (ro *readOnly) recvAck(m pb.Message) int {
rs, ok := ro.pendingReadIndex[string(m.Context)]
if !ok {
return 0
}
rs.acks[m.From] = struct{}{}
// add one to include an ack from local node
return len(rs.acks) + 1
} | [
"func",
"(",
"ro",
"*",
"readOnly",
")",
"recvAck",
"(",
"m",
"pb",
".",
"Message",
")",
"int",
"{",
"rs",
",",
"ok",
":=",
"ro",
".",
"pendingReadIndex",
"[",
"string",
"(",
"m",
".",
"Context",
")",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
... | // recvAck notifies the readonly struct that the raft state machine received
// an acknowledgment of the heartbeat that attached with the read only request
// context. | [
"recvAck",
"notifies",
"the",
"readonly",
"struct",
"that",
"the",
"raft",
"state",
"machine",
"received",
"an",
"acknowledgment",
"of",
"the",
"heartbeat",
"that",
"attached",
"with",
"the",
"read",
"only",
"request",
"context",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/read_only.go#L64-L73 | test |
etcd-io/etcd | raft/read_only.go | advance | func (ro *readOnly) advance(m pb.Message) []*readIndexStatus {
var (
i int
found bool
)
ctx := string(m.Context)
rss := []*readIndexStatus{}
for _, okctx := range ro.readIndexQueue {
i++
rs, ok := ro.pendingReadIndex[okctx]
if !ok {
panic("cannot find corresponding read state from pending map")
... | go | func (ro *readOnly) advance(m pb.Message) []*readIndexStatus {
var (
i int
found bool
)
ctx := string(m.Context)
rss := []*readIndexStatus{}
for _, okctx := range ro.readIndexQueue {
i++
rs, ok := ro.pendingReadIndex[okctx]
if !ok {
panic("cannot find corresponding read state from pending map")
... | [
"func",
"(",
"ro",
"*",
"readOnly",
")",
"advance",
"(",
"m",
"pb",
".",
"Message",
")",
"[",
"]",
"*",
"readIndexStatus",
"{",
"var",
"(",
"i",
"int",
"\n",
"found",
"bool",
"\n",
")",
"\n",
"ctx",
":=",
"string",
"(",
"m",
".",
"Context",
")",
... | // advance advances the read only request queue kept by the readonly struct.
// It dequeues the requests until it finds the read only request that has
// the same context as the given `m`. | [
"advance",
"advances",
"the",
"read",
"only",
"request",
"queue",
"kept",
"by",
"the",
"readonly",
"struct",
".",
"It",
"dequeues",
"the",
"requests",
"until",
"it",
"finds",
"the",
"read",
"only",
"request",
"that",
"has",
"the",
"same",
"context",
"as",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/read_only.go#L78-L109 | test |
etcd-io/etcd | raft/read_only.go | lastPendingRequestCtx | func (ro *readOnly) lastPendingRequestCtx() string {
if len(ro.readIndexQueue) == 0 {
return ""
}
return ro.readIndexQueue[len(ro.readIndexQueue)-1]
} | go | func (ro *readOnly) lastPendingRequestCtx() string {
if len(ro.readIndexQueue) == 0 {
return ""
}
return ro.readIndexQueue[len(ro.readIndexQueue)-1]
} | [
"func",
"(",
"ro",
"*",
"readOnly",
")",
"lastPendingRequestCtx",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"ro",
".",
"readIndexQueue",
")",
"==",
"0",
"{",
"return",
"\"\"",
"\n",
"}",
"\n",
"return",
"ro",
".",
"readIndexQueue",
"[",
"len",
"(",
... | // lastPendingRequestCtx returns the context of the last pending read only
// request in readonly struct. | [
"lastPendingRequestCtx",
"returns",
"the",
"context",
"of",
"the",
"last",
"pending",
"read",
"only",
"request",
"in",
"readonly",
"struct",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/read_only.go#L113-L118 | test |
etcd-io/etcd | etcdserver/server.go | Start | func (s *EtcdServer) Start() {
s.start()
s.goAttach(func() { s.adjustTicks() })
s.goAttach(func() { s.publish(s.Cfg.ReqTimeout()) })
s.goAttach(s.purgeFile)
s.goAttach(func() { monitorFileDescriptor(s.getLogger(), s.stopping) })
s.goAttach(s.monitorVersions)
s.goAttach(s.linearizableReadLoop)
s.goAttach(s.monit... | go | func (s *EtcdServer) Start() {
s.start()
s.goAttach(func() { s.adjustTicks() })
s.goAttach(func() { s.publish(s.Cfg.ReqTimeout()) })
s.goAttach(s.purgeFile)
s.goAttach(func() { monitorFileDescriptor(s.getLogger(), s.stopping) })
s.goAttach(s.monitorVersions)
s.goAttach(s.linearizableReadLoop)
s.goAttach(s.monit... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"Start",
"(",
")",
"{",
"s",
".",
"start",
"(",
")",
"\n",
"s",
".",
"goAttach",
"(",
"func",
"(",
")",
"{",
"s",
".",
"adjustTicks",
"(",
")",
"}",
")",
"\n",
"s",
".",
"goAttach",
"(",
"func",
"(",
... | // Start performs any initialization of the Server necessary for it to
// begin serving requests. It must be called before Do or Process.
// Start must be non-blocking; any long-running server functionality
// should be implemented in goroutines. | [
"Start",
"performs",
"any",
"initialization",
"of",
"the",
"Server",
"necessary",
"for",
"it",
"to",
"begin",
"serving",
"requests",
".",
"It",
"must",
"be",
"called",
"before",
"Do",
"or",
"Process",
".",
"Start",
"must",
"be",
"non",
"-",
"blocking",
";"... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L710-L719 | test |
etcd-io/etcd | etcdserver/server.go | start | func (s *EtcdServer) start() {
lg := s.getLogger()
if s.Cfg.SnapshotCount == 0 {
if lg != nil {
lg.Info(
"updating snapshot-count to default",
zap.Uint64("given-snapshot-count", s.Cfg.SnapshotCount),
zap.Uint64("updated-snapshot-count", DefaultSnapshotCount),
)
} else {
plog.Infof("set snaps... | go | func (s *EtcdServer) start() {
lg := s.getLogger()
if s.Cfg.SnapshotCount == 0 {
if lg != nil {
lg.Info(
"updating snapshot-count to default",
zap.Uint64("given-snapshot-count", s.Cfg.SnapshotCount),
zap.Uint64("updated-snapshot-count", DefaultSnapshotCount),
)
} else {
plog.Infof("set snaps... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"start",
"(",
")",
"{",
"lg",
":=",
"s",
".",
"getLogger",
"(",
")",
"\n",
"if",
"s",
".",
"Cfg",
".",
"SnapshotCount",
"==",
"0",
"{",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Info",
"(",
"\"updating ... | // start prepares and starts server in a new goroutine. It is no longer safe to
// modify a server's fields after it has been sent to Start.
// This function is just used for testing. | [
"start",
"prepares",
"and",
"starts",
"server",
"in",
"a",
"new",
"goroutine",
".",
"It",
"is",
"no",
"longer",
"safe",
"to",
"modify",
"a",
"server",
"s",
"fields",
"after",
"it",
"has",
"been",
"sent",
"to",
"Start",
".",
"This",
"function",
"is",
"j... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L724-L788 | test |
etcd-io/etcd | etcdserver/server.go | Process | func (s *EtcdServer) Process(ctx context.Context, m raftpb.Message) error {
if s.cluster.IsIDRemoved(types.ID(m.From)) {
if lg := s.getLogger(); lg != nil {
lg.Warn(
"rejected Raft message from removed member",
zap.String("local-member-id", s.ID().String()),
zap.String("removed-member-id", types.ID(m.... | go | func (s *EtcdServer) Process(ctx context.Context, m raftpb.Message) error {
if s.cluster.IsIDRemoved(types.ID(m.From)) {
if lg := s.getLogger(); lg != nil {
lg.Warn(
"rejected Raft message from removed member",
zap.String("local-member-id", s.ID().String()),
zap.String("removed-member-id", types.ID(m.... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"Process",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"raftpb",
".",
"Message",
")",
"error",
"{",
"if",
"s",
".",
"cluster",
".",
"IsIDRemoved",
"(",
"types",
".",
"ID",
"(",
"m",
".",
"From",
")",
... | // Process takes a raft message and applies it to the server's raft state
// machine, respecting any timeout of the given context. | [
"Process",
"takes",
"a",
"raft",
"message",
"and",
"applies",
"it",
"to",
"the",
"server",
"s",
"raft",
"state",
"machine",
"respecting",
"any",
"timeout",
"of",
"the",
"given",
"context",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L846-L863 | test |
etcd-io/etcd | etcdserver/server.go | ReportSnapshot | func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) {
s.r.ReportSnapshot(id, status)
} | go | func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) {
s.r.ReportSnapshot(id, status)
} | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"ReportSnapshot",
"(",
"id",
"uint64",
",",
"status",
"raft",
".",
"SnapshotStatus",
")",
"{",
"s",
".",
"r",
".",
"ReportSnapshot",
"(",
"id",
",",
"status",
")",
"\n",
"}"
] | // ReportSnapshot reports snapshot sent status to the raft state machine,
// and clears the used snapshot from the snapshot store. | [
"ReportSnapshot",
"reports",
"snapshot",
"sent",
"status",
"to",
"the",
"raft",
"state",
"machine",
"and",
"clears",
"the",
"used",
"snapshot",
"from",
"the",
"snapshot",
"store",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L871-L873 | test |
etcd-io/etcd | etcdserver/server.go | MoveLeader | func (s *EtcdServer) MoveLeader(ctx context.Context, lead, transferee uint64) error {
now := time.Now()
interval := time.Duration(s.Cfg.TickMs) * time.Millisecond
if lg := s.getLogger(); lg != nil {
lg.Info(
"leadership transfer starting",
zap.String("local-member-id", s.ID().String()),
zap.String("curre... | go | func (s *EtcdServer) MoveLeader(ctx context.Context, lead, transferee uint64) error {
now := time.Now()
interval := time.Duration(s.Cfg.TickMs) * time.Millisecond
if lg := s.getLogger(); lg != nil {
lg.Info(
"leadership transfer starting",
zap.String("local-member-id", s.ID().String()),
zap.String("curre... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"MoveLeader",
"(",
"ctx",
"context",
".",
"Context",
",",
"lead",
",",
"transferee",
"uint64",
")",
"error",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"interval",
":=",
"time",
".",
"Duration",
"(... | // MoveLeader transfers the leader to the given transferee. | [
"MoveLeader",
"transfers",
"the",
"leader",
"to",
"the",
"given",
"transferee",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1384-L1421 | test |
etcd-io/etcd | etcdserver/server.go | TransferLeadership | func (s *EtcdServer) TransferLeadership() error {
if !s.isLeader() {
if lg := s.getLogger(); lg != nil {
lg.Info(
"skipped leadership transfer; local server is not leader",
zap.String("local-member-id", s.ID().String()),
zap.String("current-leader-member-id", types.ID(s.Lead()).String()),
)
} els... | go | func (s *EtcdServer) TransferLeadership() error {
if !s.isLeader() {
if lg := s.getLogger(); lg != nil {
lg.Info(
"skipped leadership transfer; local server is not leader",
zap.String("local-member-id", s.ID().String()),
zap.String("current-leader-member-id", types.ID(s.Lead()).String()),
)
} els... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"TransferLeadership",
"(",
")",
"error",
"{",
"if",
"!",
"s",
".",
"isLeader",
"(",
")",
"{",
"if",
"lg",
":=",
"s",
".",
"getLogger",
"(",
")",
";",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Info",
"(",
"\"s... | // TransferLeadership transfers the leader to the chosen transferee. | [
"TransferLeadership",
"transfers",
"the",
"leader",
"to",
"the",
"chosen",
"transferee",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1424-L1461 | test |
etcd-io/etcd | etcdserver/server.go | configure | func (s *EtcdServer) configure(ctx context.Context, cc raftpb.ConfChange) ([]*membership.Member, error) {
cc.ID = s.reqIDGen.Next()
ch := s.w.Register(cc.ID)
start := time.Now()
if err := s.r.ProposeConfChange(ctx, cc); err != nil {
s.w.Trigger(cc.ID, nil)
return nil, err
}
select {
case x := <-ch:
if x ... | go | func (s *EtcdServer) configure(ctx context.Context, cc raftpb.ConfChange) ([]*membership.Member, error) {
cc.ID = s.reqIDGen.Next()
ch := s.w.Register(cc.ID)
start := time.Now()
if err := s.r.ProposeConfChange(ctx, cc); err != nil {
s.w.Trigger(cc.ID, nil)
return nil, err
}
select {
case x := <-ch:
if x ... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"configure",
"(",
"ctx",
"context",
".",
"Context",
",",
"cc",
"raftpb",
".",
"ConfChange",
")",
"(",
"[",
"]",
"*",
"membership",
".",
"Member",
",",
"error",
")",
"{",
"cc",
".",
"ID",
"=",
"s",
".",
"r... | // configure sends a configuration change through consensus and
// then waits for it to be applied to the server. It
// will block until the change is performed or there is an error. | [
"configure",
"sends",
"a",
"configuration",
"change",
"through",
"consensus",
"and",
"then",
"waits",
"for",
"it",
"to",
"be",
"applied",
"to",
"the",
"server",
".",
"It",
"will",
"block",
"until",
"the",
"change",
"is",
"performed",
"or",
"there",
"is",
"... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1737-L1774 | test |
etcd-io/etcd | etcdserver/server.go | sync | func (s *EtcdServer) sync(timeout time.Duration) {
req := pb.Request{
Method: "SYNC",
ID: s.reqIDGen.Next(),
Time: time.Now().UnixNano(),
}
data := pbutil.MustMarshal(&req)
// There is no promise that node has leader when do SYNC request,
// so it uses goroutine to propose.
ctx, cancel := context.With... | go | func (s *EtcdServer) sync(timeout time.Duration) {
req := pb.Request{
Method: "SYNC",
ID: s.reqIDGen.Next(),
Time: time.Now().UnixNano(),
}
data := pbutil.MustMarshal(&req)
// There is no promise that node has leader when do SYNC request,
// so it uses goroutine to propose.
ctx, cancel := context.With... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"sync",
"(",
"timeout",
"time",
".",
"Duration",
")",
"{",
"req",
":=",
"pb",
".",
"Request",
"{",
"Method",
":",
"\"SYNC\"",
",",
"ID",
":",
"s",
".",
"reqIDGen",
".",
"Next",
"(",
")",
",",
"Time",
":",... | // sync proposes a SYNC request and is non-blocking.
// This makes no guarantee that the request will be proposed or performed.
// The request will be canceled after the given timeout. | [
"sync",
"proposes",
"a",
"SYNC",
"request",
"and",
"is",
"non",
"-",
"blocking",
".",
"This",
"makes",
"no",
"guarantee",
"that",
"the",
"request",
"will",
"be",
"proposed",
"or",
"performed",
".",
"The",
"request",
"will",
"be",
"canceled",
"after",
"the"... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1779-L1793 | test |
etcd-io/etcd | etcdserver/server.go | publish | func (s *EtcdServer) publish(timeout time.Duration) {
b, err := json.Marshal(s.attributes)
if err != nil {
if lg := s.getLogger(); lg != nil {
lg.Panic("failed to marshal JSON", zap.Error(err))
} else {
plog.Panicf("json marshal error: %v", err)
}
return
}
req := pb.Request{
Method: "PUT",
Path: ... | go | func (s *EtcdServer) publish(timeout time.Duration) {
b, err := json.Marshal(s.attributes)
if err != nil {
if lg := s.getLogger(); lg != nil {
lg.Panic("failed to marshal JSON", zap.Error(err))
} else {
plog.Panicf("json marshal error: %v", err)
}
return
}
req := pb.Request{
Method: "PUT",
Path: ... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"publish",
"(",
"timeout",
"time",
".",
"Duration",
")",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"s",
".",
"attributes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"lg",
":=",
"s",
... | // publish registers server information into the cluster. The information
// is the JSON representation of this server's member struct, updated with the
// static clientURLs of the server.
// The function keeps attempting to register until it succeeds,
// or its server is stopped. | [
"publish",
"registers",
"server",
"information",
"into",
"the",
"cluster",
".",
"The",
"information",
"is",
"the",
"JSON",
"representation",
"of",
"this",
"server",
"s",
"member",
"struct",
"updated",
"with",
"the",
"static",
"clientURLs",
"of",
"the",
"server",... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1800-L1866 | test |
etcd-io/etcd | etcdserver/server.go | applyEntryNormal | func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) {
shouldApplyV3 := false
if e.Index > s.consistIndex.ConsistentIndex() {
// set the consistent index of current executing entry
s.consistIndex.setConsistentIndex(e.Index)
shouldApplyV3 = true
}
// raft state machine may generate noop entry when leader co... | go | func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) {
shouldApplyV3 := false
if e.Index > s.consistIndex.ConsistentIndex() {
// set the consistent index of current executing entry
s.consistIndex.setConsistentIndex(e.Index)
shouldApplyV3 = true
}
// raft state machine may generate noop entry when leader co... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"applyEntryNormal",
"(",
"e",
"*",
"raftpb",
".",
"Entry",
")",
"{",
"shouldApplyV3",
":=",
"false",
"\n",
"if",
"e",
".",
"Index",
">",
"s",
".",
"consistIndex",
".",
"ConsistentIndex",
"(",
")",
"{",
"s",
"... | // applyEntryNormal apples an EntryNormal type raftpb request to the EtcdServer | [
"applyEntryNormal",
"apples",
"an",
"EntryNormal",
"type",
"raftpb",
"request",
"to",
"the",
"EtcdServer"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1958-L2043 | test |
etcd-io/etcd | etcdserver/server.go | applyConfChange | func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.ConfState) (bool, error) {
if err := s.cluster.ValidateConfigurationChange(cc); err != nil {
cc.NodeID = raft.None
s.r.ApplyConfChange(cc)
return false, err
}
lg := s.getLogger()
*confState = *s.r.ApplyConfChange(cc)
switch cc.Type... | go | func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.ConfState) (bool, error) {
if err := s.cluster.ValidateConfigurationChange(cc); err != nil {
cc.NodeID = raft.None
s.r.ApplyConfChange(cc)
return false, err
}
lg := s.getLogger()
*confState = *s.r.ApplyConfChange(cc)
switch cc.Type... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"applyConfChange",
"(",
"cc",
"raftpb",
".",
"ConfChange",
",",
"confState",
"*",
"raftpb",
".",
"ConfState",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s",
".",
"cluster",
".",
"ValidateConf... | // applyConfChange applies a ConfChange to the server. It is only
// invoked with a ConfChange that has already passed through Raft | [
"applyConfChange",
"applies",
"a",
"ConfChange",
"to",
"the",
"server",
".",
"It",
"is",
"only",
"invoked",
"with",
"a",
"ConfChange",
"that",
"has",
"already",
"passed",
"through",
"Raft"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L2047-L2116 | test |
etcd-io/etcd | etcdserver/server.go | monitorVersions | func (s *EtcdServer) monitorVersions() {
for {
select {
case <-s.forceVersionC:
case <-time.After(monitorVersionInterval):
case <-s.stopping:
return
}
if s.Leader() != s.ID() {
continue
}
v := decideClusterVersion(s.getLogger(), getVersions(s.getLogger(), s.cluster, s.id, s.peerRt))
if v != n... | go | func (s *EtcdServer) monitorVersions() {
for {
select {
case <-s.forceVersionC:
case <-time.After(monitorVersionInterval):
case <-s.stopping:
return
}
if s.Leader() != s.ID() {
continue
}
v := decideClusterVersion(s.getLogger(), getVersions(s.getLogger(), s.cluster, s.id, s.peerRt))
if v != n... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"monitorVersions",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"s",
".",
"forceVersionC",
":",
"case",
"<-",
"time",
".",
"After",
"(",
"monitorVersionInterval",
")",
":",
"case",
"<-",
"s",
".",
... | // monitorVersions checks the member's version every monitorVersionInterval.
// It updates the cluster version if all members agrees on a higher one.
// It prints out log if there is a member with a higher version than the
// local version. | [
"monitorVersions",
"checks",
"the",
"member",
"s",
"version",
"every",
"monitorVersionInterval",
".",
"It",
"updates",
"the",
"cluster",
"version",
"if",
"all",
"members",
"agrees",
"on",
"a",
"higher",
"one",
".",
"It",
"prints",
"out",
"log",
"if",
"there",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L2248-L2288 | test |
etcd-io/etcd | etcdserver/server.go | goAttach | func (s *EtcdServer) goAttach(f func()) {
s.wgMu.RLock() // this blocks with ongoing close(s.stopping)
defer s.wgMu.RUnlock()
select {
case <-s.stopping:
if lg := s.getLogger(); lg != nil {
lg.Warn("server has stopped; skipping goAttach")
} else {
plog.Warning("server has stopped (skipping goAttach)")
}... | go | func (s *EtcdServer) goAttach(f func()) {
s.wgMu.RLock() // this blocks with ongoing close(s.stopping)
defer s.wgMu.RUnlock()
select {
case <-s.stopping:
if lg := s.getLogger(); lg != nil {
lg.Warn("server has stopped; skipping goAttach")
} else {
plog.Warning("server has stopped (skipping goAttach)")
}... | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"goAttach",
"(",
"f",
"func",
"(",
")",
")",
"{",
"s",
".",
"wgMu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"wgMu",
".",
"RUnlock",
"(",
")",
"\n",
"select",
"{",
"case",
"<-",
"s",
".",
"sto... | // goAttach creates a goroutine on a given function and tracks it using
// the etcdserver waitgroup. | [
"goAttach",
"creates",
"a",
"goroutine",
"on",
"a",
"given",
"function",
"and",
"tracks",
"it",
"using",
"the",
"etcdserver",
"waitgroup",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L2408-L2428 | test |
etcd-io/etcd | clientv3/balancer/picker/roundrobin_balanced.go | NewRoundrobinBalanced | func NewRoundrobinBalanced(
lg *zap.Logger,
scs []balancer.SubConn,
addrToSc map[resolver.Address]balancer.SubConn,
scToAddr map[balancer.SubConn]resolver.Address,
) Picker {
return &rrBalanced{
lg: lg,
scs: scs,
addrToSc: addrToSc,
scToAddr: scToAddr,
}
} | go | func NewRoundrobinBalanced(
lg *zap.Logger,
scs []balancer.SubConn,
addrToSc map[resolver.Address]balancer.SubConn,
scToAddr map[balancer.SubConn]resolver.Address,
) Picker {
return &rrBalanced{
lg: lg,
scs: scs,
addrToSc: addrToSc,
scToAddr: scToAddr,
}
} | [
"func",
"NewRoundrobinBalanced",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"scs",
"[",
"]",
"balancer",
".",
"SubConn",
",",
"addrToSc",
"map",
"[",
"resolver",
".",
"Address",
"]",
"balancer",
".",
"SubConn",
",",
"scToAddr",
"map",
"[",
"balancer",
".... | // NewRoundrobinBalanced returns a new roundrobin balanced picker. | [
"NewRoundrobinBalanced",
"returns",
"a",
"new",
"roundrobin",
"balanced",
"picker",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/balancer/picker/roundrobin_balanced.go#L28-L40 | test |
etcd-io/etcd | clientv3/balancer/picker/roundrobin_balanced.go | Pick | func (rb *rrBalanced) Pick(ctx context.Context, opts balancer.PickOptions) (balancer.SubConn, func(balancer.DoneInfo), error) {
rb.mu.RLock()
n := len(rb.scs)
rb.mu.RUnlock()
if n == 0 {
return nil, nil, balancer.ErrNoSubConnAvailable
}
rb.mu.Lock()
cur := rb.next
sc := rb.scs[cur]
picked := rb.scToAddr[sc]... | go | func (rb *rrBalanced) Pick(ctx context.Context, opts balancer.PickOptions) (balancer.SubConn, func(balancer.DoneInfo), error) {
rb.mu.RLock()
n := len(rb.scs)
rb.mu.RUnlock()
if n == 0 {
return nil, nil, balancer.ErrNoSubConnAvailable
}
rb.mu.Lock()
cur := rb.next
sc := rb.scs[cur]
picked := rb.scToAddr[sc]... | [
"func",
"(",
"rb",
"*",
"rrBalanced",
")",
"Pick",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"balancer",
".",
"PickOptions",
")",
"(",
"balancer",
".",
"SubConn",
",",
"func",
"(",
"balancer",
".",
"DoneInfo",
")",
",",
"error",
")",
"{",
"... | // Pick is called for every client request. | [
"Pick",
"is",
"called",
"for",
"every",
"client",
"request",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/balancer/picker/roundrobin_balanced.go#L54-L92 | test |
etcd-io/etcd | pkg/transport/listener_tls.go | NewTLSListener | func NewTLSListener(l net.Listener, tlsinfo *TLSInfo) (net.Listener, error) {
check := func(context.Context, *tls.Conn) error { return nil }
return newTLSListener(l, tlsinfo, check)
} | go | func NewTLSListener(l net.Listener, tlsinfo *TLSInfo) (net.Listener, error) {
check := func(context.Context, *tls.Conn) error { return nil }
return newTLSListener(l, tlsinfo, check)
} | [
"func",
"NewTLSListener",
"(",
"l",
"net",
".",
"Listener",
",",
"tlsinfo",
"*",
"TLSInfo",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"check",
":=",
"func",
"(",
"context",
".",
"Context",
",",
"*",
"tls",
".",
"Conn",
")",
"error",
... | // NewTLSListener handshakes TLS connections and performs optional CRL checking. | [
"NewTLSListener",
"handshakes",
"TLS",
"connections",
"and",
"performs",
"optional",
"CRL",
"checking",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/transport/listener_tls.go#L43-L46 | test |
etcd-io/etcd | pkg/transport/listener_tls.go | acceptLoop | func (l *tlsListener) acceptLoop() {
var wg sync.WaitGroup
var pendingMu sync.Mutex
pending := make(map[net.Conn]struct{})
ctx, cancel := context.WithCancel(context.Background())
defer func() {
cancel()
pendingMu.Lock()
for c := range pending {
c.Close()
}
pendingMu.Unlock()
wg.Wait()
close(l.don... | go | func (l *tlsListener) acceptLoop() {
var wg sync.WaitGroup
var pendingMu sync.Mutex
pending := make(map[net.Conn]struct{})
ctx, cancel := context.WithCancel(context.Background())
defer func() {
cancel()
pendingMu.Lock()
for c := range pending {
c.Close()
}
pendingMu.Unlock()
wg.Wait()
close(l.don... | [
"func",
"(",
"l",
"*",
"tlsListener",
")",
"acceptLoop",
"(",
")",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"var",
"pendingMu",
"sync",
".",
"Mutex",
"\n",
"pending",
":=",
"make",
"(",
"map",
"[",
"net",
".",
"Conn",
"]",
"struct",
"{",
"... | // acceptLoop launches each TLS handshake in a separate goroutine
// to prevent a hanging TLS connection from blocking other connections. | [
"acceptLoop",
"launches",
"each",
"TLS",
"handshake",
"in",
"a",
"separate",
"goroutine",
"to",
"prevent",
"a",
"hanging",
"TLS",
"connection",
"from",
"blocking",
"other",
"connections",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/transport/listener_tls.go#L108-L167 | test |
etcd-io/etcd | clientv3/balancer/resolver/endpoint/endpoint.go | SetEndpoints | func (e *ResolverGroup) SetEndpoints(endpoints []string) {
addrs := epsToAddrs(endpoints...)
e.mu.Lock()
e.endpoints = endpoints
for _, r := range e.resolvers {
r.cc.NewAddress(addrs)
}
e.mu.Unlock()
} | go | func (e *ResolverGroup) SetEndpoints(endpoints []string) {
addrs := epsToAddrs(endpoints...)
e.mu.Lock()
e.endpoints = endpoints
for _, r := range e.resolvers {
r.cc.NewAddress(addrs)
}
e.mu.Unlock()
} | [
"func",
"(",
"e",
"*",
"ResolverGroup",
")",
"SetEndpoints",
"(",
"endpoints",
"[",
"]",
"string",
")",
"{",
"addrs",
":=",
"epsToAddrs",
"(",
"endpoints",
"...",
")",
"\n",
"e",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"e",
".",
"endpoints",
"=",
"... | // SetEndpoints updates the endpoints for ResolverGroup. All registered resolver are updated
// immediately with the new endpoints. | [
"SetEndpoints",
"updates",
"the",
"endpoints",
"for",
"ResolverGroup",
".",
"All",
"registered",
"resolver",
"are",
"updated",
"immediately",
"with",
"the",
"new",
"endpoints",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/balancer/resolver/endpoint/endpoint.go#L82-L90 | test |
etcd-io/etcd | clientv3/balancer/resolver/endpoint/endpoint.go | Target | func (e *ResolverGroup) Target(endpoint string) string {
return Target(e.id, endpoint)
} | go | func (e *ResolverGroup) Target(endpoint string) string {
return Target(e.id, endpoint)
} | [
"func",
"(",
"e",
"*",
"ResolverGroup",
")",
"Target",
"(",
"endpoint",
"string",
")",
"string",
"{",
"return",
"Target",
"(",
"e",
".",
"id",
",",
"endpoint",
")",
"\n",
"}"
] | // Target constructs a endpoint target using the endpoint id of the ResolverGroup. | [
"Target",
"constructs",
"a",
"endpoint",
"target",
"using",
"the",
"endpoint",
"id",
"of",
"the",
"ResolverGroup",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/balancer/resolver/endpoint/endpoint.go#L93-L95 | test |
etcd-io/etcd | clientv3/balancer/resolver/endpoint/endpoint.go | Target | func Target(id, endpoint string) string {
return fmt.Sprintf("%s://%s/%s", scheme, id, endpoint)
} | go | func Target(id, endpoint string) string {
return fmt.Sprintf("%s://%s/%s", scheme, id, endpoint)
} | [
"func",
"Target",
"(",
"id",
",",
"endpoint",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%s://%s/%s\"",
",",
"scheme",
",",
"id",
",",
"endpoint",
")",
"\n",
"}"
] | // Target constructs a endpoint resolver target. | [
"Target",
"constructs",
"a",
"endpoint",
"resolver",
"target",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/balancer/resolver/endpoint/endpoint.go#L98-L100 | test |
etcd-io/etcd | clientv3/balancer/resolver/endpoint/endpoint.go | Build | func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOption) (resolver.Resolver, error) {
if len(target.Authority) < 1 {
return nil, fmt.Errorf("'etcd' target scheme requires non-empty authority identifying etcd cluster being routed to")
}
id := target.Authority
es, err := b.... | go | func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOption) (resolver.Resolver, error) {
if len(target.Authority) < 1 {
return nil, fmt.Errorf("'etcd' target scheme requires non-empty authority identifying etcd cluster being routed to")
}
id := target.Authority
es, err := b.... | [
"func",
"(",
"b",
"*",
"builder",
")",
"Build",
"(",
"target",
"resolver",
".",
"Target",
",",
"cc",
"resolver",
".",
"ClientConn",
",",
"opts",
"resolver",
".",
"BuildOption",
")",
"(",
"resolver",
".",
"Resolver",
",",
"error",
")",
"{",
"if",
"len",... | // Build creates or reuses an etcd resolver for the etcd cluster name identified by the authority part of the target. | [
"Build",
"creates",
"or",
"reuses",
"an",
"etcd",
"resolver",
"for",
"the",
"etcd",
"cluster",
"name",
"identified",
"by",
"the",
"authority",
"part",
"of",
"the",
"target",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/balancer/resolver/endpoint/endpoint.go#L112-L127 | test |
etcd-io/etcd | etcdserver/v2_server.go | Handle | func (r *RequestV2) Handle(ctx context.Context, v2api RequestV2Handler) (Response, error) {
if r.Method == "GET" && r.Quorum {
r.Method = "QGET"
}
switch r.Method {
case "POST":
return v2api.Post(ctx, r)
case "PUT":
return v2api.Put(ctx, r)
case "DELETE":
return v2api.Delete(ctx, r)
case "QGET":
return... | go | func (r *RequestV2) Handle(ctx context.Context, v2api RequestV2Handler) (Response, error) {
if r.Method == "GET" && r.Quorum {
r.Method = "QGET"
}
switch r.Method {
case "POST":
return v2api.Post(ctx, r)
case "PUT":
return v2api.Put(ctx, r)
case "DELETE":
return v2api.Delete(ctx, r)
case "QGET":
return... | [
"func",
"(",
"r",
"*",
"RequestV2",
")",
"Handle",
"(",
"ctx",
"context",
".",
"Context",
",",
"v2api",
"RequestV2Handler",
")",
"(",
"Response",
",",
"error",
")",
"{",
"if",
"r",
".",
"Method",
"==",
"\"GET\"",
"&&",
"r",
".",
"Quorum",
"{",
"r",
... | // Handle interprets r and performs an operation on s.store according to r.Method
// and other fields. If r.Method is "POST", "PUT", "DELETE", or a "GET" with
// Quorum == true, r will be sent through consensus before performing its
// respective operation. Do will block until an action is performed or there is
// an e... | [
"Handle",
"interprets",
"r",
"and",
"performs",
"an",
"operation",
"on",
"s",
".",
"store",
"according",
"to",
"r",
".",
"Method",
"and",
"other",
"fields",
".",
"If",
"r",
".",
"Method",
"is",
"POST",
"PUT",
"DELETE",
"or",
"a",
"GET",
"with",
"Quorum... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/v2_server.go#L141-L160 | test |
etcd-io/etcd | functional/runner/election_command.go | NewElectionCommand | func NewElectionCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "election [election name (defaults to 'elector')]",
Short: "Performs election operation",
Run: runElectionFunc,
}
cmd.Flags().IntVar(&totalClientConnections, "total-client-connections", 10, "total number of client connections")
return ... | go | func NewElectionCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "election [election name (defaults to 'elector')]",
Short: "Performs election operation",
Run: runElectionFunc,
}
cmd.Flags().IntVar(&totalClientConnections, "total-client-connections", 10, "total number of client connections")
return ... | [
"func",
"NewElectionCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"election [election name (defaults to 'elector')]\"",
",",
"Short",
":",
"\"Performs election operation\"",
",",
"Run",
":",
"r... | // NewElectionCommand returns the cobra command for "election runner". | [
"NewElectionCommand",
"returns",
"the",
"cobra",
"command",
"for",
"election",
"runner",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/runner/election_command.go#L28-L36 | test |
etcd-io/etcd | etcdserver/api/membership/store.go | nodeToMember | func nodeToMember(n *v2store.NodeExtern) (*Member, error) {
m := &Member{ID: MustParseMemberIDFromKey(n.Key)}
attrs := make(map[string][]byte)
raftAttrKey := path.Join(n.Key, raftAttributesSuffix)
attrKey := path.Join(n.Key, attributesSuffix)
for _, nn := range n.Nodes {
if nn.Key != raftAttrKey && nn.Key != att... | go | func nodeToMember(n *v2store.NodeExtern) (*Member, error) {
m := &Member{ID: MustParseMemberIDFromKey(n.Key)}
attrs := make(map[string][]byte)
raftAttrKey := path.Join(n.Key, raftAttributesSuffix)
attrKey := path.Join(n.Key, attributesSuffix)
for _, nn := range n.Nodes {
if nn.Key != raftAttrKey && nn.Key != att... | [
"func",
"nodeToMember",
"(",
"n",
"*",
"v2store",
".",
"NodeExtern",
")",
"(",
"*",
"Member",
",",
"error",
")",
"{",
"m",
":=",
"&",
"Member",
"{",
"ID",
":",
"MustParseMemberIDFromKey",
"(",
"n",
".",
"Key",
")",
"}",
"\n",
"attrs",
":=",
"make",
... | // nodeToMember builds member from a key value node.
// the child nodes of the given node MUST be sorted by key. | [
"nodeToMember",
"builds",
"member",
"from",
"a",
"key",
"value",
"node",
".",
"the",
"child",
"nodes",
"of",
"the",
"given",
"node",
"MUST",
"be",
"sorted",
"by",
"key",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/membership/store.go#L128-L152 | test |
etcd-io/etcd | mvcc/backend/backend.go | NewTmpBackend | func NewTmpBackend(batchInterval time.Duration, batchLimit int) (*backend, string) {
dir, err := ioutil.TempDir(os.TempDir(), "etcd_backend_test")
if err != nil {
panic(err)
}
tmpPath := filepath.Join(dir, "database")
bcfg := DefaultBackendConfig()
bcfg.Path, bcfg.BatchInterval, bcfg.BatchLimit = tmpPath, batch... | go | func NewTmpBackend(batchInterval time.Duration, batchLimit int) (*backend, string) {
dir, err := ioutil.TempDir(os.TempDir(), "etcd_backend_test")
if err != nil {
panic(err)
}
tmpPath := filepath.Join(dir, "database")
bcfg := DefaultBackendConfig()
bcfg.Path, bcfg.BatchInterval, bcfg.BatchLimit = tmpPath, batch... | [
"func",
"NewTmpBackend",
"(",
"batchInterval",
"time",
".",
"Duration",
",",
"batchLimit",
"int",
")",
"(",
"*",
"backend",
",",
"string",
")",
"{",
"dir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"os",
".",
"TempDir",
"(",
")",
",",
"\"etcd_ba... | // NewTmpBackend creates a backend implementation for testing. | [
"NewTmpBackend",
"creates",
"a",
"backend",
"implementation",
"for",
"testing",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/backend.go#L513-L522 | test |
etcd-io/etcd | etcdserver/api/v3compactor/revision.go | newRevision | func newRevision(lg *zap.Logger, clock clockwork.Clock, retention int64, rg RevGetter, c Compactable) *Revision {
rc := &Revision{
lg: lg,
clock: clock,
retention: retention,
rg: rg,
c: c,
}
rc.ctx, rc.cancel = context.WithCancel(context.Background())
return rc
} | go | func newRevision(lg *zap.Logger, clock clockwork.Clock, retention int64, rg RevGetter, c Compactable) *Revision {
rc := &Revision{
lg: lg,
clock: clock,
retention: retention,
rg: rg,
c: c,
}
rc.ctx, rc.cancel = context.WithCancel(context.Background())
return rc
} | [
"func",
"newRevision",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"clock",
"clockwork",
".",
"Clock",
",",
"retention",
"int64",
",",
"rg",
"RevGetter",
",",
"c",
"Compactable",
")",
"*",
"Revision",
"{",
"rc",
":=",
"&",
"Revision",
"{",
"lg",
":",
... | // newRevision creates a new instance of Revisonal compactor that purges
// the log older than retention revisions from the current revision. | [
"newRevision",
"creates",
"a",
"new",
"instance",
"of",
"Revisonal",
"compactor",
"that",
"purges",
"the",
"log",
"older",
"than",
"retention",
"revisions",
"from",
"the",
"current",
"revision",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3compactor/revision.go#L49-L59 | test |
etcd-io/etcd | etcdserver/api/v3compactor/revision.go | Run | func (rc *Revision) Run() {
prev := int64(0)
go func() {
for {
select {
case <-rc.ctx.Done():
return
case <-rc.clock.After(revInterval):
rc.mu.Lock()
p := rc.paused
rc.mu.Unlock()
if p {
continue
}
}
rev := rc.rg.Rev() - rc.retention
if rev <= 0 || rev == prev {
c... | go | func (rc *Revision) Run() {
prev := int64(0)
go func() {
for {
select {
case <-rc.ctx.Done():
return
case <-rc.clock.After(revInterval):
rc.mu.Lock()
p := rc.paused
rc.mu.Unlock()
if p {
continue
}
}
rev := rc.rg.Rev() - rc.retention
if rev <= 0 || rev == prev {
c... | [
"func",
"(",
"rc",
"*",
"Revision",
")",
"Run",
"(",
")",
"{",
"prev",
":=",
"int64",
"(",
"0",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"rc",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"\n",
"... | // Run runs revision-based compactor. | [
"Run",
"runs",
"revision",
"-",
"based",
"compactor",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3compactor/revision.go#L64-L124 | test |
etcd-io/etcd | etcdserver/api/v3compactor/revision.go | Pause | func (rc *Revision) Pause() {
rc.mu.Lock()
rc.paused = true
rc.mu.Unlock()
} | go | func (rc *Revision) Pause() {
rc.mu.Lock()
rc.paused = true
rc.mu.Unlock()
} | [
"func",
"(",
"rc",
"*",
"Revision",
")",
"Pause",
"(",
")",
"{",
"rc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"rc",
".",
"paused",
"=",
"true",
"\n",
"rc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Pause pauses revision-based compactor. | [
"Pause",
"pauses",
"revision",
"-",
"based",
"compactor",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3compactor/revision.go#L132-L136 | test |
etcd-io/etcd | etcdserver/api/v3compactor/revision.go | Resume | func (rc *Revision) Resume() {
rc.mu.Lock()
rc.paused = false
rc.mu.Unlock()
} | go | func (rc *Revision) Resume() {
rc.mu.Lock()
rc.paused = false
rc.mu.Unlock()
} | [
"func",
"(",
"rc",
"*",
"Revision",
")",
"Resume",
"(",
")",
"{",
"rc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"rc",
".",
"paused",
"=",
"false",
"\n",
"rc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Resume resumes revision-based compactor. | [
"Resume",
"resumes",
"revision",
"-",
"based",
"compactor",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3compactor/revision.go#L139-L143 | test |
etcd-io/etcd | raft/util.go | voteRespMsgType | func voteRespMsgType(msgt pb.MessageType) pb.MessageType {
switch msgt {
case pb.MsgVote:
return pb.MsgVoteResp
case pb.MsgPreVote:
return pb.MsgPreVoteResp
default:
panic(fmt.Sprintf("not a vote message: %s", msgt))
}
} | go | func voteRespMsgType(msgt pb.MessageType) pb.MessageType {
switch msgt {
case pb.MsgVote:
return pb.MsgVoteResp
case pb.MsgPreVote:
return pb.MsgPreVoteResp
default:
panic(fmt.Sprintf("not a vote message: %s", msgt))
}
} | [
"func",
"voteRespMsgType",
"(",
"msgt",
"pb",
".",
"MessageType",
")",
"pb",
".",
"MessageType",
"{",
"switch",
"msgt",
"{",
"case",
"pb",
".",
"MsgVote",
":",
"return",
"pb",
".",
"MsgVoteResp",
"\n",
"case",
"pb",
".",
"MsgPreVote",
":",
"return",
"pb"... | // voteResponseType maps vote and prevote message types to their corresponding responses. | [
"voteResponseType",
"maps",
"vote",
"and",
"prevote",
"message",
"types",
"to",
"their",
"corresponding",
"responses",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/util.go#L59-L68 | test |
etcd-io/etcd | raft/util.go | DescribeMessage | func DescribeMessage(m pb.Message, f EntryFormatter) string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "%x->%x %v Term:%d Log:%d/%d", m.From, m.To, m.Type, m.Term, m.LogTerm, m.Index)
if m.Reject {
fmt.Fprintf(&buf, " Rejected (Hint: %d)", m.RejectHint)
}
if m.Commit != 0 {
fmt.Fprintf(&buf, " Commit:%d", m.Comm... | go | func DescribeMessage(m pb.Message, f EntryFormatter) string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "%x->%x %v Term:%d Log:%d/%d", m.From, m.To, m.Type, m.Term, m.LogTerm, m.Index)
if m.Reject {
fmt.Fprintf(&buf, " Rejected (Hint: %d)", m.RejectHint)
}
if m.Commit != 0 {
fmt.Fprintf(&buf, " Commit:%d", m.Comm... | [
"func",
"DescribeMessage",
"(",
"m",
"pb",
".",
"Message",
",",
"f",
"EntryFormatter",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"fmt",
".",
"Fprintf",
"(",
"&",
"buf",
",",
"\"%x->%x %v Term:%d Log:%d/%d\"",
",",
"m",
".",
"From",
... | // DescribeMessage returns a concise human-readable description of a
// Message for debugging. | [
"DescribeMessage",
"returns",
"a",
"concise",
"human",
"-",
"readable",
"description",
"of",
"a",
"Message",
"for",
"debugging",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/util.go#L76-L99 | test |
etcd-io/etcd | raft/util.go | DescribeEntry | func DescribeEntry(e pb.Entry, f EntryFormatter) string {
var formatted string
if e.Type == pb.EntryNormal && f != nil {
formatted = f(e.Data)
} else {
formatted = fmt.Sprintf("%q", e.Data)
}
return fmt.Sprintf("%d/%d %s %s", e.Term, e.Index, e.Type, formatted)
} | go | func DescribeEntry(e pb.Entry, f EntryFormatter) string {
var formatted string
if e.Type == pb.EntryNormal && f != nil {
formatted = f(e.Data)
} else {
formatted = fmt.Sprintf("%q", e.Data)
}
return fmt.Sprintf("%d/%d %s %s", e.Term, e.Index, e.Type, formatted)
} | [
"func",
"DescribeEntry",
"(",
"e",
"pb",
".",
"Entry",
",",
"f",
"EntryFormatter",
")",
"string",
"{",
"var",
"formatted",
"string",
"\n",
"if",
"e",
".",
"Type",
"==",
"pb",
".",
"EntryNormal",
"&&",
"f",
"!=",
"nil",
"{",
"formatted",
"=",
"f",
"("... | // DescribeEntry returns a concise human-readable description of an
// Entry for debugging. | [
"DescribeEntry",
"returns",
"a",
"concise",
"human",
"-",
"readable",
"description",
"of",
"an",
"Entry",
"for",
"debugging",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/util.go#L109-L117 | test |
etcd-io/etcd | raft/util.go | DescribeEntries | func DescribeEntries(ents []pb.Entry, f EntryFormatter) string {
var buf bytes.Buffer
for _, e := range ents {
_, _ = buf.WriteString(DescribeEntry(e, f) + "\n")
}
return buf.String()
} | go | func DescribeEntries(ents []pb.Entry, f EntryFormatter) string {
var buf bytes.Buffer
for _, e := range ents {
_, _ = buf.WriteString(DescribeEntry(e, f) + "\n")
}
return buf.String()
} | [
"func",
"DescribeEntries",
"(",
"ents",
"[",
"]",
"pb",
".",
"Entry",
",",
"f",
"EntryFormatter",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"ents",
"{",
"_",
",",
"_",
"=",
"buf",
".",
"W... | // DescribeEntries calls DescribeEntry for each Entry, adding a newline to
// each. | [
"DescribeEntries",
"calls",
"DescribeEntry",
"for",
"each",
"Entry",
"adding",
"a",
"newline",
"to",
"each",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/util.go#L121-L127 | test |
etcd-io/etcd | clientv3/logger.go | SetLogger | func SetLogger(l grpclog.LoggerV2) {
lgMu.Lock()
lg = logutil.NewLogger(l)
// override grpclog so that any changes happen with locking
grpclog.SetLoggerV2(lg)
lgMu.Unlock()
} | go | func SetLogger(l grpclog.LoggerV2) {
lgMu.Lock()
lg = logutil.NewLogger(l)
// override grpclog so that any changes happen with locking
grpclog.SetLoggerV2(lg)
lgMu.Unlock()
} | [
"func",
"SetLogger",
"(",
"l",
"grpclog",
".",
"LoggerV2",
")",
"{",
"lgMu",
".",
"Lock",
"(",
")",
"\n",
"lg",
"=",
"logutil",
".",
"NewLogger",
"(",
"l",
")",
"\n",
"grpclog",
".",
"SetLoggerV2",
"(",
"lg",
")",
"\n",
"lgMu",
".",
"Unlock",
"(",
... | // SetLogger sets client-side Logger. | [
"SetLogger",
"sets",
"client",
"-",
"side",
"Logger",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/logger.go#L43-L49 | test |
etcd-io/etcd | clientv3/logger.go | GetLogger | func GetLogger() logutil.Logger {
lgMu.RLock()
l := lg
lgMu.RUnlock()
return l
} | go | func GetLogger() logutil.Logger {
lgMu.RLock()
l := lg
lgMu.RUnlock()
return l
} | [
"func",
"GetLogger",
"(",
")",
"logutil",
".",
"Logger",
"{",
"lgMu",
".",
"RLock",
"(",
")",
"\n",
"l",
":=",
"lg",
"\n",
"lgMu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"l",
"\n",
"}"
] | // GetLogger returns the current logutil.Logger. | [
"GetLogger",
"returns",
"the",
"current",
"logutil",
".",
"Logger",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/logger.go#L52-L57 | test |
etcd-io/etcd | raft/log_unstable.go | maybeFirstIndex | func (u *unstable) maybeFirstIndex() (uint64, bool) {
if u.snapshot != nil {
return u.snapshot.Metadata.Index + 1, true
}
return 0, false
} | go | func (u *unstable) maybeFirstIndex() (uint64, bool) {
if u.snapshot != nil {
return u.snapshot.Metadata.Index + 1, true
}
return 0, false
} | [
"func",
"(",
"u",
"*",
"unstable",
")",
"maybeFirstIndex",
"(",
")",
"(",
"uint64",
",",
"bool",
")",
"{",
"if",
"u",
".",
"snapshot",
"!=",
"nil",
"{",
"return",
"u",
".",
"snapshot",
".",
"Metadata",
".",
"Index",
"+",
"1",
",",
"true",
"\n",
"... | // maybeFirstIndex returns the index of the first possible entry in entries
// if it has a snapshot. | [
"maybeFirstIndex",
"returns",
"the",
"index",
"of",
"the",
"first",
"possible",
"entry",
"in",
"entries",
"if",
"it",
"has",
"a",
"snapshot",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log_unstable.go#L35-L40 | test |
etcd-io/etcd | raft/log_unstable.go | maybeLastIndex | func (u *unstable) maybeLastIndex() (uint64, bool) {
if l := len(u.entries); l != 0 {
return u.offset + uint64(l) - 1, true
}
if u.snapshot != nil {
return u.snapshot.Metadata.Index, true
}
return 0, false
} | go | func (u *unstable) maybeLastIndex() (uint64, bool) {
if l := len(u.entries); l != 0 {
return u.offset + uint64(l) - 1, true
}
if u.snapshot != nil {
return u.snapshot.Metadata.Index, true
}
return 0, false
} | [
"func",
"(",
"u",
"*",
"unstable",
")",
"maybeLastIndex",
"(",
")",
"(",
"uint64",
",",
"bool",
")",
"{",
"if",
"l",
":=",
"len",
"(",
"u",
".",
"entries",
")",
";",
"l",
"!=",
"0",
"{",
"return",
"u",
".",
"offset",
"+",
"uint64",
"(",
"l",
... | // maybeLastIndex returns the last index if it has at least one
// unstable entry or snapshot. | [
"maybeLastIndex",
"returns",
"the",
"last",
"index",
"if",
"it",
"has",
"at",
"least",
"one",
"unstable",
"entry",
"or",
"snapshot",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log_unstable.go#L44-L52 | test |
etcd-io/etcd | raft/log_unstable.go | maybeTerm | func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
if i < u.offset {
if u.snapshot == nil {
return 0, false
}
if u.snapshot.Metadata.Index == i {
return u.snapshot.Metadata.Term, true
}
return 0, false
}
last, ok := u.maybeLastIndex()
if !ok {
return 0, false
}
if i > last {
return 0, fa... | go | func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
if i < u.offset {
if u.snapshot == nil {
return 0, false
}
if u.snapshot.Metadata.Index == i {
return u.snapshot.Metadata.Term, true
}
return 0, false
}
last, ok := u.maybeLastIndex()
if !ok {
return 0, false
}
if i > last {
return 0, fa... | [
"func",
"(",
"u",
"*",
"unstable",
")",
"maybeTerm",
"(",
"i",
"uint64",
")",
"(",
"uint64",
",",
"bool",
")",
"{",
"if",
"i",
"<",
"u",
".",
"offset",
"{",
"if",
"u",
".",
"snapshot",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
... | // maybeTerm returns the term of the entry at index i, if there
// is any. | [
"maybeTerm",
"returns",
"the",
"term",
"of",
"the",
"entry",
"at",
"index",
"i",
"if",
"there",
"is",
"any",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log_unstable.go#L56-L75 | test |
etcd-io/etcd | raft/log_unstable.go | shrinkEntriesArray | func (u *unstable) shrinkEntriesArray() {
// We replace the array if we're using less than half of the space in
// it. This number is fairly arbitrary, chosen as an attempt to balance
// memory usage vs number of allocations. It could probably be improved
// with some focused tuning.
const lenMultiple = 2
if len(... | go | func (u *unstable) shrinkEntriesArray() {
// We replace the array if we're using less than half of the space in
// it. This number is fairly arbitrary, chosen as an attempt to balance
// memory usage vs number of allocations. It could probably be improved
// with some focused tuning.
const lenMultiple = 2
if len(... | [
"func",
"(",
"u",
"*",
"unstable",
")",
"shrinkEntriesArray",
"(",
")",
"{",
"const",
"lenMultiple",
"=",
"2",
"\n",
"if",
"len",
"(",
"u",
".",
"entries",
")",
"==",
"0",
"{",
"u",
".",
"entries",
"=",
"nil",
"\n",
"}",
"else",
"if",
"len",
"(",... | // shrinkEntriesArray discards the underlying array used by the entries slice
// if most of it isn't being used. This avoids holding references to a bunch of
// potentially large entries that aren't needed anymore. Simply clearing the
// entries wouldn't be safe because clients might still be using them. | [
"shrinkEntriesArray",
"discards",
"the",
"underlying",
"array",
"used",
"by",
"the",
"entries",
"slice",
"if",
"most",
"of",
"it",
"isn",
"t",
"being",
"used",
".",
"This",
"avoids",
"holding",
"references",
"to",
"a",
"bunch",
"of",
"potentially",
"large",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log_unstable.go#L96-L109 | test |
etcd-io/etcd | etcdserver/storage.go | SaveSnap | func (st *storage) SaveSnap(snap raftpb.Snapshot) error {
walsnap := walpb.Snapshot{
Index: snap.Metadata.Index,
Term: snap.Metadata.Term,
}
err := st.WAL.SaveSnapshot(walsnap)
if err != nil {
return err
}
err = st.Snapshotter.SaveSnap(snap)
if err != nil {
return err
}
return st.WAL.ReleaseLockTo(sna... | go | func (st *storage) SaveSnap(snap raftpb.Snapshot) error {
walsnap := walpb.Snapshot{
Index: snap.Metadata.Index,
Term: snap.Metadata.Term,
}
err := st.WAL.SaveSnapshot(walsnap)
if err != nil {
return err
}
err = st.Snapshotter.SaveSnap(snap)
if err != nil {
return err
}
return st.WAL.ReleaseLockTo(sna... | [
"func",
"(",
"st",
"*",
"storage",
")",
"SaveSnap",
"(",
"snap",
"raftpb",
".",
"Snapshot",
")",
"error",
"{",
"walsnap",
":=",
"walpb",
".",
"Snapshot",
"{",
"Index",
":",
"snap",
".",
"Metadata",
".",
"Index",
",",
"Term",
":",
"snap",
".",
"Metada... | // SaveSnap saves the snapshot to disk and release the locked
// wal files since they will not be used. | [
"SaveSnap",
"saves",
"the",
"snapshot",
"to",
"disk",
"and",
"release",
"the",
"locked",
"wal",
"files",
"since",
"they",
"will",
"not",
"be",
"used",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/storage.go#L52-L66 | test |
etcd-io/etcd | clientv3/client.go | New | func New(cfg Config) (*Client, error) {
if len(cfg.Endpoints) == 0 {
return nil, ErrNoAvailableEndpoints
}
return newClient(&cfg)
} | go | func New(cfg Config) (*Client, error) {
if len(cfg.Endpoints) == 0 {
return nil, ErrNoAvailableEndpoints
}
return newClient(&cfg)
} | [
"func",
"New",
"(",
"cfg",
"Config",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"len",
"(",
"cfg",
".",
"Endpoints",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrNoAvailableEndpoints",
"\n",
"}",
"\n",
"return",
"newClient",
"(",
"&",
... | // New creates a new etcdv3 client from a given configuration. | [
"New",
"creates",
"a",
"new",
"etcdv3",
"client",
"from",
"a",
"given",
"configuration",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L100-L106 | test |
etcd-io/etcd | clientv3/client.go | NewCtxClient | func NewCtxClient(ctx context.Context) *Client {
cctx, cancel := context.WithCancel(ctx)
return &Client{ctx: cctx, cancel: cancel}
} | go | func NewCtxClient(ctx context.Context) *Client {
cctx, cancel := context.WithCancel(ctx)
return &Client{ctx: cctx, cancel: cancel}
} | [
"func",
"NewCtxClient",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"Client",
"{",
"cctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"return",
"&",
"Client",
"{",
"ctx",
":",
"cctx",
",",
"cancel",
":",
"cancel",
... | // NewCtxClient creates a client with a context but no underlying grpc
// connection. This is useful for embedded cases that override the
// service interface implementations and do not need connection management. | [
"NewCtxClient",
"creates",
"a",
"client",
"with",
"a",
"context",
"but",
"no",
"underlying",
"grpc",
"connection",
".",
"This",
"is",
"useful",
"for",
"embedded",
"cases",
"that",
"override",
"the",
"service",
"interface",
"implementations",
"and",
"do",
"not",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L111-L114 | test |
etcd-io/etcd | clientv3/client.go | NewFromURL | func NewFromURL(url string) (*Client, error) {
return New(Config{Endpoints: []string{url}})
} | go | func NewFromURL(url string) (*Client, error) {
return New(Config{Endpoints: []string{url}})
} | [
"func",
"NewFromURL",
"(",
"url",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"return",
"New",
"(",
"Config",
"{",
"Endpoints",
":",
"[",
"]",
"string",
"{",
"url",
"}",
"}",
")",
"\n",
"}"
] | // NewFromURL creates a new etcdv3 client from a URL. | [
"NewFromURL",
"creates",
"a",
"new",
"etcdv3",
"client",
"from",
"a",
"URL",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L117-L119 | test |
etcd-io/etcd | clientv3/client.go | Close | func (c *Client) Close() error {
c.cancel()
c.Watcher.Close()
c.Lease.Close()
if c.resolverGroup != nil {
c.resolverGroup.Close()
}
if c.conn != nil {
return toErr(c.ctx, c.conn.Close())
}
return c.ctx.Err()
} | go | func (c *Client) Close() error {
c.cancel()
c.Watcher.Close()
c.Lease.Close()
if c.resolverGroup != nil {
c.resolverGroup.Close()
}
if c.conn != nil {
return toErr(c.ctx, c.conn.Close())
}
return c.ctx.Err()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Close",
"(",
")",
"error",
"{",
"c",
".",
"cancel",
"(",
")",
"\n",
"c",
".",
"Watcher",
".",
"Close",
"(",
")",
"\n",
"c",
".",
"Lease",
".",
"Close",
"(",
")",
"\n",
"if",
"c",
".",
"resolverGroup",
"!... | // Close shuts down the client's etcd connections. | [
"Close",
"shuts",
"down",
"the",
"client",
"s",
"etcd",
"connections",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L127-L138 | test |
etcd-io/etcd | clientv3/client.go | Endpoints | func (c *Client) Endpoints() []string {
// copy the slice; protect original endpoints from being changed
c.mu.RLock()
defer c.mu.RUnlock()
eps := make([]string, len(c.cfg.Endpoints))
copy(eps, c.cfg.Endpoints)
return eps
} | go | func (c *Client) Endpoints() []string {
// copy the slice; protect original endpoints from being changed
c.mu.RLock()
defer c.mu.RUnlock()
eps := make([]string, len(c.cfg.Endpoints))
copy(eps, c.cfg.Endpoints)
return eps
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Endpoints",
"(",
")",
"[",
"]",
"string",
"{",
"c",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"eps",
":=",
"make",
"(",
"[",
"]",
"string",
",",
... | // Endpoints lists the registered endpoints for the client. | [
"Endpoints",
"lists",
"the",
"registered",
"endpoints",
"for",
"the",
"client",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L146-L153 | test |
etcd-io/etcd | clientv3/client.go | SetEndpoints | func (c *Client) SetEndpoints(eps ...string) {
c.mu.Lock()
defer c.mu.Unlock()
c.cfg.Endpoints = eps
c.resolverGroup.SetEndpoints(eps)
} | go | func (c *Client) SetEndpoints(eps ...string) {
c.mu.Lock()
defer c.mu.Unlock()
c.cfg.Endpoints = eps
c.resolverGroup.SetEndpoints(eps)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetEndpoints",
"(",
"eps",
"...",
"string",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"cfg",
".",
"Endpoints",
"=",
"eps",
"... | // SetEndpoints updates client's endpoints. | [
"SetEndpoints",
"updates",
"client",
"s",
"endpoints",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L156-L161 | test |
etcd-io/etcd | clientv3/client.go | Sync | func (c *Client) Sync(ctx context.Context) error {
mresp, err := c.MemberList(ctx)
if err != nil {
return err
}
var eps []string
for _, m := range mresp.Members {
eps = append(eps, m.ClientURLs...)
}
c.SetEndpoints(eps...)
return nil
} | go | func (c *Client) Sync(ctx context.Context) error {
mresp, err := c.MemberList(ctx)
if err != nil {
return err
}
var eps []string
for _, m := range mresp.Members {
eps = append(eps, m.ClientURLs...)
}
c.SetEndpoints(eps...)
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Sync",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"mresp",
",",
"err",
":=",
"c",
".",
"MemberList",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"... | // Sync synchronizes client's endpoints with the known endpoints from the etcd membership. | [
"Sync",
"synchronizes",
"client",
"s",
"endpoints",
"with",
"the",
"known",
"endpoints",
"from",
"the",
"etcd",
"membership",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L164-L175 | test |
etcd-io/etcd | clientv3/client.go | dialSetupOpts | func (c *Client) dialSetupOpts(creds *credentials.TransportCredentials, dopts ...grpc.DialOption) (opts []grpc.DialOption, err error) {
if c.cfg.DialKeepAliveTime > 0 {
params := keepalive.ClientParameters{
Time: c.cfg.DialKeepAliveTime,
Timeout: c.cfg.DialKeepAliveTimeout,
Permit... | go | func (c *Client) dialSetupOpts(creds *credentials.TransportCredentials, dopts ...grpc.DialOption) (opts []grpc.DialOption, err error) {
if c.cfg.DialKeepAliveTime > 0 {
params := keepalive.ClientParameters{
Time: c.cfg.DialKeepAliveTime,
Timeout: c.cfg.DialKeepAliveTimeout,
Permit... | [
"func",
"(",
"c",
"*",
"Client",
")",
"dialSetupOpts",
"(",
"creds",
"*",
"credentials",
".",
"TransportCredentials",
",",
"dopts",
"...",
"grpc",
".",
"DialOption",
")",
"(",
"opts",
"[",
"]",
"grpc",
".",
"DialOption",
",",
"err",
"error",
")",
"{",
... | // dialSetupOpts gives the dial opts prior to any authentication. | [
"dialSetupOpts",
"gives",
"the",
"dial",
"opts",
"prior",
"to",
"any",
"authentication",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L234-L277 | test |
etcd-io/etcd | clientv3/client.go | Dial | func (c *Client) Dial(ep string) (*grpc.ClientConn, error) {
creds := c.directDialCreds(ep)
// Use the grpc passthrough resolver to directly dial a single endpoint.
// This resolver passes through the 'unix' and 'unixs' endpoints schemes used
// by etcd without modification, allowing us to directly dial endpoints a... | go | func (c *Client) Dial(ep string) (*grpc.ClientConn, error) {
creds := c.directDialCreds(ep)
// Use the grpc passthrough resolver to directly dial a single endpoint.
// This resolver passes through the 'unix' and 'unixs' endpoints schemes used
// by etcd without modification, allowing us to directly dial endpoints a... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Dial",
"(",
"ep",
"string",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"creds",
":=",
"c",
".",
"directDialCreds",
"(",
"ep",
")",
"\n",
"return",
"c",
".",
"dial",
"(",
"fmt",
".",
... | // Dial connects to a single endpoint using the client's config. | [
"Dial",
"connects",
"to",
"a",
"single",
"endpoint",
"using",
"the",
"client",
"s",
"config",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L280-L287 | test |
etcd-io/etcd | clientv3/client.go | dialWithBalancer | func (c *Client) dialWithBalancer(ep string, dopts ...grpc.DialOption) (*grpc.ClientConn, error) {
_, host, _ := endpoint.ParseEndpoint(ep)
target := c.resolverGroup.Target(host)
creds := c.dialWithBalancerCreds(ep)
return c.dial(target, creds, dopts...)
} | go | func (c *Client) dialWithBalancer(ep string, dopts ...grpc.DialOption) (*grpc.ClientConn, error) {
_, host, _ := endpoint.ParseEndpoint(ep)
target := c.resolverGroup.Target(host)
creds := c.dialWithBalancerCreds(ep)
return c.dial(target, creds, dopts...)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"dialWithBalancer",
"(",
"ep",
"string",
",",
"dopts",
"...",
"grpc",
".",
"DialOption",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"_",
",",
"host",
",",
"_",
":=",
"endpoint",
".",
"Par... | // dialWithBalancer dials the client's current load balanced resolver group. The scheme of the host
// of the provided endpoint determines the scheme used for all endpoints of the client connection. | [
"dialWithBalancer",
"dials",
"the",
"client",
"s",
"current",
"load",
"balanced",
"resolver",
"group",
".",
"The",
"scheme",
"of",
"the",
"host",
"of",
"the",
"provided",
"endpoint",
"determines",
"the",
"scheme",
"used",
"for",
"all",
"endpoints",
"of",
"the"... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L334-L339 | test |
etcd-io/etcd | clientv3/client.go | dial | func (c *Client) dial(target string, creds *credentials.TransportCredentials, dopts ...grpc.DialOption) (*grpc.ClientConn, error) {
opts, err := c.dialSetupOpts(creds, dopts...)
if err != nil {
return nil, fmt.Errorf("failed to configure dialer: %v", err)
}
if c.Username != "" && c.Password != "" {
c.tokenCred... | go | func (c *Client) dial(target string, creds *credentials.TransportCredentials, dopts ...grpc.DialOption) (*grpc.ClientConn, error) {
opts, err := c.dialSetupOpts(creds, dopts...)
if err != nil {
return nil, fmt.Errorf("failed to configure dialer: %v", err)
}
if c.Username != "" && c.Password != "" {
c.tokenCred... | [
"func",
"(",
"c",
"*",
"Client",
")",
"dial",
"(",
"target",
"string",
",",
"creds",
"*",
"credentials",
".",
"TransportCredentials",
",",
"dopts",
"...",
"grpc",
".",
"DialOption",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"opt... | // dial configures and dials any grpc balancer target. | [
"dial",
"configures",
"and",
"dials",
"any",
"grpc",
"balancer",
"target",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L342-L387 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.