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 | integration/cluster.go | HTTPMembers | func (c *cluster) HTTPMembers() []client.Member {
ms := []client.Member{}
for _, m := range c.Members {
pScheme := schemeFromTLSInfo(m.PeerTLSInfo)
cScheme := schemeFromTLSInfo(m.ClientTLSInfo)
cm := client.Member{Name: m.Name}
for _, ln := range m.PeerListeners {
cm.PeerURLs = append(cm.PeerURLs, pScheme+... | go | func (c *cluster) HTTPMembers() []client.Member {
ms := []client.Member{}
for _, m := range c.Members {
pScheme := schemeFromTLSInfo(m.PeerTLSInfo)
cScheme := schemeFromTLSInfo(m.ClientTLSInfo)
cm := client.Member{Name: m.Name}
for _, ln := range m.PeerListeners {
cm.PeerURLs = append(cm.PeerURLs, pScheme+... | [
"func",
"(",
"c",
"*",
"cluster",
")",
"HTTPMembers",
"(",
")",
"[",
"]",
"client",
".",
"Member",
"{",
"ms",
":=",
"[",
"]",
"client",
".",
"Member",
"{",
"}",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"c",
".",
"Members",
"{",
"pScheme",
":=... | // HTTPMembers returns a list of all active members as client.Members | [
"HTTPMembers",
"returns",
"a",
"list",
"of",
"all",
"active",
"members",
"as",
"client",
".",
"Members"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L261-L276 | test |
etcd-io/etcd | integration/cluster.go | waitLeader | func (c *cluster) waitLeader(t testing.TB, membs []*member) int {
possibleLead := make(map[uint64]bool)
var lead uint64
for _, m := range membs {
possibleLead[uint64(m.s.ID())] = true
}
cc := MustNewHTTPClient(t, getMembersURLs(membs), nil)
kapi := client.NewKeysAPI(cc)
// ensure leader is up via linearizable... | go | func (c *cluster) waitLeader(t testing.TB, membs []*member) int {
possibleLead := make(map[uint64]bool)
var lead uint64
for _, m := range membs {
possibleLead[uint64(m.s.ID())] = true
}
cc := MustNewHTTPClient(t, getMembersURLs(membs), nil)
kapi := client.NewKeysAPI(cc)
// ensure leader is up via linearizable... | [
"func",
"(",
"c",
"*",
"cluster",
")",
"waitLeader",
"(",
"t",
"testing",
".",
"TB",
",",
"membs",
"[",
"]",
"*",
"member",
")",
"int",
"{",
"possibleLead",
":=",
"make",
"(",
"map",
"[",
"uint64",
"]",
"bool",
")",
"\n",
"var",
"lead",
"uint64",
... | // waitLeader waits until given members agree on the same leader. | [
"waitLeader",
"waits",
"until",
"given",
"members",
"agree",
"on",
"the",
"same",
"leader",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L427-L470 | test |
etcd-io/etcd | integration/cluster.go | waitNoLeader | func (c *cluster) waitNoLeader(membs []*member) {
noLeader := false
for !noLeader {
noLeader = true
for _, m := range membs {
select {
case <-m.s.StopNotify():
continue
default:
}
if m.s.Lead() != 0 {
noLeader = false
time.Sleep(10 * tickDuration)
break
}
}
}
} | go | func (c *cluster) waitNoLeader(membs []*member) {
noLeader := false
for !noLeader {
noLeader = true
for _, m := range membs {
select {
case <-m.s.StopNotify():
continue
default:
}
if m.s.Lead() != 0 {
noLeader = false
time.Sleep(10 * tickDuration)
break
}
}
}
} | [
"func",
"(",
"c",
"*",
"cluster",
")",
"waitNoLeader",
"(",
"membs",
"[",
"]",
"*",
"member",
")",
"{",
"noLeader",
":=",
"false",
"\n",
"for",
"!",
"noLeader",
"{",
"noLeader",
"=",
"true",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"membs",
"{",
... | // waitNoLeader waits until given members lose leader. | [
"waitNoLeader",
"waits",
"until",
"given",
"members",
"lose",
"leader",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L475-L492 | test |
etcd-io/etcd | integration/cluster.go | isMembersEqual | func isMembersEqual(membs []client.Member, wmembs []client.Member) bool {
sort.Sort(SortableMemberSliceByPeerURLs(membs))
sort.Sort(SortableMemberSliceByPeerURLs(wmembs))
for i := range membs {
membs[i].ID = ""
}
return reflect.DeepEqual(membs, wmembs)
} | go | func isMembersEqual(membs []client.Member, wmembs []client.Member) bool {
sort.Sort(SortableMemberSliceByPeerURLs(membs))
sort.Sort(SortableMemberSliceByPeerURLs(wmembs))
for i := range membs {
membs[i].ID = ""
}
return reflect.DeepEqual(membs, wmembs)
} | [
"func",
"isMembersEqual",
"(",
"membs",
"[",
"]",
"client",
".",
"Member",
",",
"wmembs",
"[",
"]",
"client",
".",
"Member",
")",
"bool",
"{",
"sort",
".",
"Sort",
"(",
"SortableMemberSliceByPeerURLs",
"(",
"membs",
")",
")",
"\n",
"sort",
".",
"Sort",
... | // isMembersEqual checks whether two members equal except ID field.
// The given wmembs should always set ID field to empty string. | [
"isMembersEqual",
"checks",
"whether",
"two",
"members",
"equal",
"except",
"ID",
"field",
".",
"The",
"given",
"wmembs",
"should",
"always",
"set",
"ID",
"field",
"to",
"empty",
"string",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L511-L518 | test |
etcd-io/etcd | integration/cluster.go | listenGRPC | func (m *member) listenGRPC() error {
// prefix with localhost so cert has right domain
m.grpcAddr = "localhost:" + m.Name
if m.useIP { // for IP-only TLS certs
m.grpcAddr = "127.0.0.1:" + m.Name
}
l, err := transport.NewUnixListener(m.grpcAddr)
if err != nil {
return fmt.Errorf("listen failed on grpc socket ... | go | func (m *member) listenGRPC() error {
// prefix with localhost so cert has right domain
m.grpcAddr = "localhost:" + m.Name
if m.useIP { // for IP-only TLS certs
m.grpcAddr = "127.0.0.1:" + m.Name
}
l, err := transport.NewUnixListener(m.grpcAddr)
if err != nil {
return fmt.Errorf("listen failed on grpc socket ... | [
"func",
"(",
"m",
"*",
"member",
")",
"listenGRPC",
"(",
")",
"error",
"{",
"m",
".",
"grpcAddr",
"=",
"\"localhost:\"",
"+",
"m",
".",
"Name",
"\n",
"if",
"m",
".",
"useIP",
"{",
"m",
".",
"grpcAddr",
"=",
"\"127.0.0.1:\"",
"+",
"m",
".",
"Name",
... | // listenGRPC starts a grpc server over a unix domain socket on the member | [
"listenGRPC",
"starts",
"a",
"grpc",
"server",
"over",
"a",
"unix",
"domain",
"socket",
"on",
"the",
"member"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L693-L711 | test |
etcd-io/etcd | integration/cluster.go | NewClientV3 | func NewClientV3(m *member) (*clientv3.Client, error) {
if m.grpcAddr == "" {
return nil, fmt.Errorf("member not configured for grpc")
}
cfg := clientv3.Config{
Endpoints: []string{m.grpcAddr},
DialTimeout: 5 * time.Second,
DialOptions: []grpc.DialOption{grpc.WithBlock()},
MaxCallSe... | go | func NewClientV3(m *member) (*clientv3.Client, error) {
if m.grpcAddr == "" {
return nil, fmt.Errorf("member not configured for grpc")
}
cfg := clientv3.Config{
Endpoints: []string{m.grpcAddr},
DialTimeout: 5 * time.Second,
DialOptions: []grpc.DialOption{grpc.WithBlock()},
MaxCallSe... | [
"func",
"NewClientV3",
"(",
"m",
"*",
"member",
")",
"(",
"*",
"clientv3",
".",
"Client",
",",
"error",
")",
"{",
"if",
"m",
".",
"grpcAddr",
"==",
"\"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"member not configured for grpc\"",
")",
... | // NewClientV3 creates a new grpc client connection to the member | [
"NewClientV3",
"creates",
"a",
"new",
"grpc",
"client",
"connection",
"to",
"the",
"member"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L726-L750 | test |
etcd-io/etcd | integration/cluster.go | Clone | func (m *member) Clone(t testing.TB) *member {
mm := &member{}
mm.ServerConfig = m.ServerConfig
var err error
clientURLStrs := m.ClientURLs.StringSlice()
mm.ClientURLs, err = types.NewURLs(clientURLStrs)
if err != nil {
// this should never fail
panic(err)
}
peerURLStrs := m.PeerURLs.StringSlice()
mm.Peer... | go | func (m *member) Clone(t testing.TB) *member {
mm := &member{}
mm.ServerConfig = m.ServerConfig
var err error
clientURLStrs := m.ClientURLs.StringSlice()
mm.ClientURLs, err = types.NewURLs(clientURLStrs)
if err != nil {
// this should never fail
panic(err)
}
peerURLStrs := m.PeerURLs.StringSlice()
mm.Peer... | [
"func",
"(",
"m",
"*",
"member",
")",
"Clone",
"(",
"t",
"testing",
".",
"TB",
")",
"*",
"member",
"{",
"mm",
":=",
"&",
"member",
"{",
"}",
"\n",
"mm",
".",
"ServerConfig",
"=",
"m",
".",
"ServerConfig",
"\n",
"var",
"err",
"error",
"\n",
"clien... | // Clone returns a member with the same server configuration. The returned
// member will not set PeerListeners and ClientListeners. | [
"Clone",
"returns",
"a",
"member",
"with",
"the",
"same",
"server",
"configuration",
".",
"The",
"returned",
"member",
"will",
"not",
"set",
"PeerListeners",
"and",
"ClientListeners",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L754-L782 | test |
etcd-io/etcd | integration/cluster.go | Close | func (m *member) Close() {
if m.grpcBridge != nil {
m.grpcBridge.Close()
m.grpcBridge = nil
}
if m.serverClient != nil {
m.serverClient.Close()
m.serverClient = nil
}
if m.grpcServer != nil {
m.grpcServer.Stop()
m.grpcServer.GracefulStop()
m.grpcServer = nil
m.grpcServerPeer.Stop()
m.grpcServerPe... | go | func (m *member) Close() {
if m.grpcBridge != nil {
m.grpcBridge.Close()
m.grpcBridge = nil
}
if m.serverClient != nil {
m.serverClient.Close()
m.serverClient = nil
}
if m.grpcServer != nil {
m.grpcServer.Stop()
m.grpcServer.GracefulStop()
m.grpcServer = nil
m.grpcServerPeer.Stop()
m.grpcServerPe... | [
"func",
"(",
"m",
"*",
"member",
")",
"Close",
"(",
")",
"{",
"if",
"m",
".",
"grpcBridge",
"!=",
"nil",
"{",
"m",
".",
"grpcBridge",
".",
"Close",
"(",
")",
"\n",
"m",
".",
"grpcBridge",
"=",
"nil",
"\n",
"}",
"\n",
"if",
"m",
".",
"serverClie... | // Close stops the member's etcdserver and closes its connections | [
"Close",
"stops",
"the",
"member",
"s",
"etcdserver",
"and",
"closes",
"its",
"connections"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1006-L1027 | test |
etcd-io/etcd | integration/cluster.go | Stop | func (m *member) Stop(t testing.TB) {
lg.Info(
"stopping a member",
zap.String("name", m.Name),
zap.Strings("advertise-peer-urls", m.PeerURLs.StringSlice()),
zap.Strings("listen-client-urls", m.ClientURLs.StringSlice()),
zap.String("grpc-address", m.grpcAddr),
)
m.Close()
m.serverClosers = nil
lg.Info(
... | go | func (m *member) Stop(t testing.TB) {
lg.Info(
"stopping a member",
zap.String("name", m.Name),
zap.Strings("advertise-peer-urls", m.PeerURLs.StringSlice()),
zap.Strings("listen-client-urls", m.ClientURLs.StringSlice()),
zap.String("grpc-address", m.grpcAddr),
)
m.Close()
m.serverClosers = nil
lg.Info(
... | [
"func",
"(",
"m",
"*",
"member",
")",
"Stop",
"(",
"t",
"testing",
".",
"TB",
")",
"{",
"lg",
".",
"Info",
"(",
"\"stopping a member\"",
",",
"zap",
".",
"String",
"(",
"\"name\"",
",",
"m",
".",
"Name",
")",
",",
"zap",
".",
"Strings",
"(",
"\"a... | // Stop stops the member, but the data dir of the member is preserved. | [
"Stop",
"stops",
"the",
"member",
"but",
"the",
"data",
"dir",
"of",
"the",
"member",
"is",
"preserved",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1030-L1047 | test |
etcd-io/etcd | integration/cluster.go | checkLeaderTransition | func checkLeaderTransition(m *member, oldLead uint64) uint64 {
interval := time.Duration(m.s.Cfg.TickMs) * time.Millisecond
for m.s.Lead() == 0 || (m.s.Lead() == oldLead) {
time.Sleep(interval)
}
return m.s.Lead()
} | go | func checkLeaderTransition(m *member, oldLead uint64) uint64 {
interval := time.Duration(m.s.Cfg.TickMs) * time.Millisecond
for m.s.Lead() == 0 || (m.s.Lead() == oldLead) {
time.Sleep(interval)
}
return m.s.Lead()
} | [
"func",
"checkLeaderTransition",
"(",
"m",
"*",
"member",
",",
"oldLead",
"uint64",
")",
"uint64",
"{",
"interval",
":=",
"time",
".",
"Duration",
"(",
"m",
".",
"s",
".",
"Cfg",
".",
"TickMs",
")",
"*",
"time",
".",
"Millisecond",
"\n",
"for",
"m",
... | // checkLeaderTransition waits for leader transition, returning the new leader ID. | [
"checkLeaderTransition",
"waits",
"for",
"leader",
"transition",
"returning",
"the",
"new",
"leader",
"ID",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1050-L1056 | test |
etcd-io/etcd | integration/cluster.go | Restart | func (m *member) Restart(t testing.TB) error {
lg.Info(
"restarting a member",
zap.String("name", m.Name),
zap.Strings("advertise-peer-urls", m.PeerURLs.StringSlice()),
zap.Strings("listen-client-urls", m.ClientURLs.StringSlice()),
zap.String("grpc-address", m.grpcAddr),
)
newPeerListeners := make([]net.Li... | go | func (m *member) Restart(t testing.TB) error {
lg.Info(
"restarting a member",
zap.String("name", m.Name),
zap.Strings("advertise-peer-urls", m.PeerURLs.StringSlice()),
zap.Strings("listen-client-urls", m.ClientURLs.StringSlice()),
zap.String("grpc-address", m.grpcAddr),
)
newPeerListeners := make([]net.Li... | [
"func",
"(",
"m",
"*",
"member",
")",
"Restart",
"(",
"t",
"testing",
".",
"TB",
")",
"error",
"{",
"lg",
".",
"Info",
"(",
"\"restarting a member\"",
",",
"zap",
".",
"String",
"(",
"\"name\"",
",",
"m",
".",
"Name",
")",
",",
"zap",
".",
"Strings... | // Restart starts the member using the preserved data dir. | [
"Restart",
"starts",
"the",
"member",
"using",
"the",
"preserved",
"data",
"dir",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1064-L1099 | test |
etcd-io/etcd | integration/cluster.go | Terminate | func (m *member) Terminate(t testing.TB) {
lg.Info(
"terminating a member",
zap.String("name", m.Name),
zap.Strings("advertise-peer-urls", m.PeerURLs.StringSlice()),
zap.Strings("listen-client-urls", m.ClientURLs.StringSlice()),
zap.String("grpc-address", m.grpcAddr),
)
m.Close()
if !m.keepDataDirTerminat... | go | func (m *member) Terminate(t testing.TB) {
lg.Info(
"terminating a member",
zap.String("name", m.Name),
zap.Strings("advertise-peer-urls", m.PeerURLs.StringSlice()),
zap.Strings("listen-client-urls", m.ClientURLs.StringSlice()),
zap.String("grpc-address", m.grpcAddr),
)
m.Close()
if !m.keepDataDirTerminat... | [
"func",
"(",
"m",
"*",
"member",
")",
"Terminate",
"(",
"t",
"testing",
".",
"TB",
")",
"{",
"lg",
".",
"Info",
"(",
"\"terminating a member\"",
",",
"zap",
".",
"String",
"(",
"\"name\"",
",",
"m",
".",
"Name",
")",
",",
"zap",
".",
"Strings",
"("... | // Terminate stops the member and removes the data dir. | [
"Terminate",
"stops",
"the",
"member",
"and",
"removes",
"the",
"data",
"dir",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1102-L1123 | test |
etcd-io/etcd | integration/cluster.go | Metric | func (m *member) Metric(metricName string) (string, error) {
cfgtls := transport.TLSInfo{}
tr, err := transport.NewTimeoutTransport(cfgtls, time.Second, time.Second, time.Second)
if err != nil {
return "", err
}
cli := &http.Client{Transport: tr}
resp, err := cli.Get(m.ClientURLs[0].String() + "/metrics")
if e... | go | func (m *member) Metric(metricName string) (string, error) {
cfgtls := transport.TLSInfo{}
tr, err := transport.NewTimeoutTransport(cfgtls, time.Second, time.Second, time.Second)
if err != nil {
return "", err
}
cli := &http.Client{Transport: tr}
resp, err := cli.Get(m.ClientURLs[0].String() + "/metrics")
if e... | [
"func",
"(",
"m",
"*",
"member",
")",
"Metric",
"(",
"metricName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"cfgtls",
":=",
"transport",
".",
"TLSInfo",
"{",
"}",
"\n",
"tr",
",",
"err",
":=",
"transport",
".",
"NewTimeoutTransport",
"(",
... | // Metric gets the metric value for a member | [
"Metric",
"gets",
"the",
"metric",
"value",
"for",
"a",
"member"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1126-L1149 | test |
etcd-io/etcd | integration/cluster.go | InjectPartition | func (m *member) InjectPartition(t testing.TB, others ...*member) {
for _, other := range others {
m.s.CutPeer(other.s.ID())
other.s.CutPeer(m.s.ID())
}
} | go | func (m *member) InjectPartition(t testing.TB, others ...*member) {
for _, other := range others {
m.s.CutPeer(other.s.ID())
other.s.CutPeer(m.s.ID())
}
} | [
"func",
"(",
"m",
"*",
"member",
")",
"InjectPartition",
"(",
"t",
"testing",
".",
"TB",
",",
"others",
"...",
"*",
"member",
")",
"{",
"for",
"_",
",",
"other",
":=",
"range",
"others",
"{",
"m",
".",
"s",
".",
"CutPeer",
"(",
"other",
".",
"s",... | // InjectPartition drops connections from m to others, vice versa. | [
"InjectPartition",
"drops",
"connections",
"from",
"m",
"to",
"others",
"vice",
"versa",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1152-L1157 | test |
etcd-io/etcd | integration/cluster.go | RecoverPartition | func (m *member) RecoverPartition(t testing.TB, others ...*member) {
for _, other := range others {
m.s.MendPeer(other.s.ID())
other.s.MendPeer(m.s.ID())
}
} | go | func (m *member) RecoverPartition(t testing.TB, others ...*member) {
for _, other := range others {
m.s.MendPeer(other.s.ID())
other.s.MendPeer(m.s.ID())
}
} | [
"func",
"(",
"m",
"*",
"member",
")",
"RecoverPartition",
"(",
"t",
"testing",
".",
"TB",
",",
"others",
"...",
"*",
"member",
")",
"{",
"for",
"_",
",",
"other",
":=",
"range",
"others",
"{",
"m",
".",
"s",
".",
"MendPeer",
"(",
"other",
".",
"s... | // RecoverPartition recovers connections from m to others, vice versa. | [
"RecoverPartition",
"recovers",
"connections",
"from",
"m",
"to",
"others",
"vice",
"versa",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1160-L1165 | test |
etcd-io/etcd | integration/cluster.go | NewClusterV3 | func NewClusterV3(t testing.TB, cfg *ClusterConfig) *ClusterV3 {
cfg.UseGRPC = true
if os.Getenv("CLIENT_DEBUG") != "" {
clientv3.SetLogger(grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 4))
}
clus := &ClusterV3{
cluster: NewClusterByConfig(t, cfg),
}
clus.Launch(t)
if !cfg.SkipCreatingCl... | go | func NewClusterV3(t testing.TB, cfg *ClusterConfig) *ClusterV3 {
cfg.UseGRPC = true
if os.Getenv("CLIENT_DEBUG") != "" {
clientv3.SetLogger(grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 4))
}
clus := &ClusterV3{
cluster: NewClusterByConfig(t, cfg),
}
clus.Launch(t)
if !cfg.SkipCreatingCl... | [
"func",
"NewClusterV3",
"(",
"t",
"testing",
".",
"TB",
",",
"cfg",
"*",
"ClusterConfig",
")",
"*",
"ClusterV3",
"{",
"cfg",
".",
"UseGRPC",
"=",
"true",
"\n",
"if",
"os",
".",
"Getenv",
"(",
"\"CLIENT_DEBUG\"",
")",
"!=",
"\"\"",
"{",
"clientv3",
".",... | // NewClusterV3 returns a launched cluster with a grpc client connection
// for each cluster member. | [
"NewClusterV3",
"returns",
"a",
"launched",
"cluster",
"with",
"a",
"grpc",
"client",
"connection",
"for",
"each",
"cluster",
"member",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1206-L1227 | test |
etcd-io/etcd | auth/options.go | ParseWithDefaults | func (opts *jwtOptions) ParseWithDefaults(optMap map[string]string) error {
if opts.TTL == 0 && optMap[optTTL] == "" {
opts.TTL = DefaultTTL
}
return opts.Parse(optMap)
} | go | func (opts *jwtOptions) ParseWithDefaults(optMap map[string]string) error {
if opts.TTL == 0 && optMap[optTTL] == "" {
opts.TTL = DefaultTTL
}
return opts.Parse(optMap)
} | [
"func",
"(",
"opts",
"*",
"jwtOptions",
")",
"ParseWithDefaults",
"(",
"optMap",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"if",
"opts",
".",
"TTL",
"==",
"0",
"&&",
"optMap",
"[",
"optTTL",
"]",
"==",
"\"\"",
"{",
"opts",
".",
"TTL",
... | // ParseWithDefaults will load options from the specified map or set defaults where appropriate | [
"ParseWithDefaults",
"will",
"load",
"options",
"from",
"the",
"specified",
"map",
"or",
"set",
"defaults",
"where",
"appropriate"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/auth/options.go#L54-L60 | test |
etcd-io/etcd | auth/options.go | Parse | func (opts *jwtOptions) Parse(optMap map[string]string) error {
var err error
if ttl := optMap[optTTL]; ttl != "" {
opts.TTL, err = time.ParseDuration(ttl)
if err != nil {
return err
}
}
if file := optMap[optPublicKey]; file != "" {
opts.PublicKey, err = ioutil.ReadFile(file)
if err != nil {
return... | go | func (opts *jwtOptions) Parse(optMap map[string]string) error {
var err error
if ttl := optMap[optTTL]; ttl != "" {
opts.TTL, err = time.ParseDuration(ttl)
if err != nil {
return err
}
}
if file := optMap[optPublicKey]; file != "" {
opts.PublicKey, err = ioutil.ReadFile(file)
if err != nil {
return... | [
"func",
"(",
"opts",
"*",
"jwtOptions",
")",
"Parse",
"(",
"optMap",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"if",
"ttl",
":=",
"optMap",
"[",
"optTTL",
"]",
";",
"ttl",
"!=",
"\"\"",
"{",
"opts",
".",
... | // Parse will load options from the specified map | [
"Parse",
"will",
"load",
"options",
"from",
"the",
"specified",
"map"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/auth/options.go#L63-L94 | test |
etcd-io/etcd | auth/options.go | Key | func (opts *jwtOptions) Key() (interface{}, error) {
switch opts.SignMethod.(type) {
case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS:
return opts.rsaKey()
case *jwt.SigningMethodECDSA:
return opts.ecKey()
case *jwt.SigningMethodHMAC:
return opts.hmacKey()
default:
return nil, fmt.Errorf("unsupported s... | go | func (opts *jwtOptions) Key() (interface{}, error) {
switch opts.SignMethod.(type) {
case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS:
return opts.rsaKey()
case *jwt.SigningMethodECDSA:
return opts.ecKey()
case *jwt.SigningMethodHMAC:
return opts.hmacKey()
default:
return nil, fmt.Errorf("unsupported s... | [
"func",
"(",
"opts",
"*",
"jwtOptions",
")",
"Key",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"switch",
"opts",
".",
"SignMethod",
".",
"(",
"type",
")",
"{",
"case",
"*",
"jwt",
".",
"SigningMethodRSA",
",",
"*",
"jwt",
".",
... | // Key will parse and return the appropriately typed key for the selected signature method | [
"Key",
"will",
"parse",
"and",
"return",
"the",
"appropriately",
"typed",
"key",
"for",
"the",
"selected",
"signature",
"method"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/auth/options.go#L97-L108 | test |
etcd-io/etcd | etcdserver/api/v3rpc/header.go | fill | func (h *header) fill(rh *pb.ResponseHeader) {
if rh == nil {
plog.Panic("unexpected nil resp.Header")
}
rh.ClusterId = uint64(h.clusterID)
rh.MemberId = uint64(h.memberID)
rh.RaftTerm = h.sg.Term()
if rh.Revision == 0 {
rh.Revision = h.rev()
}
} | go | func (h *header) fill(rh *pb.ResponseHeader) {
if rh == nil {
plog.Panic("unexpected nil resp.Header")
}
rh.ClusterId = uint64(h.clusterID)
rh.MemberId = uint64(h.memberID)
rh.RaftTerm = h.sg.Term()
if rh.Revision == 0 {
rh.Revision = h.rev()
}
} | [
"func",
"(",
"h",
"*",
"header",
")",
"fill",
"(",
"rh",
"*",
"pb",
".",
"ResponseHeader",
")",
"{",
"if",
"rh",
"==",
"nil",
"{",
"plog",
".",
"Panic",
"(",
"\"unexpected nil resp.Header\"",
")",
"\n",
"}",
"\n",
"rh",
".",
"ClusterId",
"=",
"uint64... | // fill populates pb.ResponseHeader using etcdserver information | [
"fill",
"populates",
"pb",
".",
"ResponseHeader",
"using",
"etcdserver",
"information"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3rpc/header.go#L39-L49 | test |
etcd-io/etcd | proxy/grpcproxy/watch_broadcast.go | add | func (wb *watchBroadcast) add(w *watcher) bool {
wb.mu.Lock()
defer wb.mu.Unlock()
if wb.nextrev > w.nextrev || (wb.nextrev == 0 && w.nextrev != 0) {
// wb is too far ahead, w will miss events
// or wb is being established with a current watcher
return false
}
if wb.responses == 0 {
// Newly created; creat... | go | func (wb *watchBroadcast) add(w *watcher) bool {
wb.mu.Lock()
defer wb.mu.Unlock()
if wb.nextrev > w.nextrev || (wb.nextrev == 0 && w.nextrev != 0) {
// wb is too far ahead, w will miss events
// or wb is being established with a current watcher
return false
}
if wb.responses == 0 {
// Newly created; creat... | [
"func",
"(",
"wb",
"*",
"watchBroadcast",
")",
"add",
"(",
"w",
"*",
"watcher",
")",
"bool",
"{",
"wb",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"wb",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"wb",
".",
"nextrev",
">",
"w",
"."... | // add puts a watcher into receiving a broadcast if its revision at least
// meets the broadcast revision. Returns true if added. | [
"add",
"puts",
"a",
"watcher",
"into",
"receiving",
"a",
"broadcast",
"if",
"its",
"revision",
"at",
"least",
"meets",
"the",
"broadcast",
"revision",
".",
"Returns",
"true",
"if",
"added",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/watch_broadcast.go#L91-L122 | test |
etcd-io/etcd | mvcc/watcher.go | Watch | func (ws *watchStream) Watch(id WatchID, key, end []byte, startRev int64, fcs ...FilterFunc) (WatchID, error) {
// prevent wrong range where key >= end lexicographically
// watch request with 'WithFromKey' has empty-byte range end
if len(end) != 0 && bytes.Compare(key, end) != -1 {
return -1, ErrEmptyWatcherRange
... | go | func (ws *watchStream) Watch(id WatchID, key, end []byte, startRev int64, fcs ...FilterFunc) (WatchID, error) {
// prevent wrong range where key >= end lexicographically
// watch request with 'WithFromKey' has empty-byte range end
if len(end) != 0 && bytes.Compare(key, end) != -1 {
return -1, ErrEmptyWatcherRange
... | [
"func",
"(",
"ws",
"*",
"watchStream",
")",
"Watch",
"(",
"id",
"WatchID",
",",
"key",
",",
"end",
"[",
"]",
"byte",
",",
"startRev",
"int64",
",",
"fcs",
"...",
"FilterFunc",
")",
"(",
"WatchID",
",",
"error",
")",
"{",
"if",
"len",
"(",
"end",
... | // Watch creates a new watcher in the stream and returns its WatchID. | [
"Watch",
"creates",
"a",
"new",
"watcher",
"in",
"the",
"stream",
"and",
"returns",
"its",
"WatchID",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher.go#L108-L136 | test |
etcd-io/etcd | wal/encoder.go | newFileEncoder | func newFileEncoder(f *os.File, prevCrc uint32) (*encoder, error) {
offset, err := f.Seek(0, io.SeekCurrent)
if err != nil {
return nil, err
}
return newEncoder(f, prevCrc, int(offset)), nil
} | go | func newFileEncoder(f *os.File, prevCrc uint32) (*encoder, error) {
offset, err := f.Seek(0, io.SeekCurrent)
if err != nil {
return nil, err
}
return newEncoder(f, prevCrc, int(offset)), nil
} | [
"func",
"newFileEncoder",
"(",
"f",
"*",
"os",
".",
"File",
",",
"prevCrc",
"uint32",
")",
"(",
"*",
"encoder",
",",
"error",
")",
"{",
"offset",
",",
"err",
":=",
"f",
".",
"Seek",
"(",
"0",
",",
"io",
".",
"SeekCurrent",
")",
"\n",
"if",
"err",... | // newFileEncoder creates a new encoder with current file offset for the page writer. | [
"newFileEncoder",
"creates",
"a",
"new",
"encoder",
"with",
"current",
"file",
"offset",
"for",
"the",
"page",
"writer",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/encoder.go#L54-L60 | test |
etcd-io/etcd | pkg/fileutil/purge.go | purgeFile | func purgeFile(lg *zap.Logger, dirname string, suffix string, max uint, interval time.Duration, stop <-chan struct{}, purgec chan<- string) <-chan error {
errC := make(chan error, 1)
go func() {
for {
fnames, err := ReadDir(dirname)
if err != nil {
errC <- err
return
}
newfnames := make([]string... | go | func purgeFile(lg *zap.Logger, dirname string, suffix string, max uint, interval time.Duration, stop <-chan struct{}, purgec chan<- string) <-chan error {
errC := make(chan error, 1)
go func() {
for {
fnames, err := ReadDir(dirname)
if err != nil {
errC <- err
return
}
newfnames := make([]string... | [
"func",
"purgeFile",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"dirname",
"string",
",",
"suffix",
"string",
",",
"max",
"uint",
",",
"interval",
"time",
".",
"Duration",
",",
"stop",
"<-",
"chan",
"struct",
"{",
"}",
",",
"purgec",
"chan",
"<-",
"s... | // purgeFile is the internal implementation for PurgeFile which can post purged files to purgec if non-nil. | [
"purgeFile",
"is",
"the",
"internal",
"implementation",
"for",
"PurgeFile",
"which",
"can",
"post",
"purged",
"files",
"to",
"purgec",
"if",
"non",
"-",
"nil",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/fileutil/purge.go#L32-L88 | test |
etcd-io/etcd | pkg/flags/strings.go | Set | func (ss *StringsValue) Set(s string) error {
*ss = strings.Split(s, ",")
return nil
} | go | func (ss *StringsValue) Set(s string) error {
*ss = strings.Split(s, ",")
return nil
} | [
"func",
"(",
"ss",
"*",
"StringsValue",
")",
"Set",
"(",
"s",
"string",
")",
"error",
"{",
"*",
"ss",
"=",
"strings",
".",
"Split",
"(",
"s",
",",
"\",\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Set parses a command line set of strings, separated by comma.
// Implements "flag.Value" interface. | [
"Set",
"parses",
"a",
"command",
"line",
"set",
"of",
"strings",
"separated",
"by",
"comma",
".",
"Implements",
"flag",
".",
"Value",
"interface",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/strings.go#L28-L31 | test |
etcd-io/etcd | pkg/flags/strings.go | NewStringsValue | func NewStringsValue(s string) (ss *StringsValue) {
if s == "" {
return &StringsValue{}
}
ss = new(StringsValue)
if err := ss.Set(s); err != nil {
plog.Panicf("new StringsValue should never fail: %v", err)
}
return ss
} | go | func NewStringsValue(s string) (ss *StringsValue) {
if s == "" {
return &StringsValue{}
}
ss = new(StringsValue)
if err := ss.Set(s); err != nil {
plog.Panicf("new StringsValue should never fail: %v", err)
}
return ss
} | [
"func",
"NewStringsValue",
"(",
"s",
"string",
")",
"(",
"ss",
"*",
"StringsValue",
")",
"{",
"if",
"s",
"==",
"\"\"",
"{",
"return",
"&",
"StringsValue",
"{",
"}",
"\n",
"}",
"\n",
"ss",
"=",
"new",
"(",
"StringsValue",
")",
"\n",
"if",
"err",
":=... | // NewStringsValue implements string slice as "flag.Value" interface.
// Given value is to be separated by comma. | [
"NewStringsValue",
"implements",
"string",
"slice",
"as",
"flag",
".",
"Value",
"interface",
".",
"Given",
"value",
"is",
"to",
"be",
"separated",
"by",
"comma",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/strings.go#L38-L47 | test |
etcd-io/etcd | pkg/flags/strings.go | StringsFromFlag | func StringsFromFlag(fs *flag.FlagSet, flagName string) []string {
return []string(*fs.Lookup(flagName).Value.(*StringsValue))
} | go | func StringsFromFlag(fs *flag.FlagSet, flagName string) []string {
return []string(*fs.Lookup(flagName).Value.(*StringsValue))
} | [
"func",
"StringsFromFlag",
"(",
"fs",
"*",
"flag",
".",
"FlagSet",
",",
"flagName",
"string",
")",
"[",
"]",
"string",
"{",
"return",
"[",
"]",
"string",
"(",
"*",
"fs",
".",
"Lookup",
"(",
"flagName",
")",
".",
"Value",
".",
"(",
"*",
"StringsValue"... | // StringsFromFlag returns a string slice from the flag. | [
"StringsFromFlag",
"returns",
"a",
"string",
"slice",
"from",
"the",
"flag",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/strings.go#L50-L52 | test |
etcd-io/etcd | version/version.go | Cluster | func Cluster(v string) string {
vs := strings.Split(v, ".")
if len(vs) <= 2 {
return v
}
return fmt.Sprintf("%s.%s", vs[0], vs[1])
} | go | func Cluster(v string) string {
vs := strings.Split(v, ".")
if len(vs) <= 2 {
return v
}
return fmt.Sprintf("%s.%s", vs[0], vs[1])
} | [
"func",
"Cluster",
"(",
"v",
"string",
")",
"string",
"{",
"vs",
":=",
"strings",
".",
"Split",
"(",
"v",
",",
"\".\"",
")",
"\n",
"if",
"len",
"(",
"vs",
")",
"<=",
"2",
"{",
"return",
"v",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"("... | // Cluster only keeps the major.minor. | [
"Cluster",
"only",
"keeps",
"the",
"major",
".",
"minor",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/version/version.go#L50-L56 | test |
etcd-io/etcd | pkg/ioutil/pagewriter.go | NewPageWriter | func NewPageWriter(w io.Writer, pageBytes, pageOffset int) *PageWriter {
return &PageWriter{
w: w,
pageOffset: pageOffset,
pageBytes: pageBytes,
buf: make([]byte, defaultBufferBytes+pageBytes),
bufWatermarkBytes: defaultBufferBytes,
}
} | go | func NewPageWriter(w io.Writer, pageBytes, pageOffset int) *PageWriter {
return &PageWriter{
w: w,
pageOffset: pageOffset,
pageBytes: pageBytes,
buf: make([]byte, defaultBufferBytes+pageBytes),
bufWatermarkBytes: defaultBufferBytes,
}
} | [
"func",
"NewPageWriter",
"(",
"w",
"io",
".",
"Writer",
",",
"pageBytes",
",",
"pageOffset",
"int",
")",
"*",
"PageWriter",
"{",
"return",
"&",
"PageWriter",
"{",
"w",
":",
"w",
",",
"pageOffset",
":",
"pageOffset",
",",
"pageBytes",
":",
"pageBytes",
",... | // NewPageWriter creates a new PageWriter. pageBytes is the number of bytes
// to write per page. pageOffset is the starting offset of io.Writer. | [
"NewPageWriter",
"creates",
"a",
"new",
"PageWriter",
".",
"pageBytes",
"is",
"the",
"number",
"of",
"bytes",
"to",
"write",
"per",
"page",
".",
"pageOffset",
"is",
"the",
"starting",
"offset",
"of",
"io",
".",
"Writer",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/ioutil/pagewriter.go#L43-L51 | test |
etcd-io/etcd | etcdserver/api/v2store/watcher_hub.go | watch | func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeIndex uint64) (Watcher, *v2error.Error) {
reportWatchRequest()
event, err := wh.EventHistory.scan(key, recursive, index)
if err != nil {
err.Index = storeIndex
return nil, err
}
w := &watcher{
eventChan: make(chan *Event, 100), //... | go | func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeIndex uint64) (Watcher, *v2error.Error) {
reportWatchRequest()
event, err := wh.EventHistory.scan(key, recursive, index)
if err != nil {
err.Index = storeIndex
return nil, err
}
w := &watcher{
eventChan: make(chan *Event, 100), //... | [
"func",
"(",
"wh",
"*",
"watcherHub",
")",
"watch",
"(",
"key",
"string",
",",
"recursive",
",",
"stream",
"bool",
",",
"index",
",",
"storeIndex",
"uint64",
")",
"(",
"Watcher",
",",
"*",
"v2error",
".",
"Error",
")",
"{",
"reportWatchRequest",
"(",
"... | // Watch function returns a Watcher.
// If recursive is true, the first change after index under key will be sent to the event channel of the watcher.
// If recursive is false, the first change after index at key will be sent to the event channel of the watcher.
// If index is zero, watch will start from the current in... | [
"Watch",
"function",
"returns",
"a",
"Watcher",
".",
"If",
"recursive",
"is",
"true",
"the",
"first",
"change",
"after",
"index",
"under",
"key",
"will",
"be",
"sent",
"to",
"the",
"event",
"channel",
"of",
"the",
"watcher",
".",
"If",
"recursive",
"is",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/watcher_hub.go#L59-L116 | test |
etcd-io/etcd | etcdserver/api/v2store/watcher_hub.go | notify | func (wh *watcherHub) notify(e *Event) {
e = wh.EventHistory.addEvent(e) // add event into the eventHistory
segments := strings.Split(e.Node.Key, "/")
currPath := "/"
// walk through all the segments of the path and notify the watchers
// if the path is "/foo/bar", it will notify watchers with path "/",
// "/f... | go | func (wh *watcherHub) notify(e *Event) {
e = wh.EventHistory.addEvent(e) // add event into the eventHistory
segments := strings.Split(e.Node.Key, "/")
currPath := "/"
// walk through all the segments of the path and notify the watchers
// if the path is "/foo/bar", it will notify watchers with path "/",
// "/f... | [
"func",
"(",
"wh",
"*",
"watcherHub",
")",
"notify",
"(",
"e",
"*",
"Event",
")",
"{",
"e",
"=",
"wh",
".",
"EventHistory",
".",
"addEvent",
"(",
"e",
")",
"\n",
"segments",
":=",
"strings",
".",
"Split",
"(",
"e",
".",
"Node",
".",
"Key",
",",
... | // notify function accepts an event and notify to the watchers. | [
"notify",
"function",
"accepts",
"an",
"event",
"and",
"notify",
"to",
"the",
"watchers",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/watcher_hub.go#L123-L139 | test |
etcd-io/etcd | etcdserver/api/v2store/watcher_hub.go | clone | func (wh *watcherHub) clone() *watcherHub {
clonedHistory := wh.EventHistory.clone()
return &watcherHub{
EventHistory: clonedHistory,
}
} | go | func (wh *watcherHub) clone() *watcherHub {
clonedHistory := wh.EventHistory.clone()
return &watcherHub{
EventHistory: clonedHistory,
}
} | [
"func",
"(",
"wh",
"*",
"watcherHub",
")",
"clone",
"(",
")",
"*",
"watcherHub",
"{",
"clonedHistory",
":=",
"wh",
".",
"EventHistory",
".",
"clone",
"(",
")",
"\n",
"return",
"&",
"watcherHub",
"{",
"EventHistory",
":",
"clonedHistory",
",",
"}",
"\n",
... | // clone function clones the watcherHub and return the cloned one.
// only clone the static content. do not clone the current watchers. | [
"clone",
"function",
"clones",
"the",
"watcherHub",
"and",
"return",
"the",
"cloned",
"one",
".",
"only",
"clone",
"the",
"static",
"content",
".",
"do",
"not",
"clone",
"the",
"current",
"watchers",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/watcher_hub.go#L180-L186 | test |
etcd-io/etcd | etcdserver/api/v2store/watcher_hub.go | isHidden | func isHidden(watchPath, keyPath string) bool {
// When deleting a directory, watchPath might be deeper than the actual keyPath
// For example, when deleting /foo we also need to notify watchers on /foo/bar.
if len(watchPath) > len(keyPath) {
return false
}
// if watch path is just a "/", after path will start w... | go | func isHidden(watchPath, keyPath string) bool {
// When deleting a directory, watchPath might be deeper than the actual keyPath
// For example, when deleting /foo we also need to notify watchers on /foo/bar.
if len(watchPath) > len(keyPath) {
return false
}
// if watch path is just a "/", after path will start w... | [
"func",
"isHidden",
"(",
"watchPath",
",",
"keyPath",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"watchPath",
")",
">",
"len",
"(",
"keyPath",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"afterPath",
":=",
"path",
".",
"Clean",
"(",
"\"/\"",
"+"... | // isHidden checks to see if key path is considered hidden to watch path i.e. the
// last element is hidden or it's within a hidden directory | [
"isHidden",
"checks",
"to",
"see",
"if",
"key",
"path",
"is",
"considered",
"hidden",
"to",
"watch",
"path",
"i",
".",
"e",
".",
"the",
"last",
"element",
"is",
"hidden",
"or",
"it",
"s",
"within",
"a",
"hidden",
"directory"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/watcher_hub.go#L190-L200 | test |
etcd-io/etcd | functional/agent/handler.go | createEtcdLogFile | func (srv *Server) createEtcdLogFile() error {
var err error
srv.etcdLogFile, err = os.Create(srv.Member.Etcd.LogOutputs[0])
if err != nil {
return err
}
srv.lg.Info("created etcd log file", zap.String("path", srv.Member.Etcd.LogOutputs[0]))
return nil
} | go | func (srv *Server) createEtcdLogFile() error {
var err error
srv.etcdLogFile, err = os.Create(srv.Member.Etcd.LogOutputs[0])
if err != nil {
return err
}
srv.lg.Info("created etcd log file", zap.String("path", srv.Member.Etcd.LogOutputs[0]))
return nil
} | [
"func",
"(",
"srv",
"*",
"Server",
")",
"createEtcdLogFile",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"srv",
".",
"etcdLogFile",
",",
"err",
"=",
"os",
".",
"Create",
"(",
"srv",
".",
"Member",
".",
"Etcd",
".",
"LogOutputs",
"[",
"0",
... | // just archive the first file | [
"just",
"archive",
"the",
"first",
"file"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/agent/handler.go#L89-L97 | test |
etcd-io/etcd | functional/agent/handler.go | runEtcd | func (srv *Server) runEtcd() error {
errc := make(chan error)
go func() {
time.Sleep(5 * time.Second)
// server advertise client/peer listener had to start first
// before setting up proxy listener
errc <- srv.startProxy()
}()
if srv.etcdCmd != nil {
srv.lg.Info(
"starting etcd command",
zap.String... | go | func (srv *Server) runEtcd() error {
errc := make(chan error)
go func() {
time.Sleep(5 * time.Second)
// server advertise client/peer listener had to start first
// before setting up proxy listener
errc <- srv.startProxy()
}()
if srv.etcdCmd != nil {
srv.lg.Info(
"starting etcd command",
zap.String... | [
"func",
"(",
"srv",
"*",
"Server",
")",
"runEtcd",
"(",
")",
"error",
"{",
"errc",
":=",
"make",
"(",
"chan",
"error",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"time",
".",
"Sleep",
"(",
"5",
"*",
"time",
".",
"Second",
")",
"\n",
"errc",
"<-",
... | // start but do not wait for it to complete | [
"start",
"but",
"do",
"not",
"wait",
"for",
"it",
"to",
"complete"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/agent/handler.go#L140-L175 | test |
etcd-io/etcd | functional/agent/handler.go | stopEtcd | func (srv *Server) stopEtcd(sig os.Signal) error {
srv.stopProxy()
if srv.etcdCmd != nil {
srv.lg.Info(
"stopping etcd command",
zap.String("command-path", srv.etcdCmd.Path),
zap.String("signal", sig.String()),
)
err := srv.etcdCmd.Process.Signal(sig)
if err != nil {
return err
}
errc := ma... | go | func (srv *Server) stopEtcd(sig os.Signal) error {
srv.stopProxy()
if srv.etcdCmd != nil {
srv.lg.Info(
"stopping etcd command",
zap.String("command-path", srv.etcdCmd.Path),
zap.String("signal", sig.String()),
)
err := srv.etcdCmd.Process.Signal(sig)
if err != nil {
return err
}
errc := ma... | [
"func",
"(",
"srv",
"*",
"Server",
")",
"stopEtcd",
"(",
"sig",
"os",
".",
"Signal",
")",
"error",
"{",
"srv",
".",
"stopProxy",
"(",
")",
"\n",
"if",
"srv",
".",
"etcdCmd",
"!=",
"nil",
"{",
"srv",
".",
"lg",
".",
"Info",
"(",
"\"stopping etcd com... | // SIGQUIT to exit with stackstrace | [
"SIGQUIT",
"to",
"exit",
"with",
"stackstrace"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/agent/handler.go#L178-L223 | test |
etcd-io/etcd | functional/agent/handler.go | handle_SIGQUIT_ETCD_AND_REMOVE_DATA_AND_STOP_AGENT | func (srv *Server) handle_SIGQUIT_ETCD_AND_REMOVE_DATA_AND_STOP_AGENT() (*rpcpb.Response, error) {
err := srv.stopEtcd(syscall.SIGQUIT)
if err != nil {
return nil, err
}
if srv.etcdServer != nil {
srv.etcdServer.GetLogger().Sync()
} else {
srv.etcdLogFile.Sync()
srv.etcdLogFile.Close()
}
err = os.Remov... | go | func (srv *Server) handle_SIGQUIT_ETCD_AND_REMOVE_DATA_AND_STOP_AGENT() (*rpcpb.Response, error) {
err := srv.stopEtcd(syscall.SIGQUIT)
if err != nil {
return nil, err
}
if srv.etcdServer != nil {
srv.etcdServer.GetLogger().Sync()
} else {
srv.etcdLogFile.Sync()
srv.etcdLogFile.Close()
}
err = os.Remov... | [
"func",
"(",
"srv",
"*",
"Server",
")",
"handle_SIGQUIT_ETCD_AND_REMOVE_DATA_AND_STOP_AGENT",
"(",
")",
"(",
"*",
"rpcpb",
".",
"Response",
",",
"error",
")",
"{",
"err",
":=",
"srv",
".",
"stopEtcd",
"(",
"syscall",
".",
"SIGQUIT",
")",
"\n",
"if",
"err",... | // stop proxy, etcd, delete data directory | [
"stop",
"proxy",
"etcd",
"delete",
"data",
"directory"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/agent/handler.go#L694-L720 | test |
etcd-io/etcd | pkg/transport/limit_listen.go | LimitListener | func LimitListener(l net.Listener, n int) net.Listener {
return &limitListener{l, make(chan struct{}, n)}
} | go | func LimitListener(l net.Listener, n int) net.Listener {
return &limitListener{l, make(chan struct{}, n)}
} | [
"func",
"LimitListener",
"(",
"l",
"net",
".",
"Listener",
",",
"n",
"int",
")",
"net",
".",
"Listener",
"{",
"return",
"&",
"limitListener",
"{",
"l",
",",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"n",
")",
"}",
"\n",
"}"
] | // LimitListener returns a Listener that accepts at most n simultaneous
// connections from the provided Listener. | [
"LimitListener",
"returns",
"a",
"Listener",
"that",
"accepts",
"at",
"most",
"n",
"simultaneous",
"connections",
"from",
"the",
"provided",
"Listener",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/transport/limit_listen.go#L32-L34 | test |
etcd-io/etcd | etcdserver/api/v2http/http.go | allowMethod | func allowMethod(w http.ResponseWriter, m string, ms ...string) bool {
for _, meth := range ms {
if m == meth {
return true
}
}
w.Header().Set("Allow", strings.Join(ms, ","))
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
return false
} | go | func allowMethod(w http.ResponseWriter, m string, ms ...string) bool {
for _, meth := range ms {
if m == meth {
return true
}
}
w.Header().Set("Allow", strings.Join(ms, ","))
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
return false
} | [
"func",
"allowMethod",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"m",
"string",
",",
"ms",
"...",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"meth",
":=",
"range",
"ms",
"{",
"if",
"m",
"==",
"meth",
"{",
"return",
"true",
"\n",
"}",
"\n",
... | // allowMethod verifies that the given method is one of the allowed methods,
// and if not, it writes an error to w. A boolean is returned indicating
// whether or not the method is allowed. | [
"allowMethod",
"verifies",
"that",
"the",
"given",
"method",
"is",
"one",
"of",
"the",
"allowed",
"methods",
"and",
"if",
"not",
"it",
"writes",
"an",
"error",
"to",
"w",
".",
"A",
"boolean",
"is",
"returned",
"indicating",
"whether",
"or",
"not",
"the",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/http.go#L68-L77 | test |
etcd-io/etcd | etcdserver/api/v3rpc/watch.go | NewWatchServer | func NewWatchServer(s *etcdserver.EtcdServer) pb.WatchServer {
return &watchServer{
lg: s.Cfg.Logger,
clusterID: int64(s.Cluster().ID()),
memberID: int64(s.ID()),
maxRequestBytes: int(s.Cfg.MaxRequestBytes + grpcOverheadBytes),
sg: s,
watchable: s.Watchable(),
ag: s,
}
} | go | func NewWatchServer(s *etcdserver.EtcdServer) pb.WatchServer {
return &watchServer{
lg: s.Cfg.Logger,
clusterID: int64(s.Cluster().ID()),
memberID: int64(s.ID()),
maxRequestBytes: int(s.Cfg.MaxRequestBytes + grpcOverheadBytes),
sg: s,
watchable: s.Watchable(),
ag: s,
}
} | [
"func",
"NewWatchServer",
"(",
"s",
"*",
"etcdserver",
".",
"EtcdServer",
")",
"pb",
".",
"WatchServer",
"{",
"return",
"&",
"watchServer",
"{",
"lg",
":",
"s",
".",
"Cfg",
".",
"Logger",
",",
"clusterID",
":",
"int64",
"(",
"s",
".",
"Cluster",
"(",
... | // NewWatchServer returns a new watch server. | [
"NewWatchServer",
"returns",
"a",
"new",
"watch",
"server",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3rpc/watch.go#L48-L61 | test |
etcd-io/etcd | etcdserver/api/v3rpc/watch.go | FiltersFromRequest | func FiltersFromRequest(creq *pb.WatchCreateRequest) []mvcc.FilterFunc {
filters := make([]mvcc.FilterFunc, 0, len(creq.Filters))
for _, ft := range creq.Filters {
switch ft {
case pb.WatchCreateRequest_NOPUT:
filters = append(filters, filterNoPut)
case pb.WatchCreateRequest_NODELETE:
filters = append(fil... | go | func FiltersFromRequest(creq *pb.WatchCreateRequest) []mvcc.FilterFunc {
filters := make([]mvcc.FilterFunc, 0, len(creq.Filters))
for _, ft := range creq.Filters {
switch ft {
case pb.WatchCreateRequest_NOPUT:
filters = append(filters, filterNoPut)
case pb.WatchCreateRequest_NODELETE:
filters = append(fil... | [
"func",
"FiltersFromRequest",
"(",
"creq",
"*",
"pb",
".",
"WatchCreateRequest",
")",
"[",
"]",
"mvcc",
".",
"FilterFunc",
"{",
"filters",
":=",
"make",
"(",
"[",
"]",
"mvcc",
".",
"FilterFunc",
",",
"0",
",",
"len",
"(",
"creq",
".",
"Filters",
")",
... | // FiltersFromRequest returns "mvcc.FilterFunc" from a given watch create request. | [
"FiltersFromRequest",
"returns",
"mvcc",
".",
"FilterFunc",
"from",
"a",
"given",
"watch",
"create",
"request",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3rpc/watch.go#L572-L584 | test |
etcd-io/etcd | etcdserver/api/rafthttp/http.go | newPipelineHandler | func newPipelineHandler(t *Transport, r Raft, cid types.ID) http.Handler {
return &pipelineHandler{
lg: t.Logger,
localID: t.ID,
tr: t,
r: r,
cid: cid,
}
} | go | func newPipelineHandler(t *Transport, r Raft, cid types.ID) http.Handler {
return &pipelineHandler{
lg: t.Logger,
localID: t.ID,
tr: t,
r: r,
cid: cid,
}
} | [
"func",
"newPipelineHandler",
"(",
"t",
"*",
"Transport",
",",
"r",
"Raft",
",",
"cid",
"types",
".",
"ID",
")",
"http",
".",
"Handler",
"{",
"return",
"&",
"pipelineHandler",
"{",
"lg",
":",
"t",
".",
"Logger",
",",
"localID",
":",
"t",
".",
"ID",
... | // newPipelineHandler returns a handler for handling raft messages
// from pipeline for RaftPrefix.
//
// The handler reads out the raft message from request body,
// and forwards it to the given raft state machine for processing. | [
"newPipelineHandler",
"returns",
"a",
"handler",
"for",
"handling",
"raft",
"messages",
"from",
"pipeline",
"for",
"RaftPrefix",
".",
"The",
"handler",
"reads",
"out",
"the",
"raft",
"message",
"from",
"request",
"body",
"and",
"forwards",
"it",
"to",
"the",
"... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/http.go#L78-L86 | test |
etcd-io/etcd | etcdserver/api/rafthttp/http.go | checkClusterCompatibilityFromHeader | func checkClusterCompatibilityFromHeader(lg *zap.Logger, localID types.ID, header http.Header, cid types.ID) error {
remoteName := header.Get("X-Server-From")
remoteServer := serverVersion(header)
remoteVs := ""
if remoteServer != nil {
remoteVs = remoteServer.String()
}
remoteMinClusterVer := minClusterVersi... | go | func checkClusterCompatibilityFromHeader(lg *zap.Logger, localID types.ID, header http.Header, cid types.ID) error {
remoteName := header.Get("X-Server-From")
remoteServer := serverVersion(header)
remoteVs := ""
if remoteServer != nil {
remoteVs = remoteServer.String()
}
remoteMinClusterVer := minClusterVersi... | [
"func",
"checkClusterCompatibilityFromHeader",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"localID",
"types",
".",
"ID",
",",
"header",
"http",
".",
"Header",
",",
"cid",
"types",
".",
"ID",
")",
"error",
"{",
"remoteName",
":=",
"header",
".",
"Get",
"(... | // checkClusterCompatibilityFromHeader checks the cluster compatibility of
// the local member from the given header.
// It checks whether the version of local member is compatible with
// the versions in the header, and whether the cluster ID of local member
// matches the one in the header. | [
"checkClusterCompatibilityFromHeader",
"checks",
"the",
"cluster",
"compatibility",
"of",
"the",
"local",
"member",
"from",
"the",
"given",
"header",
".",
"It",
"checks",
"whether",
"the",
"version",
"of",
"local",
"member",
"is",
"compatible",
"with",
"the",
"ver... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/http.go#L492-L555 | test |
etcd-io/etcd | clientv3/clientv3util/util.go | KeyExists | func KeyExists(key string) clientv3.Cmp {
return clientv3.Compare(clientv3.Version(key), ">", 0)
} | go | func KeyExists(key string) clientv3.Cmp {
return clientv3.Compare(clientv3.Version(key), ">", 0)
} | [
"func",
"KeyExists",
"(",
"key",
"string",
")",
"clientv3",
".",
"Cmp",
"{",
"return",
"clientv3",
".",
"Compare",
"(",
"clientv3",
".",
"Version",
"(",
"key",
")",
",",
"\">\"",
",",
"0",
")",
"\n",
"}"
] | // KeyExists returns a comparison operation that evaluates to true iff the given
// key exists. It does this by checking if the key `Version` is greater than 0.
// It is a useful guard in transaction delete operations. | [
"KeyExists",
"returns",
"a",
"comparison",
"operation",
"that",
"evaluates",
"to",
"true",
"iff",
"the",
"given",
"key",
"exists",
".",
"It",
"does",
"this",
"by",
"checking",
"if",
"the",
"key",
"Version",
"is",
"greater",
"than",
"0",
".",
"It",
"is",
... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/clientv3util/util.go#L25-L27 | test |
etcd-io/etcd | clientv3/clientv3util/util.go | KeyMissing | func KeyMissing(key string) clientv3.Cmp {
return clientv3.Compare(clientv3.Version(key), "=", 0)
} | go | func KeyMissing(key string) clientv3.Cmp {
return clientv3.Compare(clientv3.Version(key), "=", 0)
} | [
"func",
"KeyMissing",
"(",
"key",
"string",
")",
"clientv3",
".",
"Cmp",
"{",
"return",
"clientv3",
".",
"Compare",
"(",
"clientv3",
".",
"Version",
"(",
"key",
")",
",",
"\"=\"",
",",
"0",
")",
"\n",
"}"
] | // KeyMissing returns a comparison operation that evaluates to true iff the
// given key does not exist. | [
"KeyMissing",
"returns",
"a",
"comparison",
"operation",
"that",
"evaluates",
"to",
"true",
"iff",
"the",
"given",
"key",
"does",
"not",
"exist",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/clientv3util/util.go#L31-L33 | test |
etcd-io/etcd | pkg/transport/tls.go | ValidateSecureEndpoints | func ValidateSecureEndpoints(tlsInfo TLSInfo, eps []string) ([]string, error) {
t, err := NewTransport(tlsInfo, 5*time.Second)
if err != nil {
return nil, err
}
var errs []string
var endpoints []string
for _, ep := range eps {
if !strings.HasPrefix(ep, "https://") {
errs = append(errs, fmt.Sprintf("%q is i... | go | func ValidateSecureEndpoints(tlsInfo TLSInfo, eps []string) ([]string, error) {
t, err := NewTransport(tlsInfo, 5*time.Second)
if err != nil {
return nil, err
}
var errs []string
var endpoints []string
for _, ep := range eps {
if !strings.HasPrefix(ep, "https://") {
errs = append(errs, fmt.Sprintf("%q is i... | [
"func",
"ValidateSecureEndpoints",
"(",
"tlsInfo",
"TLSInfo",
",",
"eps",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"NewTransport",
"(",
"tlsInfo",
",",
"5",
"*",
"time",
".",
"Second",
")",
"\n"... | // ValidateSecureEndpoints scans the given endpoints against tls info, returning only those
// endpoints that could be validated as secure. | [
"ValidateSecureEndpoints",
"scans",
"the",
"given",
"endpoints",
"against",
"tls",
"info",
"returning",
"only",
"those",
"endpoints",
"that",
"could",
"be",
"validated",
"as",
"secure",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/transport/tls.go#L25-L49 | test |
etcd-io/etcd | contrib/recipes/key.go | putNewKV | func putNewKV(kv v3.KV, key, val string, leaseID v3.LeaseID) (int64, error) {
cmp := v3.Compare(v3.Version(key), "=", 0)
req := v3.OpPut(key, val, v3.WithLease(leaseID))
txnresp, err := kv.Txn(context.TODO()).If(cmp).Then(req).Commit()
if err != nil {
return 0, err
}
if !txnresp.Succeeded {
return 0, ErrKeyEx... | go | func putNewKV(kv v3.KV, key, val string, leaseID v3.LeaseID) (int64, error) {
cmp := v3.Compare(v3.Version(key), "=", 0)
req := v3.OpPut(key, val, v3.WithLease(leaseID))
txnresp, err := kv.Txn(context.TODO()).If(cmp).Then(req).Commit()
if err != nil {
return 0, err
}
if !txnresp.Succeeded {
return 0, ErrKeyEx... | [
"func",
"putNewKV",
"(",
"kv",
"v3",
".",
"KV",
",",
"key",
",",
"val",
"string",
",",
"leaseID",
"v3",
".",
"LeaseID",
")",
"(",
"int64",
",",
"error",
")",
"{",
"cmp",
":=",
"v3",
".",
"Compare",
"(",
"v3",
".",
"Version",
"(",
"key",
")",
",... | // putNewKV attempts to create the given key, only succeeding if the key did
// not yet exist. | [
"putNewKV",
"attempts",
"to",
"create",
"the",
"given",
"key",
"only",
"succeeding",
"if",
"the",
"key",
"did",
"not",
"yet",
"exist",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/key.go#L62-L73 | test |
etcd-io/etcd | contrib/recipes/key.go | newUniqueEphemeralKey | func newUniqueEphemeralKey(s *concurrency.Session, prefix string) (*EphemeralKV, error) {
return newUniqueEphemeralKV(s, prefix, "")
} | go | func newUniqueEphemeralKey(s *concurrency.Session, prefix string) (*EphemeralKV, error) {
return newUniqueEphemeralKV(s, prefix, "")
} | [
"func",
"newUniqueEphemeralKey",
"(",
"s",
"*",
"concurrency",
".",
"Session",
",",
"prefix",
"string",
")",
"(",
"*",
"EphemeralKV",
",",
"error",
")",
"{",
"return",
"newUniqueEphemeralKV",
"(",
"s",
",",
"prefix",
",",
"\"\"",
")",
"\n",
"}"
] | // newUniqueEphemeralKey creates a new unique valueless key associated with a session lease | [
"newUniqueEphemeralKey",
"creates",
"a",
"new",
"unique",
"valueless",
"key",
"associated",
"with",
"a",
"session",
"lease"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/key.go#L149-L151 | test |
etcd-io/etcd | etcdctl/ctlv2/command/update_dir_command.go | NewUpdateDirCommand | func NewUpdateDirCommand() cli.Command {
return cli.Command{
Name: "updatedir",
Usage: "update an existing directory",
ArgsUsage: "<key> <value>",
Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
},
Action: func(c *cli.Context) error {
updatedirCom... | go | func NewUpdateDirCommand() cli.Command {
return cli.Command{
Name: "updatedir",
Usage: "update an existing directory",
ArgsUsage: "<key> <value>",
Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
},
Action: func(c *cli.Context) error {
updatedirCom... | [
"func",
"NewUpdateDirCommand",
"(",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"updatedir\"",
",",
"Usage",
":",
"\"update an existing directory\"",
",",
"ArgsUsage",
":",
"\"<key> <value>\"",
",",
"Flags",
":",
"[",
... | // NewUpdateDirCommand returns the CLI command for "updatedir". | [
"NewUpdateDirCommand",
"returns",
"the",
"CLI",
"command",
"for",
"updatedir",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/update_dir_command.go#L26-L39 | test |
etcd-io/etcd | etcdctl/ctlv2/command/update_dir_command.go | updatedirCommandFunc | func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
if len(c.Args()) == 0 {
handleError(c, ExitBadArgs, errors.New("key required"))
}
key := c.Args()[0]
ttl := c.Int("ttl")
ctx, cancel := contextWithTotalTimeout(c)
resp, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Se... | go | func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
if len(c.Args()) == 0 {
handleError(c, ExitBadArgs, errors.New("key required"))
}
key := c.Args()[0]
ttl := c.Int("ttl")
ctx, cancel := contextWithTotalTimeout(c)
resp, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Se... | [
"func",
"updatedirCommandFunc",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"ki",
"client",
".",
"KeysAPI",
")",
"{",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"==",
"0",
"{",
"handleError",
"(",
"c",
",",
"ExitBadArgs",
",",
"errors",
".",... | // updatedirCommandFunc executes the "updatedir" command. | [
"updatedirCommandFunc",
"executes",
"the",
"updatedir",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/update_dir_command.go#L42-L57 | test |
etcd-io/etcd | etcdctl/ctlv2/command/backup_command.go | handleBackup | func handleBackup(c *cli.Context) error {
var srcWAL string
var destWAL string
withV3 := c.Bool("with-v3")
srcSnap := filepath.Join(c.String("data-dir"), "member", "snap")
destSnap := filepath.Join(c.String("backup-dir"), "member", "snap")
if c.String("wal-dir") != "" {
srcWAL = c.String("wal-dir")
} else {
... | go | func handleBackup(c *cli.Context) error {
var srcWAL string
var destWAL string
withV3 := c.Bool("with-v3")
srcSnap := filepath.Join(c.String("data-dir"), "member", "snap")
destSnap := filepath.Join(c.String("backup-dir"), "member", "snap")
if c.String("wal-dir") != "" {
srcWAL = c.String("wal-dir")
} else {
... | [
"func",
"handleBackup",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"var",
"srcWAL",
"string",
"\n",
"var",
"destWAL",
"string",
"\n",
"withV3",
":=",
"c",
".",
"Bool",
"(",
"\"with-v3\"",
")",
"\n",
"srcSnap",
":=",
"filepath",
".",
"Join... | // handleBackup handles a request that intends to do a backup. | [
"handleBackup",
"handles",
"a",
"request",
"that",
"intends",
"to",
"do",
"a",
"backup",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/backup_command.go#L58-L103 | test |
etcd-io/etcd | etcdctl/ctlv2/command/backup_command.go | saveDB | func saveDB(destDB, srcDB string, idx uint64, v3 bool) {
// open src db to safely copy db state
if v3 {
var src *bolt.DB
ch := make(chan *bolt.DB, 1)
go func() {
db, err := bolt.Open(srcDB, 0444, &bolt.Options{ReadOnly: true})
if err != nil {
log.Fatal(err)
}
ch <- db
}()
select {
case src... | go | func saveDB(destDB, srcDB string, idx uint64, v3 bool) {
// open src db to safely copy db state
if v3 {
var src *bolt.DB
ch := make(chan *bolt.DB, 1)
go func() {
db, err := bolt.Open(srcDB, 0444, &bolt.Options{ReadOnly: true})
if err != nil {
log.Fatal(err)
}
ch <- db
}()
select {
case src... | [
"func",
"saveDB",
"(",
"destDB",
",",
"srcDB",
"string",
",",
"idx",
"uint64",
",",
"v3",
"bool",
")",
"{",
"if",
"v3",
"{",
"var",
"src",
"*",
"bolt",
".",
"DB",
"\n",
"ch",
":=",
"make",
"(",
"chan",
"*",
"bolt",
".",
"DB",
",",
"1",
")",
"... | // saveDB copies the v3 backend and strips cluster information. | [
"saveDB",
"copies",
"the",
"v3",
"backend",
"and",
"strips",
"cluster",
"information",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/backup_command.go#L187-L257 | test |
etcd-io/etcd | functional/runner/watch_command.go | NewWatchCommand | func NewWatchCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "watcher",
Short: "Performs watch operation",
Run: runWatcherFunc,
}
cmd.Flags().DurationVar(&runningTime, "running-time", 60, "number of seconds to run")
cmd.Flags().StringVar(&watchPrefix, "prefix", "", "the prefix to append on all keys... | go | func NewWatchCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "watcher",
Short: "Performs watch operation",
Run: runWatcherFunc,
}
cmd.Flags().DurationVar(&runningTime, "running-time", 60, "number of seconds to run")
cmd.Flags().StringVar(&watchPrefix, "prefix", "", "the prefix to append on all keys... | [
"func",
"NewWatchCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"watcher\"",
",",
"Short",
":",
"\"Performs watch operation\"",
",",
"Run",
":",
"runWatcherFunc",
",",
"}",
"\n",
"cmd",
... | // NewWatchCommand returns the cobra command for "watcher runner". | [
"NewWatchCommand",
"returns",
"the",
"cobra",
"command",
"for",
"watcher",
"runner",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/runner/watch_command.go#L41-L54 | test |
etcd-io/etcd | clientv3/snapshot/v3_snapshot.go | NewV3 | func NewV3(lg *zap.Logger) Manager {
if lg == nil {
lg = zap.NewExample()
}
return &v3Manager{lg: lg}
} | go | func NewV3(lg *zap.Logger) Manager {
if lg == nil {
lg = zap.NewExample()
}
return &v3Manager{lg: lg}
} | [
"func",
"NewV3",
"(",
"lg",
"*",
"zap",
".",
"Logger",
")",
"Manager",
"{",
"if",
"lg",
"==",
"nil",
"{",
"lg",
"=",
"zap",
".",
"NewExample",
"(",
")",
"\n",
"}",
"\n",
"return",
"&",
"v3Manager",
"{",
"lg",
":",
"lg",
"}",
"\n",
"}"
] | // NewV3 returns a new snapshot Manager for v3.x snapshot. | [
"NewV3",
"returns",
"a",
"new",
"snapshot",
"Manager",
"for",
"v3",
".",
"x",
"snapshot",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/snapshot/v3_snapshot.go#L72-L77 | test |
etcd-io/etcd | clientv3/snapshot/v3_snapshot.go | Save | func (s *v3Manager) Save(ctx context.Context, cfg clientv3.Config, dbPath string) error {
if len(cfg.Endpoints) != 1 {
return fmt.Errorf("snapshot must be requested to one selected node, not multiple %v", cfg.Endpoints)
}
cli, err := clientv3.New(cfg)
if err != nil {
return err
}
defer cli.Close()
partpath ... | go | func (s *v3Manager) Save(ctx context.Context, cfg clientv3.Config, dbPath string) error {
if len(cfg.Endpoints) != 1 {
return fmt.Errorf("snapshot must be requested to one selected node, not multiple %v", cfg.Endpoints)
}
cli, err := clientv3.New(cfg)
if err != nil {
return err
}
defer cli.Close()
partpath ... | [
"func",
"(",
"s",
"*",
"v3Manager",
")",
"Save",
"(",
"ctx",
"context",
".",
"Context",
",",
"cfg",
"clientv3",
".",
"Config",
",",
"dbPath",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"cfg",
".",
"Endpoints",
")",
"!=",
"1",
"{",
"return",
"fm... | // Save fetches snapshot from remote etcd server and saves data to target path. | [
"Save",
"fetches",
"snapshot",
"from",
"remote",
"etcd",
"server",
"and",
"saves",
"data",
"to",
"target",
"path",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/snapshot/v3_snapshot.go#L92-L145 | test |
etcd-io/etcd | clientv3/snapshot/v3_snapshot.go | Status | func (s *v3Manager) Status(dbPath string) (ds Status, err error) {
if _, err = os.Stat(dbPath); err != nil {
return ds, err
}
db, err := bolt.Open(dbPath, 0400, &bolt.Options{ReadOnly: true})
if err != nil {
return ds, err
}
defer db.Close()
h := crc32.New(crc32.MakeTable(crc32.Castagnoli))
if err = db.V... | go | func (s *v3Manager) Status(dbPath string) (ds Status, err error) {
if _, err = os.Stat(dbPath); err != nil {
return ds, err
}
db, err := bolt.Open(dbPath, 0400, &bolt.Options{ReadOnly: true})
if err != nil {
return ds, err
}
defer db.Close()
h := crc32.New(crc32.MakeTable(crc32.Castagnoli))
if err = db.V... | [
"func",
"(",
"s",
"*",
"v3Manager",
")",
"Status",
"(",
"dbPath",
"string",
")",
"(",
"ds",
"Status",
",",
"err",
"error",
")",
"{",
"if",
"_",
",",
"err",
"=",
"os",
".",
"Stat",
"(",
"dbPath",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ds"... | // Status returns the snapshot file information. | [
"Status",
"returns",
"the",
"snapshot",
"file",
"information",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/snapshot/v3_snapshot.go#L156-L205 | test |
etcd-io/etcd | clientv3/snapshot/v3_snapshot.go | Restore | func (s *v3Manager) Restore(cfg RestoreConfig) error {
pURLs, err := types.NewURLs(cfg.PeerURLs)
if err != nil {
return err
}
var ics types.URLsMap
ics, err = types.NewURLsMap(cfg.InitialCluster)
if err != nil {
return err
}
srv := etcdserver.ServerConfig{
Logger: s.lg,
Name: ... | go | func (s *v3Manager) Restore(cfg RestoreConfig) error {
pURLs, err := types.NewURLs(cfg.PeerURLs)
if err != nil {
return err
}
var ics types.URLsMap
ics, err = types.NewURLsMap(cfg.InitialCluster)
if err != nil {
return err
}
srv := etcdserver.ServerConfig{
Logger: s.lg,
Name: ... | [
"func",
"(",
"s",
"*",
"v3Manager",
")",
"Restore",
"(",
"cfg",
"RestoreConfig",
")",
"error",
"{",
"pURLs",
",",
"err",
":=",
"types",
".",
"NewURLs",
"(",
"cfg",
".",
"PeerURLs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}... | // Restore restores a new etcd data directory from given snapshot file. | [
"Restore",
"restores",
"a",
"new",
"etcd",
"data",
"directory",
"from",
"given",
"snapshot",
"file",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/snapshot/v3_snapshot.go#L239-L309 | test |
etcd-io/etcd | auth/store.go | NewAuthStore | func NewAuthStore(lg *zap.Logger, be backend.Backend, tp TokenProvider, bcryptCost int) *authStore {
if bcryptCost < bcrypt.MinCost || bcryptCost > bcrypt.MaxCost {
if lg != nil {
lg.Warn(
"use default bcrypt cost instead of the invalid given cost",
zap.Int("min-cost", bcrypt.MinCost),
zap.Int("max-co... | go | func NewAuthStore(lg *zap.Logger, be backend.Backend, tp TokenProvider, bcryptCost int) *authStore {
if bcryptCost < bcrypt.MinCost || bcryptCost > bcrypt.MaxCost {
if lg != nil {
lg.Warn(
"use default bcrypt cost instead of the invalid given cost",
zap.Int("min-cost", bcrypt.MinCost),
zap.Int("max-co... | [
"func",
"NewAuthStore",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"be",
"backend",
".",
"Backend",
",",
"tp",
"TokenProvider",
",",
"bcryptCost",
"int",
")",
"*",
"authStore",
"{",
"if",
"bcryptCost",
"<",
"bcrypt",
".",
"MinCost",
"||",
"bcryptCost",
"... | // NewAuthStore creates a new AuthStore. | [
"NewAuthStore",
"creates",
"a",
"new",
"AuthStore",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/auth/store.go#L1068-L1122 | test |
etcd-io/etcd | auth/store.go | NewTokenProvider | func NewTokenProvider(
lg *zap.Logger,
tokenOpts string,
indexWaiter func(uint64) <-chan struct{}) (TokenProvider, error) {
tokenType, typeSpecificOpts, err := decomposeOpts(lg, tokenOpts)
if err != nil {
return nil, ErrInvalidAuthOpts
}
switch tokenType {
case tokenTypeSimple:
if lg != nil {
lg.Warn("s... | go | func NewTokenProvider(
lg *zap.Logger,
tokenOpts string,
indexWaiter func(uint64) <-chan struct{}) (TokenProvider, error) {
tokenType, typeSpecificOpts, err := decomposeOpts(lg, tokenOpts)
if err != nil {
return nil, ErrInvalidAuthOpts
}
switch tokenType {
case tokenTypeSimple:
if lg != nil {
lg.Warn("s... | [
"func",
"NewTokenProvider",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"tokenOpts",
"string",
",",
"indexWaiter",
"func",
"(",
"uint64",
")",
"<-",
"chan",
"struct",
"{",
"}",
")",
"(",
"TokenProvider",
",",
"error",
")",
"{",
"tokenType",
",",
"typeSpec... | // NewTokenProvider creates a new token provider. | [
"NewTokenProvider",
"creates",
"a",
"new",
"token",
"provider",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/auth/store.go#L1276-L1312 | test |
etcd-io/etcd | etcdserver/api/rafthttp/transport.go | MendPeer | func (t *Transport) MendPeer(id types.ID) {
t.mu.RLock()
p, pok := t.peers[id]
g, gok := t.remotes[id]
t.mu.RUnlock()
if pok {
p.(Pausable).Resume()
}
if gok {
g.Resume()
}
} | go | func (t *Transport) MendPeer(id types.ID) {
t.mu.RLock()
p, pok := t.peers[id]
g, gok := t.remotes[id]
t.mu.RUnlock()
if pok {
p.(Pausable).Resume()
}
if gok {
g.Resume()
}
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"MendPeer",
"(",
"id",
"types",
".",
"ID",
")",
"{",
"t",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"p",
",",
"pok",
":=",
"t",
".",
"peers",
"[",
"id",
"]",
"\n",
"g",
",",
"gok",
":=",
"t",
".",
"... | // MendPeer recovers the message dropping behavior of the given peer. | [
"MendPeer",
"recovers",
"the",
"message",
"dropping",
"behavior",
"of",
"the",
"given",
"peer",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/transport.go#L254-L266 | test |
etcd-io/etcd | etcdserver/api/rafthttp/transport.go | removePeer | func (t *Transport) removePeer(id types.ID) {
if peer, ok := t.peers[id]; ok {
peer.stop()
} else {
if t.Logger != nil {
t.Logger.Panic("unexpected removal of unknown remote peer", zap.String("remote-peer-id", id.String()))
} else {
plog.Panicf("unexpected removal of unknown peer '%d'", id)
}
}
delete... | go | func (t *Transport) removePeer(id types.ID) {
if peer, ok := t.peers[id]; ok {
peer.stop()
} else {
if t.Logger != nil {
t.Logger.Panic("unexpected removal of unknown remote peer", zap.String("remote-peer-id", id.String()))
} else {
plog.Panicf("unexpected removal of unknown peer '%d'", id)
}
}
delete... | [
"func",
"(",
"t",
"*",
"Transport",
")",
"removePeer",
"(",
"id",
"types",
".",
"ID",
")",
"{",
"if",
"peer",
",",
"ok",
":=",
"t",
".",
"peers",
"[",
"id",
"]",
";",
"ok",
"{",
"peer",
".",
"stop",
"(",
")",
"\n",
"}",
"else",
"{",
"if",
"... | // the caller of this function must have the peers mutex. | [
"the",
"caller",
"of",
"this",
"function",
"must",
"have",
"the",
"peers",
"mutex",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/transport.go#L353-L377 | test |
etcd-io/etcd | etcdserver/api/rafthttp/transport.go | ActivePeers | func (t *Transport) ActivePeers() (cnt int) {
t.mu.RLock()
defer t.mu.RUnlock()
for _, p := range t.peers {
if !p.activeSince().IsZero() {
cnt++
}
}
return cnt
} | go | func (t *Transport) ActivePeers() (cnt int) {
t.mu.RLock()
defer t.mu.RUnlock()
for _, p := range t.peers {
if !p.activeSince().IsZero() {
cnt++
}
}
return cnt
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"ActivePeers",
"(",
")",
"(",
"cnt",
"int",
")",
"{",
"t",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"t",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"t",
... | // ActivePeers returns a channel that closes when an initial
// peer connection has been established. Use this to wait until the
// first peer connection becomes active. | [
"ActivePeers",
"returns",
"a",
"channel",
"that",
"closes",
"when",
"an",
"initial",
"peer",
"connection",
"has",
"been",
"established",
".",
"Use",
"this",
"to",
"wait",
"until",
"the",
"first",
"peer",
"connection",
"becomes",
"active",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/transport.go#L454-L463 | test |
etcd-io/etcd | pkg/netutil/netutil.go | resolveTCPAddrDefault | func resolveTCPAddrDefault(ctx context.Context, addr string) (*net.TCPAddr, error) {
host, port, serr := net.SplitHostPort(addr)
if serr != nil {
return nil, serr
}
portnum, perr := net.DefaultResolver.LookupPort(ctx, "tcp", port)
if perr != nil {
return nil, perr
}
var ips []net.IPAddr
if ip := net.ParseI... | go | func resolveTCPAddrDefault(ctx context.Context, addr string) (*net.TCPAddr, error) {
host, port, serr := net.SplitHostPort(addr)
if serr != nil {
return nil, serr
}
portnum, perr := net.DefaultResolver.LookupPort(ctx, "tcp", port)
if perr != nil {
return nil, perr
}
var ips []net.IPAddr
if ip := net.ParseI... | [
"func",
"resolveTCPAddrDefault",
"(",
"ctx",
"context",
".",
"Context",
",",
"addr",
"string",
")",
"(",
"*",
"net",
".",
"TCPAddr",
",",
"error",
")",
"{",
"host",
",",
"port",
",",
"serr",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
")",
"\n",
... | // taken from go's ResolveTCP code but uses configurable ctx | [
"taken",
"from",
"go",
"s",
"ResolveTCP",
"code",
"but",
"uses",
"configurable",
"ctx"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/netutil.go#L37-L61 | test |
etcd-io/etcd | pkg/netutil/netutil.go | resolveTCPAddrs | func resolveTCPAddrs(ctx context.Context, lg *zap.Logger, urls [][]url.URL) ([][]url.URL, error) {
newurls := make([][]url.URL, 0)
for _, us := range urls {
nus := make([]url.URL, len(us))
for i, u := range us {
nu, err := url.Parse(u.String())
if err != nil {
return nil, fmt.Errorf("failed to parse %q ... | go | func resolveTCPAddrs(ctx context.Context, lg *zap.Logger, urls [][]url.URL) ([][]url.URL, error) {
newurls := make([][]url.URL, 0)
for _, us := range urls {
nus := make([]url.URL, len(us))
for i, u := range us {
nu, err := url.Parse(u.String())
if err != nil {
return nil, fmt.Errorf("failed to parse %q ... | [
"func",
"resolveTCPAddrs",
"(",
"ctx",
"context",
".",
"Context",
",",
"lg",
"*",
"zap",
".",
"Logger",
",",
"urls",
"[",
"]",
"[",
"]",
"url",
".",
"URL",
")",
"(",
"[",
"]",
"[",
"]",
"url",
".",
"URL",
",",
"error",
")",
"{",
"newurls",
":="... | // resolveTCPAddrs is a convenience wrapper for net.ResolveTCPAddr.
// resolveTCPAddrs return a new set of url.URLs, in which all DNS hostnames
// are resolved. | [
"resolveTCPAddrs",
"is",
"a",
"convenience",
"wrapper",
"for",
"net",
".",
"ResolveTCPAddr",
".",
"resolveTCPAddrs",
"return",
"a",
"new",
"set",
"of",
"url",
".",
"URLs",
"in",
"which",
"all",
"DNS",
"hostnames",
"are",
"resolved",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/netutil.go#L66-L89 | test |
etcd-io/etcd | pkg/netutil/netutil.go | urlsEqual | func urlsEqual(ctx context.Context, lg *zap.Logger, a []url.URL, b []url.URL) (bool, error) {
if len(a) != len(b) {
return false, fmt.Errorf("len(%q) != len(%q)", urlsToStrings(a), urlsToStrings(b))
}
urls, err := resolveTCPAddrs(ctx, lg, [][]url.URL{a, b})
if err != nil {
return false, err
}
preva, prevb := ... | go | func urlsEqual(ctx context.Context, lg *zap.Logger, a []url.URL, b []url.URL) (bool, error) {
if len(a) != len(b) {
return false, fmt.Errorf("len(%q) != len(%q)", urlsToStrings(a), urlsToStrings(b))
}
urls, err := resolveTCPAddrs(ctx, lg, [][]url.URL{a, b})
if err != nil {
return false, err
}
preva, prevb := ... | [
"func",
"urlsEqual",
"(",
"ctx",
"context",
".",
"Context",
",",
"lg",
"*",
"zap",
".",
"Logger",
",",
"a",
"[",
"]",
"url",
".",
"URL",
",",
"b",
"[",
"]",
"url",
".",
"URL",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"len",
"(",
"a",
... | // urlsEqual checks equality of url.URLS between two arrays.
// This check pass even if an URL is in hostname and opposite is in IP address. | [
"urlsEqual",
"checks",
"equality",
"of",
"url",
".",
"URLS",
"between",
"two",
"arrays",
".",
"This",
"check",
"pass",
"even",
"if",
"an",
"URL",
"is",
"in",
"hostname",
"and",
"opposite",
"is",
"in",
"IP",
"address",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/netutil.go#L147-L168 | test |
etcd-io/etcd | pkg/netutil/netutil.go | URLStringsEqual | func URLStringsEqual(ctx context.Context, lg *zap.Logger, a []string, b []string) (bool, error) {
if len(a) != len(b) {
return false, fmt.Errorf("len(%q) != len(%q)", a, b)
}
urlsA := make([]url.URL, 0)
for _, str := range a {
u, err := url.Parse(str)
if err != nil {
return false, fmt.Errorf("failed to par... | go | func URLStringsEqual(ctx context.Context, lg *zap.Logger, a []string, b []string) (bool, error) {
if len(a) != len(b) {
return false, fmt.Errorf("len(%q) != len(%q)", a, b)
}
urlsA := make([]url.URL, 0)
for _, str := range a {
u, err := url.Parse(str)
if err != nil {
return false, fmt.Errorf("failed to par... | [
"func",
"URLStringsEqual",
"(",
"ctx",
"context",
".",
"Context",
",",
"lg",
"*",
"zap",
".",
"Logger",
",",
"a",
"[",
"]",
"string",
",",
"b",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"len",
"(",
"a",
")",
"!=",
"len... | // URLStringsEqual returns "true" if given URLs are valid
// and resolved to same IP addresses. Otherwise, return "false"
// and error, if any. | [
"URLStringsEqual",
"returns",
"true",
"if",
"given",
"URLs",
"are",
"valid",
"and",
"resolved",
"to",
"same",
"IP",
"addresses",
".",
"Otherwise",
"return",
"false",
"and",
"error",
"if",
"any",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/netutil.go#L173-L200 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | NewLeaseCommand | func NewLeaseCommand() *cobra.Command {
lc := &cobra.Command{
Use: "lease <subcommand>",
Short: "Lease related commands",
}
lc.AddCommand(NewLeaseGrantCommand())
lc.AddCommand(NewLeaseRevokeCommand())
lc.AddCommand(NewLeaseTimeToLiveCommand())
lc.AddCommand(NewLeaseListCommand())
lc.AddCommand(NewLeaseKee... | go | func NewLeaseCommand() *cobra.Command {
lc := &cobra.Command{
Use: "lease <subcommand>",
Short: "Lease related commands",
}
lc.AddCommand(NewLeaseGrantCommand())
lc.AddCommand(NewLeaseRevokeCommand())
lc.AddCommand(NewLeaseTimeToLiveCommand())
lc.AddCommand(NewLeaseListCommand())
lc.AddCommand(NewLeaseKee... | [
"func",
"NewLeaseCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"lc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"lease <subcommand>\"",
",",
"Short",
":",
"\"Lease related commands\"",
",",
"}",
"\n",
"lc",
".",
"AddCommand",
"(",
"New... | // NewLeaseCommand returns the cobra command for "lease". | [
"NewLeaseCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lease",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L28-L41 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | NewLeaseGrantCommand | func NewLeaseGrantCommand() *cobra.Command {
lc := &cobra.Command{
Use: "grant <ttl>",
Short: "Creates leases",
Run: leaseGrantCommandFunc,
}
return lc
} | go | func NewLeaseGrantCommand() *cobra.Command {
lc := &cobra.Command{
Use: "grant <ttl>",
Short: "Creates leases",
Run: leaseGrantCommandFunc,
}
return lc
} | [
"func",
"NewLeaseGrantCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"lc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"grant <ttl>\"",
",",
"Short",
":",
"\"Creates leases\"",
",",
"Run",
":",
"leaseGrantCommandFunc",
",",
"}",
"\n",
"r... | // NewLeaseGrantCommand returns the cobra command for "lease grant". | [
"NewLeaseGrantCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lease",
"grant",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L44-L53 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | leaseGrantCommandFunc | func leaseGrantCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease grant command needs TTL argument"))
}
ttl, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
ExitWithError(ExitBadArgs, fmt.Errorf("bad TTL (%v)", err))
}
ctx, cancel := co... | go | func leaseGrantCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease grant command needs TTL argument"))
}
ttl, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
ExitWithError(ExitBadArgs, fmt.Errorf("bad TTL (%v)", err))
}
ctx, cancel := co... | [
"func",
"leaseGrantCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"lease grant comma... | // leaseGrantCommandFunc executes the "lease grant" command. | [
"leaseGrantCommandFunc",
"executes",
"the",
"lease",
"grant",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L56-L73 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | NewLeaseRevokeCommand | func NewLeaseRevokeCommand() *cobra.Command {
lc := &cobra.Command{
Use: "revoke <leaseID>",
Short: "Revokes leases",
Run: leaseRevokeCommandFunc,
}
return lc
} | go | func NewLeaseRevokeCommand() *cobra.Command {
lc := &cobra.Command{
Use: "revoke <leaseID>",
Short: "Revokes leases",
Run: leaseRevokeCommandFunc,
}
return lc
} | [
"func",
"NewLeaseRevokeCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"lc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"revoke <leaseID>\"",
",",
"Short",
":",
"\"Revokes leases\"",
",",
"Run",
":",
"leaseRevokeCommandFunc",
",",
"}",
"\n... | // NewLeaseRevokeCommand returns the cobra command for "lease revoke". | [
"NewLeaseRevokeCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lease",
"revoke",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L76-L85 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | leaseRevokeCommandFunc | func leaseRevokeCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease revoke command needs 1 argument"))
}
id := leaseFromArgs(args[0])
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Revoke(ctx, id)
cancel()
if err != nil {
Exit... | go | func leaseRevokeCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease revoke command needs 1 argument"))
}
id := leaseFromArgs(args[0])
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Revoke(ctx, id)
cancel()
if err != nil {
Exit... | [
"func",
"leaseRevokeCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"lease revoke com... | // leaseRevokeCommandFunc executes the "lease grant" command. | [
"leaseRevokeCommandFunc",
"executes",
"the",
"lease",
"grant",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L88-L101 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | NewLeaseTimeToLiveCommand | func NewLeaseTimeToLiveCommand() *cobra.Command {
lc := &cobra.Command{
Use: "timetolive <leaseID> [options]",
Short: "Get lease information",
Run: leaseTimeToLiveCommandFunc,
}
lc.Flags().BoolVar(&timeToLiveKeys, "keys", false, "Get keys attached to this lease")
return lc
} | go | func NewLeaseTimeToLiveCommand() *cobra.Command {
lc := &cobra.Command{
Use: "timetolive <leaseID> [options]",
Short: "Get lease information",
Run: leaseTimeToLiveCommandFunc,
}
lc.Flags().BoolVar(&timeToLiveKeys, "keys", false, "Get keys attached to this lease")
return lc
} | [
"func",
"NewLeaseTimeToLiveCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"lc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"timetolive <leaseID> [options]\"",
",",
"Short",
":",
"\"Get lease information\"",
",",
"Run",
":",
"leaseTimeToLiveComm... | // NewLeaseTimeToLiveCommand returns the cobra command for "lease timetolive". | [
"NewLeaseTimeToLiveCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lease",
"timetolive",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L106-L116 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | leaseTimeToLiveCommandFunc | func leaseTimeToLiveCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease timetolive command needs lease ID as argument"))
}
var opts []v3.LeaseOption
if timeToLiveKeys {
opts = append(opts, v3.WithAttachedKeys())
}
resp, rerr := mustClientFromCmd(cm... | go | func leaseTimeToLiveCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease timetolive command needs lease ID as argument"))
}
var opts []v3.LeaseOption
if timeToLiveKeys {
opts = append(opts, v3.WithAttachedKeys())
}
resp, rerr := mustClientFromCmd(cm... | [
"func",
"leaseTimeToLiveCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"lease timeto... | // leaseTimeToLiveCommandFunc executes the "lease timetolive" command. | [
"leaseTimeToLiveCommandFunc",
"executes",
"the",
"lease",
"timetolive",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L119-L132 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | NewLeaseListCommand | func NewLeaseListCommand() *cobra.Command {
lc := &cobra.Command{
Use: "list",
Short: "List all active leases",
Run: leaseListCommandFunc,
}
return lc
} | go | func NewLeaseListCommand() *cobra.Command {
lc := &cobra.Command{
Use: "list",
Short: "List all active leases",
Run: leaseListCommandFunc,
}
return lc
} | [
"func",
"NewLeaseListCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"lc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"list\"",
",",
"Short",
":",
"\"List all active leases\"",
",",
"Run",
":",
"leaseListCommandFunc",
",",
"}",
"\n",
"re... | // NewLeaseListCommand returns the cobra command for "lease list". | [
"NewLeaseListCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lease",
"list",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L135-L142 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | leaseListCommandFunc | func leaseListCommandFunc(cmd *cobra.Command, args []string) {
resp, rerr := mustClientFromCmd(cmd).Leases(context.TODO())
if rerr != nil {
ExitWithError(ExitBadConnection, rerr)
}
display.Leases(*resp)
} | go | func leaseListCommandFunc(cmd *cobra.Command, args []string) {
resp, rerr := mustClientFromCmd(cmd).Leases(context.TODO())
if rerr != nil {
ExitWithError(ExitBadConnection, rerr)
}
display.Leases(*resp)
} | [
"func",
"leaseListCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"resp",
",",
"rerr",
":=",
"mustClientFromCmd",
"(",
"cmd",
")",
".",
"Leases",
"(",
"context",
".",
"TODO",
"(",
")",
")",
"\n",
"if... | // leaseListCommandFunc executes the "lease list" command. | [
"leaseListCommandFunc",
"executes",
"the",
"lease",
"list",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L145-L151 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | NewLeaseKeepAliveCommand | func NewLeaseKeepAliveCommand() *cobra.Command {
lc := &cobra.Command{
Use: "keep-alive [options] <leaseID>",
Short: "Keeps leases alive (renew)",
Run: leaseKeepAliveCommandFunc,
}
lc.Flags().BoolVar(&leaseKeepAliveOnce, "once", false, "Resets the keep-alive time to its original value and exits immediately... | go | func NewLeaseKeepAliveCommand() *cobra.Command {
lc := &cobra.Command{
Use: "keep-alive [options] <leaseID>",
Short: "Keeps leases alive (renew)",
Run: leaseKeepAliveCommandFunc,
}
lc.Flags().BoolVar(&leaseKeepAliveOnce, "once", false, "Resets the keep-alive time to its original value and exits immediately... | [
"func",
"NewLeaseKeepAliveCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"lc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"keep-alive [options] <leaseID>\"",
",",
"Short",
":",
"\"Keeps leases alive (renew)\"",
",",
"Run",
":",
"leaseKeepAliveC... | // NewLeaseKeepAliveCommand returns the cobra command for "lease keep-alive". | [
"NewLeaseKeepAliveCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lease",
"keep",
"-",
"alive",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L158-L169 | test |
etcd-io/etcd | etcdctl/ctlv3/command/lease_command.go | leaseKeepAliveCommandFunc | func leaseKeepAliveCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease keep-alive command needs lease ID as argument"))
}
id := leaseFromArgs(args[0])
if leaseKeepAliveOnce {
respc, kerr := mustClientFromCmd(cmd).KeepAliveOnce(context.TODO(), id)
... | go | func leaseKeepAliveCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("lease keep-alive command needs lease ID as argument"))
}
id := leaseFromArgs(args[0])
if leaseKeepAliveOnce {
respc, kerr := mustClientFromCmd(cmd).KeepAliveOnce(context.TODO(), id)
... | [
"func",
"leaseKeepAliveCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"lease keep-al... | // leaseKeepAliveCommandFunc executes the "lease keep-alive" command. | [
"leaseKeepAliveCommandFunc",
"executes",
"the",
"lease",
"keep",
"-",
"alive",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L172-L199 | test |
etcd-io/etcd | etcdctl/ctlv3/command/alarm_command.go | NewAlarmCommand | func NewAlarmCommand() *cobra.Command {
ac := &cobra.Command{
Use: "alarm <subcommand>",
Short: "Alarm related commands",
}
ac.AddCommand(NewAlarmDisarmCommand())
ac.AddCommand(NewAlarmListCommand())
return ac
} | go | func NewAlarmCommand() *cobra.Command {
ac := &cobra.Command{
Use: "alarm <subcommand>",
Short: "Alarm related commands",
}
ac.AddCommand(NewAlarmDisarmCommand())
ac.AddCommand(NewAlarmListCommand())
return ac
} | [
"func",
"NewAlarmCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"ac",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"alarm <subcommand>\"",
",",
"Short",
":",
"\"Alarm related commands\"",
",",
"}",
"\n",
"ac",
".",
"AddCommand",
"(",
"New... | // NewAlarmCommand returns the cobra command for "alarm". | [
"NewAlarmCommand",
"returns",
"the",
"cobra",
"command",
"for",
"alarm",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/alarm_command.go#L25-L35 | test |
etcd-io/etcd | etcdctl/ctlv3/command/alarm_command.go | alarmDisarmCommandFunc | func alarmDisarmCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("alarm disarm command accepts no arguments"))
}
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).AlarmDisarm(ctx, &v3.AlarmMember{})
cancel()
if err != nil {
ExitWithErr... | go | func alarmDisarmCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("alarm disarm command accepts no arguments"))
}
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).AlarmDisarm(ctx, &v3.AlarmMember{})
cancel()
if err != nil {
ExitWithErr... | [
"func",
"alarmDisarmCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"0",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"alarm disarm com... | // alarmDisarmCommandFunc executes the "alarm disarm" command. | [
"alarmDisarmCommandFunc",
"executes",
"the",
"alarm",
"disarm",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/alarm_command.go#L47-L58 | test |
etcd-io/etcd | etcdctl/ctlv3/command/alarm_command.go | alarmListCommandFunc | func alarmListCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("alarm list command accepts no arguments"))
}
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).AlarmList(ctx)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
di... | go | func alarmListCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("alarm list command accepts no arguments"))
}
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).AlarmList(ctx)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
di... | [
"func",
"alarmListCommandFunc",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"0",
"{",
"ExitWithError",
"(",
"ExitBadArgs",
",",
"fmt",
".",
"Errorf",
"(",
"\"alarm list command... | // alarmListCommandFunc executes the "alarm list" command. | [
"alarmListCommandFunc",
"executes",
"the",
"alarm",
"list",
"command",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/alarm_command.go#L70-L81 | test |
etcd-io/etcd | functional/rpcpb/etcd_config.go | Flags | func (e *Etcd) Flags() (fs []string) {
tp := reflect.TypeOf(*e)
vo := reflect.ValueOf(*e)
for _, name := range etcdFields {
field, ok := tp.FieldByName(name)
if !ok {
panic(fmt.Errorf("field %q not found", name))
}
fv := reflect.Indirect(vo).FieldByName(name)
var sv string
switch fv.Type().Kind() {
... | go | func (e *Etcd) Flags() (fs []string) {
tp := reflect.TypeOf(*e)
vo := reflect.ValueOf(*e)
for _, name := range etcdFields {
field, ok := tp.FieldByName(name)
if !ok {
panic(fmt.Errorf("field %q not found", name))
}
fv := reflect.Indirect(vo).FieldByName(name)
var sv string
switch fv.Type().Kind() {
... | [
"func",
"(",
"e",
"*",
"Etcd",
")",
"Flags",
"(",
")",
"(",
"fs",
"[",
"]",
"string",
")",
"{",
"tp",
":=",
"reflect",
".",
"TypeOf",
"(",
"*",
"e",
")",
"\n",
"vo",
":=",
"reflect",
".",
"ValueOf",
"(",
"*",
"e",
")",
"\n",
"for",
"_",
","... | // Flags returns etcd flags in string slice. | [
"Flags",
"returns",
"etcd",
"flags",
"in",
"string",
"slice",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/rpcpb/etcd_config.go#L67-L107 | test |
etcd-io/etcd | functional/rpcpb/etcd_config.go | EmbedConfig | func (e *Etcd) EmbedConfig() (cfg *embed.Config, err error) {
var lcURLs types.URLs
lcURLs, err = types.NewURLs(e.ListenClientURLs)
if err != nil {
return nil, err
}
var acURLs types.URLs
acURLs, err = types.NewURLs(e.AdvertiseClientURLs)
if err != nil {
return nil, err
}
var lpURLs types.URLs
lpURLs, err... | go | func (e *Etcd) EmbedConfig() (cfg *embed.Config, err error) {
var lcURLs types.URLs
lcURLs, err = types.NewURLs(e.ListenClientURLs)
if err != nil {
return nil, err
}
var acURLs types.URLs
acURLs, err = types.NewURLs(e.AdvertiseClientURLs)
if err != nil {
return nil, err
}
var lpURLs types.URLs
lpURLs, err... | [
"func",
"(",
"e",
"*",
"Etcd",
")",
"EmbedConfig",
"(",
")",
"(",
"cfg",
"*",
"embed",
".",
"Config",
",",
"err",
"error",
")",
"{",
"var",
"lcURLs",
"types",
".",
"URLs",
"\n",
"lcURLs",
",",
"err",
"=",
"types",
".",
"NewURLs",
"(",
"e",
".",
... | // EmbedConfig returns etcd embed.Config. | [
"EmbedConfig",
"returns",
"etcd",
"embed",
".",
"Config",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/rpcpb/etcd_config.go#L110-L174 | test |
etcd-io/etcd | pkg/debugutil/pprof.go | PProfHandlers | func PProfHandlers() map[string]http.Handler {
// set only when there's no existing setting
if runtime.SetMutexProfileFraction(-1) == 0 {
// 1 out of 5 mutex events are reported, on average
runtime.SetMutexProfileFraction(5)
}
m := make(map[string]http.Handler)
m[HTTPPrefixPProf+"/"] = http.HandlerFunc(pprof... | go | func PProfHandlers() map[string]http.Handler {
// set only when there's no existing setting
if runtime.SetMutexProfileFraction(-1) == 0 {
// 1 out of 5 mutex events are reported, on average
runtime.SetMutexProfileFraction(5)
}
m := make(map[string]http.Handler)
m[HTTPPrefixPProf+"/"] = http.HandlerFunc(pprof... | [
"func",
"PProfHandlers",
"(",
")",
"map",
"[",
"string",
"]",
"http",
".",
"Handler",
"{",
"if",
"runtime",
".",
"SetMutexProfileFraction",
"(",
"-",
"1",
")",
"==",
"0",
"{",
"runtime",
".",
"SetMutexProfileFraction",
"(",
"5",
")",
"\n",
"}",
"\n",
"... | // PProfHandlers returns a map of pprof handlers keyed by the HTTP path. | [
"PProfHandlers",
"returns",
"a",
"map",
"of",
"pprof",
"handlers",
"keyed",
"by",
"the",
"HTTP",
"path",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/debugutil/pprof.go#L26-L47 | test |
etcd-io/etcd | etcdserver/quota.go | NewBackendQuota | func NewBackendQuota(s *EtcdServer, name string) Quota {
lg := s.getLogger()
quotaBackendBytes.Set(float64(s.Cfg.QuotaBackendBytes))
if s.Cfg.QuotaBackendBytes < 0 {
// disable quotas if negative
quotaLogOnce.Do(func() {
if lg != nil {
lg.Info(
"disabled backend quota",
zap.String("quota-name",... | go | func NewBackendQuota(s *EtcdServer, name string) Quota {
lg := s.getLogger()
quotaBackendBytes.Set(float64(s.Cfg.QuotaBackendBytes))
if s.Cfg.QuotaBackendBytes < 0 {
// disable quotas if negative
quotaLogOnce.Do(func() {
if lg != nil {
lg.Info(
"disabled backend quota",
zap.String("quota-name",... | [
"func",
"NewBackendQuota",
"(",
"s",
"*",
"EtcdServer",
",",
"name",
"string",
")",
"Quota",
"{",
"lg",
":=",
"s",
".",
"getLogger",
"(",
")",
"\n",
"quotaBackendBytes",
".",
"Set",
"(",
"float64",
"(",
"s",
".",
"Cfg",
".",
"QuotaBackendBytes",
")",
"... | // NewBackendQuota creates a quota layer with the given storage limit. | [
"NewBackendQuota",
"creates",
"a",
"quota",
"layer",
"with",
"the",
"given",
"storage",
"limit",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/quota.go#L74-L135 | test |
etcd-io/etcd | proxy/grpcproxy/cluster.go | NewClusterProxy | func NewClusterProxy(c *clientv3.Client, advaddr string, prefix string) (pb.ClusterServer, <-chan struct{}) {
cp := &clusterProxy{
clus: c.Cluster,
ctx: c.Ctx(),
gr: &naming.GRPCResolver{Client: c},
advaddr: advaddr,
prefix: prefix,
umap: make(map[string]gnaming.Update),
}
donec := make(chan str... | go | func NewClusterProxy(c *clientv3.Client, advaddr string, prefix string) (pb.ClusterServer, <-chan struct{}) {
cp := &clusterProxy{
clus: c.Cluster,
ctx: c.Ctx(),
gr: &naming.GRPCResolver{Client: c},
advaddr: advaddr,
prefix: prefix,
umap: make(map[string]gnaming.Update),
}
donec := make(chan str... | [
"func",
"NewClusterProxy",
"(",
"c",
"*",
"clientv3",
".",
"Client",
",",
"advaddr",
"string",
",",
"prefix",
"string",
")",
"(",
"pb",
".",
"ClusterServer",
",",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"cp",
":=",
"&",
"clusterProxy",
"{",
"clus",... | // NewClusterProxy takes optional prefix to fetch grpc-proxy member endpoints.
// The returned channel is closed when there is grpc-proxy endpoint registered
// and the client's context is canceled so the 'register' loop returns. | [
"NewClusterProxy",
"takes",
"optional",
"prefix",
"to",
"fetch",
"grpc",
"-",
"proxy",
"member",
"endpoints",
".",
"The",
"returned",
"channel",
"is",
"closed",
"when",
"there",
"is",
"grpc",
"-",
"proxy",
"endpoint",
"registered",
"and",
"the",
"client",
"s",... | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cluster.go#L51-L73 | test |
etcd-io/etcd | lease/leasehttp/http.go | NewHandler | func NewHandler(l lease.Lessor, waitch func() <-chan struct{}) http.Handler {
return &leaseHandler{l, waitch}
} | go | func NewHandler(l lease.Lessor, waitch func() <-chan struct{}) http.Handler {
return &leaseHandler{l, waitch}
} | [
"func",
"NewHandler",
"(",
"l",
"lease",
".",
"Lessor",
",",
"waitch",
"func",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
")",
"http",
".",
"Handler",
"{",
"return",
"&",
"leaseHandler",
"{",
"l",
",",
"waitch",
"}",
"\n",
"}"
] | // NewHandler returns an http Handler for lease renewals | [
"NewHandler",
"returns",
"an",
"http",
"Handler",
"for",
"lease",
"renewals"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/leasehttp/http.go#L40-L42 | test |
etcd-io/etcd | lease/leasehttp/http.go | TimeToLiveHTTP | func TimeToLiveHTTP(ctx context.Context, id lease.LeaseID, keys bool, url string, rt http.RoundTripper) (*leasepb.LeaseInternalResponse, error) {
// will post lreq protobuf to leader
lreq, err := (&leasepb.LeaseInternalRequest{
LeaseTimeToLiveRequest: &pb.LeaseTimeToLiveRequest{
ID: int64(id),
Keys: keys,
... | go | func TimeToLiveHTTP(ctx context.Context, id lease.LeaseID, keys bool, url string, rt http.RoundTripper) (*leasepb.LeaseInternalResponse, error) {
// will post lreq protobuf to leader
lreq, err := (&leasepb.LeaseInternalRequest{
LeaseTimeToLiveRequest: &pb.LeaseTimeToLiveRequest{
ID: int64(id),
Keys: keys,
... | [
"func",
"TimeToLiveHTTP",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"lease",
".",
"LeaseID",
",",
"keys",
"bool",
",",
"url",
"string",
",",
"rt",
"http",
".",
"RoundTripper",
")",
"(",
"*",
"leasepb",
".",
"LeaseInternalResponse",
",",
"error",
... | // TimeToLiveHTTP retrieves lease information of the given lease ID. | [
"TimeToLiveHTTP",
"retrieves",
"lease",
"information",
"of",
"the",
"given",
"lease",
"ID",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/leasehttp/http.go#L193-L242 | test |
etcd-io/etcd | mvcc/watcher_group.go | newWatcherBatch | func newWatcherBatch(wg *watcherGroup, evs []mvccpb.Event) watcherBatch {
if len(wg.watchers) == 0 {
return nil
}
wb := make(watcherBatch)
for _, ev := range evs {
for w := range wg.watcherSetByKey(string(ev.Kv.Key)) {
if ev.Kv.ModRevision >= w.minRev {
// don't double notify
wb.add(w, ev)
}
}
... | go | func newWatcherBatch(wg *watcherGroup, evs []mvccpb.Event) watcherBatch {
if len(wg.watchers) == 0 {
return nil
}
wb := make(watcherBatch)
for _, ev := range evs {
for w := range wg.watcherSetByKey(string(ev.Kv.Key)) {
if ev.Kv.ModRevision >= w.minRev {
// don't double notify
wb.add(w, ev)
}
}
... | [
"func",
"newWatcherBatch",
"(",
"wg",
"*",
"watcherGroup",
",",
"evs",
"[",
"]",
"mvccpb",
".",
"Event",
")",
"watcherBatch",
"{",
"if",
"len",
"(",
"wg",
".",
"watchers",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"wb",
":=",
"make",
"... | // newWatcherBatch maps watchers to their matched events. It enables quick
// events look up by watcher. | [
"newWatcherBatch",
"maps",
"watchers",
"to",
"their",
"matched",
"events",
".",
"It",
"enables",
"quick",
"events",
"look",
"up",
"by",
"watcher",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher_group.go#L81-L96 | test |
etcd-io/etcd | mvcc/watcher_group.go | add | func (wg *watcherGroup) add(wa *watcher) {
wg.watchers.add(wa)
if wa.end == nil {
wg.keyWatchers.add(wa)
return
}
// interval already registered?
ivl := adt.NewStringAffineInterval(string(wa.key), string(wa.end))
if iv := wg.ranges.Find(ivl); iv != nil {
iv.Val.(watcherSet).add(wa)
return
}
// not reg... | go | func (wg *watcherGroup) add(wa *watcher) {
wg.watchers.add(wa)
if wa.end == nil {
wg.keyWatchers.add(wa)
return
}
// interval already registered?
ivl := adt.NewStringAffineInterval(string(wa.key), string(wa.end))
if iv := wg.ranges.Find(ivl); iv != nil {
iv.Val.(watcherSet).add(wa)
return
}
// not reg... | [
"func",
"(",
"wg",
"*",
"watcherGroup",
")",
"add",
"(",
"wa",
"*",
"watcher",
")",
"{",
"wg",
".",
"watchers",
".",
"add",
"(",
"wa",
")",
"\n",
"if",
"wa",
".",
"end",
"==",
"nil",
"{",
"wg",
".",
"keyWatchers",
".",
"add",
"(",
"wa",
")",
... | // add puts a watcher in the group. | [
"add",
"puts",
"a",
"watcher",
"in",
"the",
"group",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher_group.go#L164-L182 | test |
etcd-io/etcd | mvcc/watcher_group.go | contains | func (wg *watcherGroup) contains(key string) bool {
_, ok := wg.keyWatchers[key]
return ok || wg.ranges.Intersects(adt.NewStringAffinePoint(key))
} | go | func (wg *watcherGroup) contains(key string) bool {
_, ok := wg.keyWatchers[key]
return ok || wg.ranges.Intersects(adt.NewStringAffinePoint(key))
} | [
"func",
"(",
"wg",
"*",
"watcherGroup",
")",
"contains",
"(",
"key",
"string",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"wg",
".",
"keyWatchers",
"[",
"key",
"]",
"\n",
"return",
"ok",
"||",
"wg",
".",
"ranges",
".",
"Intersects",
"(",
"adt",
".",
... | // contains is whether the given key has a watcher in the group. | [
"contains",
"is",
"whether",
"the",
"given",
"key",
"has",
"a",
"watcher",
"in",
"the",
"group",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher_group.go#L185-L188 | test |
etcd-io/etcd | mvcc/watcher_group.go | delete | func (wg *watcherGroup) delete(wa *watcher) bool {
if _, ok := wg.watchers[wa]; !ok {
return false
}
wg.watchers.delete(wa)
if wa.end == nil {
wg.keyWatchers.delete(wa)
return true
}
ivl := adt.NewStringAffineInterval(string(wa.key), string(wa.end))
iv := wg.ranges.Find(ivl)
if iv == nil {
return false... | go | func (wg *watcherGroup) delete(wa *watcher) bool {
if _, ok := wg.watchers[wa]; !ok {
return false
}
wg.watchers.delete(wa)
if wa.end == nil {
wg.keyWatchers.delete(wa)
return true
}
ivl := adt.NewStringAffineInterval(string(wa.key), string(wa.end))
iv := wg.ranges.Find(ivl)
if iv == nil {
return false... | [
"func",
"(",
"wg",
"*",
"watcherGroup",
")",
"delete",
"(",
"wa",
"*",
"watcher",
")",
"bool",
"{",
"if",
"_",
",",
"ok",
":=",
"wg",
".",
"watchers",
"[",
"wa",
"]",
";",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"wg",
".",
"watchers... | // delete removes a watcher from the group. | [
"delete",
"removes",
"a",
"watcher",
"from",
"the",
"group",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher_group.go#L194-L220 | test |
etcd-io/etcd | mvcc/watcher_group.go | choose | func (wg *watcherGroup) choose(maxWatchers int, curRev, compactRev int64) (*watcherGroup, int64) {
if len(wg.watchers) < maxWatchers {
return wg, wg.chooseAll(curRev, compactRev)
}
ret := newWatcherGroup()
for w := range wg.watchers {
if maxWatchers <= 0 {
break
}
maxWatchers--
ret.add(w)
}
return &r... | go | func (wg *watcherGroup) choose(maxWatchers int, curRev, compactRev int64) (*watcherGroup, int64) {
if len(wg.watchers) < maxWatchers {
return wg, wg.chooseAll(curRev, compactRev)
}
ret := newWatcherGroup()
for w := range wg.watchers {
if maxWatchers <= 0 {
break
}
maxWatchers--
ret.add(w)
}
return &r... | [
"func",
"(",
"wg",
"*",
"watcherGroup",
")",
"choose",
"(",
"maxWatchers",
"int",
",",
"curRev",
",",
"compactRev",
"int64",
")",
"(",
"*",
"watcherGroup",
",",
"int64",
")",
"{",
"if",
"len",
"(",
"wg",
".",
"watchers",
")",
"<",
"maxWatchers",
"{",
... | // choose selects watchers from the watcher group to update | [
"choose",
"selects",
"watchers",
"from",
"the",
"watcher",
"group",
"to",
"update"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher_group.go#L223-L236 | test |
etcd-io/etcd | mvcc/watcher_group.go | watcherSetByKey | func (wg *watcherGroup) watcherSetByKey(key string) watcherSet {
wkeys := wg.keyWatchers[key]
wranges := wg.ranges.Stab(adt.NewStringAffinePoint(key))
// zero-copy cases
switch {
case len(wranges) == 0:
// no need to merge ranges or copy; reuse single-key set
return wkeys
case len(wranges) == 0 && len(wkeys)... | go | func (wg *watcherGroup) watcherSetByKey(key string) watcherSet {
wkeys := wg.keyWatchers[key]
wranges := wg.ranges.Stab(adt.NewStringAffinePoint(key))
// zero-copy cases
switch {
case len(wranges) == 0:
// no need to merge ranges or copy; reuse single-key set
return wkeys
case len(wranges) == 0 && len(wkeys)... | [
"func",
"(",
"wg",
"*",
"watcherGroup",
")",
"watcherSetByKey",
"(",
"key",
"string",
")",
"watcherSet",
"{",
"wkeys",
":=",
"wg",
".",
"keyWatchers",
"[",
"key",
"]",
"\n",
"wranges",
":=",
"wg",
".",
"ranges",
".",
"Stab",
"(",
"adt",
".",
"NewString... | // watcherSetByKey gets the set of watchers that receive events on the given key. | [
"watcherSetByKey",
"gets",
"the",
"set",
"of",
"watchers",
"that",
"receive",
"events",
"on",
"the",
"given",
"key",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher_group.go#L270-L292 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Compare | func (ivl *Interval) Compare(c Comparable) int {
ivl2 := c.(*Interval)
ivbCmpBegin := ivl.Begin.Compare(ivl2.Begin)
ivbCmpEnd := ivl.Begin.Compare(ivl2.End)
iveCmpBegin := ivl.End.Compare(ivl2.Begin)
// ivl is left of ivl2
if ivbCmpBegin < 0 && iveCmpBegin <= 0 {
return -1
}
// iv is right of iv2
if ivbCmp... | go | func (ivl *Interval) Compare(c Comparable) int {
ivl2 := c.(*Interval)
ivbCmpBegin := ivl.Begin.Compare(ivl2.Begin)
ivbCmpEnd := ivl.Begin.Compare(ivl2.End)
iveCmpBegin := ivl.End.Compare(ivl2.Begin)
// ivl is left of ivl2
if ivbCmpBegin < 0 && iveCmpBegin <= 0 {
return -1
}
// iv is right of iv2
if ivbCmp... | [
"func",
"(",
"ivl",
"*",
"Interval",
")",
"Compare",
"(",
"c",
"Comparable",
")",
"int",
"{",
"ivl2",
":=",
"c",
".",
"(",
"*",
"Interval",
")",
"\n",
"ivbCmpBegin",
":=",
"ivl",
".",
"Begin",
".",
"Compare",
"(",
"ivl2",
".",
"Begin",
")",
"\n",
... | // Compare on an interval gives == if the interval overlaps. | [
"Compare",
"on",
"an",
"interval",
"gives",
"==",
"if",
"the",
"interval",
"overlaps",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L46-L63 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | successor | func (x *intervalNode) successor() *intervalNode {
if x.right != nil {
return x.right.min()
}
y := x.parent
for y != nil && x == y.right {
x = y
y = y.parent
}
return y
} | go | func (x *intervalNode) successor() *intervalNode {
if x.right != nil {
return x.right.min()
}
y := x.parent
for y != nil && x == y.right {
x = y
y = y.parent
}
return y
} | [
"func",
"(",
"x",
"*",
"intervalNode",
")",
"successor",
"(",
")",
"*",
"intervalNode",
"{",
"if",
"x",
".",
"right",
"!=",
"nil",
"{",
"return",
"x",
".",
"right",
".",
"min",
"(",
")",
"\n",
"}",
"\n",
"y",
":=",
"x",
".",
"parent",
"\n",
"fo... | // successor is the next in-order node in the tree | [
"successor",
"is",
"the",
"next",
"in",
"-",
"order",
"node",
"in",
"the",
"tree"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L104-L114 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | updateMax | func (x *intervalNode) updateMax() {
for x != nil {
oldmax := x.max
max := x.iv.Ivl.End
if x.left != nil && x.left.max.Compare(max) > 0 {
max = x.left.max
}
if x.right != nil && x.right.max.Compare(max) > 0 {
max = x.right.max
}
if oldmax.Compare(max) == 0 {
break
}
x.max = max
x = x.paren... | go | func (x *intervalNode) updateMax() {
for x != nil {
oldmax := x.max
max := x.iv.Ivl.End
if x.left != nil && x.left.max.Compare(max) > 0 {
max = x.left.max
}
if x.right != nil && x.right.max.Compare(max) > 0 {
max = x.right.max
}
if oldmax.Compare(max) == 0 {
break
}
x.max = max
x = x.paren... | [
"func",
"(",
"x",
"*",
"intervalNode",
")",
"updateMax",
"(",
")",
"{",
"for",
"x",
"!=",
"nil",
"{",
"oldmax",
":=",
"x",
".",
"max",
"\n",
"max",
":=",
"x",
".",
"iv",
".",
"Ivl",
".",
"End",
"\n",
"if",
"x",
".",
"left",
"!=",
"nil",
"&&",... | // updateMax updates the maximum values for a node and its ancestors | [
"updateMax",
"updates",
"the",
"maximum",
"values",
"for",
"a",
"node",
"and",
"its",
"ancestors"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L117-L133 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | visit | func (x *intervalNode) visit(iv *Interval, nv nodeVisitor) bool {
if x == nil {
return true
}
v := iv.Compare(&x.iv.Ivl)
switch {
case v < 0:
if !x.left.visit(iv, nv) {
return false
}
case v > 0:
maxiv := Interval{x.iv.Ivl.Begin, x.max}
if maxiv.Compare(iv) == 0 {
if !x.left.visit(iv, nv) || !x.ri... | go | func (x *intervalNode) visit(iv *Interval, nv nodeVisitor) bool {
if x == nil {
return true
}
v := iv.Compare(&x.iv.Ivl)
switch {
case v < 0:
if !x.left.visit(iv, nv) {
return false
}
case v > 0:
maxiv := Interval{x.iv.Ivl.Begin, x.max}
if maxiv.Compare(iv) == 0 {
if !x.left.visit(iv, nv) || !x.ri... | [
"func",
"(",
"x",
"*",
"intervalNode",
")",
"visit",
"(",
"iv",
"*",
"Interval",
",",
"nv",
"nodeVisitor",
")",
"bool",
"{",
"if",
"x",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"v",
":=",
"iv",
".",
"Compare",
"(",
"&",
"x",
".",
"i... | // visit will call a node visitor on each node that overlaps the given interval | [
"visit",
"will",
"call",
"a",
"node",
"visitor",
"on",
"each",
"node",
"that",
"overlaps",
"the",
"given",
"interval"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L138-L161 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Delete | func (ivt *IntervalTree) Delete(ivl Interval) bool {
z := ivt.find(ivl)
if z == nil {
return false
}
y := z
if z.left != nil && z.right != nil {
y = z.successor()
}
x := y.left
if x == nil {
x = y.right
}
if x != nil {
x.parent = y.parent
}
if y.parent == nil {
ivt.root = x
} else {
if y == ... | go | func (ivt *IntervalTree) Delete(ivl Interval) bool {
z := ivt.find(ivl)
if z == nil {
return false
}
y := z
if z.left != nil && z.right != nil {
y = z.successor()
}
x := y.left
if x == nil {
x = y.right
}
if x != nil {
x.parent = y.parent
}
if y.parent == nil {
ivt.root = x
} else {
if y == ... | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Delete",
"(",
"ivl",
"Interval",
")",
"bool",
"{",
"z",
":=",
"ivt",
".",
"find",
"(",
"ivl",
")",
"\n",
"if",
"z",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"y",
":=",
"z",
"\n",
"if",... | // Delete removes the node with the given interval from the tree, returning
// true if a node is in fact removed. | [
"Delete",
"removes",
"the",
"node",
"with",
"the",
"given",
"interval",
"from",
"the",
"tree",
"returning",
"true",
"if",
"a",
"node",
"is",
"in",
"fact",
"removed",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L178-L218 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | Insert | func (ivt *IntervalTree) Insert(ivl Interval, val interface{}) {
var y *intervalNode
z := &intervalNode{iv: IntervalValue{ivl, val}, max: ivl.End, c: red}
x := ivt.root
for x != nil {
y = x
if z.iv.Ivl.Begin.Compare(x.iv.Ivl.Begin) < 0 {
x = x.left
} else {
x = x.right
}
}
z.parent = y
if y == nil... | go | func (ivt *IntervalTree) Insert(ivl Interval, val interface{}) {
var y *intervalNode
z := &intervalNode{iv: IntervalValue{ivl, val}, max: ivl.End, c: red}
x := ivt.root
for x != nil {
y = x
if z.iv.Ivl.Begin.Compare(x.iv.Ivl.Begin) < 0 {
x = x.left
} else {
x = x.right
}
}
z.parent = y
if y == nil... | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Insert",
"(",
"ivl",
"Interval",
",",
"val",
"interface",
"{",
"}",
")",
"{",
"var",
"y",
"*",
"intervalNode",
"\n",
"z",
":=",
"&",
"intervalNode",
"{",
"iv",
":",
"IntervalValue",
"{",
"ivl",
",",
"val... | // Insert adds a node with the given interval into the tree. | [
"Insert",
"adds",
"a",
"node",
"with",
"the",
"given",
"interval",
"into",
"the",
"tree",
"."
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L285-L312 | test |
etcd-io/etcd | pkg/adt/interval_tree.go | rotateLeft | func (ivt *IntervalTree) rotateLeft(x *intervalNode) {
y := x.right
x.right = y.left
if y.left != nil {
y.left.parent = x
}
x.updateMax()
ivt.replaceParent(x, y)
y.left = x
y.updateMax()
} | go | func (ivt *IntervalTree) rotateLeft(x *intervalNode) {
y := x.right
x.right = y.left
if y.left != nil {
y.left.parent = x
}
x.updateMax()
ivt.replaceParent(x, y)
y.left = x
y.updateMax()
} | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"rotateLeft",
"(",
"x",
"*",
"intervalNode",
")",
"{",
"y",
":=",
"x",
".",
"right",
"\n",
"x",
".",
"right",
"=",
"y",
".",
"left",
"\n",
"if",
"y",
".",
"left",
"!=",
"nil",
"{",
"y",
".",
"left",... | // rotateLeft moves x so it is left of its right child | [
"rotateLeft",
"moves",
"x",
"so",
"it",
"is",
"left",
"of",
"its",
"right",
"child"
] | 616592d9ba993e3fe9798eef581316016df98906 | https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L355-L365 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.