repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
google/seesaw | engine/core.go | syncRPC | func (e *Engine) syncRPC() {
// TODO(jsing): Make this default to IPv6, if configured.
addr := &net.TCPAddr{
IP: e.config.Node.IPv4Addr,
Port: e.config.SyncPort,
}
ln, err := net.ListenTCP("tcp", addr)
if err != nil {
log.Fatalf("Listen failed: %v", err)
}
go e.syncServer.serve(ln)
<-e.shutdownRPC
ln... | go | func (e *Engine) syncRPC() {
// TODO(jsing): Make this default to IPv6, if configured.
addr := &net.TCPAddr{
IP: e.config.Node.IPv4Addr,
Port: e.config.SyncPort,
}
ln, err := net.ListenTCP("tcp", addr)
if err != nil {
log.Fatalf("Listen failed: %v", err)
}
go e.syncServer.serve(ln)
<-e.shutdownRPC
ln... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"syncRPC",
"(",
")",
"{",
"// TODO(jsing): Make this default to IPv6, if configured.",
"addr",
":=",
"&",
"net",
".",
"TCPAddr",
"{",
"IP",
":",
"e",
".",
"config",
".",
"Node",
".",
"IPv4Addr",
",",
"Port",
":",
"e",
... | // syncRPC starts a server to handle synchronisation RPCs via a TCP socket. | [
"syncRPC",
"starts",
"a",
"server",
"to",
"handle",
"synchronisation",
"RPCs",
"via",
"a",
"TCP",
"socket",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L229-L245 | train |
google/seesaw | engine/core.go | initNetwork | func (e *Engine) initNetwork() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
if e.config.AnycastEnabled {
if err := e.ncc.BGPWithdrawAll(); err != nil {
log.Fatalf("Failed to withdraw all BGP advertisements: %v", err)
}
}
if err := e.ncc.IPV... | go | func (e *Engine) initNetwork() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
if e.config.AnycastEnabled {
if err := e.ncc.BGPWithdrawAll(); err != nil {
log.Fatalf("Failed to withdraw all BGP advertisements: %v", err)
}
}
if err := e.ncc.IPV... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"initNetwork",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"... | // initNetwork initialises the network configuration for load balancing. | [
"initNetwork",
"initialises",
"the",
"network",
"configuration",
"for",
"load",
"balancing",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L248-L280 | train |
google/seesaw | engine/core.go | initAnycast | func (e *Engine) initAnycast() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
vips := make([]*seesaw.VIP, 0)
if e.config.ClusterVIP.IPv4Addr != nil {
for _, ip := range e.config.ServiceAnycastIPv4 {
vips = append(vips, seesaw.NewVIP(ip, nil))
... | go | func (e *Engine) initAnycast() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
vips := make([]*seesaw.VIP, 0)
if e.config.ClusterVIP.IPv4Addr != nil {
for _, ip := range e.config.ServiceAnycastIPv4 {
vips = append(vips, seesaw.NewVIP(ip, nil))
... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"initAnycast",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"... | // initAnycast initialises the anycast configuration. | [
"initAnycast",
"initialises",
"the",
"anycast",
"configuration",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L283-L309 | train |
google/seesaw | engine/core.go | gratuitousARP | func (e *Engine) gratuitousARP() {
arpTicker := time.NewTicker(e.config.GratuitousARPInterval)
var announced bool
for {
select {
case <-arpTicker.C:
if e.haManager.state() != seesaw.HAMaster {
if announced {
log.Infof("Stopping gratuitous ARPs for %s", e.config.ClusterVIP.IPv4Addr)
announced = f... | go | func (e *Engine) gratuitousARP() {
arpTicker := time.NewTicker(e.config.GratuitousARPInterval)
var announced bool
for {
select {
case <-arpTicker.C:
if e.haManager.state() != seesaw.HAMaster {
if announced {
log.Infof("Stopping gratuitous ARPs for %s", e.config.ClusterVIP.IPv4Addr)
announced = f... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"gratuitousARP",
"(",
")",
"{",
"arpTicker",
":=",
"time",
".",
"NewTicker",
"(",
"e",
".",
"config",
".",
"GratuitousARPInterval",
")",
"\n",
"var",
"announced",
"bool",
"\n",
"for",
"{",
"select",
"{",
"case",
"<... | // gratuitousARP sends gratuitous ARP messages at regular intervals, if this
// node is the HA master. | [
"gratuitousARP",
"sends",
"gratuitous",
"ARP",
"messages",
"at",
"regular",
"intervals",
"if",
"this",
"node",
"is",
"the",
"HA",
"master",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L313-L344 | train |
google/seesaw | engine/core.go | updateVservers | func (e *Engine) updateVservers() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
// Delete vservers that no longer exist in the new configuration.
for name, vserver := range e.vservers {
if cluster.Vservers[name] == nil {
log.Infof("Stopping unconfigured vserver %s", name)
vserver.st... | go | func (e *Engine) updateVservers() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
// Delete vservers that no longer exist in the new configuration.
for name, vserver := range e.vservers {
if cluster.Vservers[name] == nil {
log.Infof("Stopping unconfigured vserver %s", name)
vserver.st... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"updateVservers",
"(",
")",
"{",
"e",
".",
"clusterLock",
".",
"RLock",
"(",
")",
"\n",
"cluster",
":=",
"e",
".",
"cluster",
"\n",
"e",
".",
"clusterLock",
".",
"RUnlock",
"(",
")",
"\n\n",
"// Delete vservers tha... | // updateVservers processes a list of vserver configurations then stops
// deleted vservers, spawns new vservers and updates the existing vservers. | [
"updateVservers",
"processes",
"a",
"list",
"of",
"vserver",
"configurations",
"then",
"stops",
"deleted",
"vservers",
"spawns",
"new",
"vservers",
"and",
"updates",
"the",
"existing",
"vservers",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L448-L480 | train |
google/seesaw | engine/core.go | shutdownVservers | func (e *Engine) shutdownVservers() {
for _, v := range e.vservers {
v.stop()
}
for name, v := range e.vservers {
<-v.stopped
delete(e.vservers, name)
}
e.vserverLock.Lock()
e.vserverSnapshots = make(map[string]*seesaw.Vserver)
e.vserverLock.Unlock()
} | go | func (e *Engine) shutdownVservers() {
for _, v := range e.vservers {
v.stop()
}
for name, v := range e.vservers {
<-v.stopped
delete(e.vservers, name)
}
e.vserverLock.Lock()
e.vserverSnapshots = make(map[string]*seesaw.Vserver)
e.vserverLock.Unlock()
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"shutdownVservers",
"(",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"e",
".",
"vservers",
"{",
"v",
".",
"stop",
"(",
")",
"\n",
"}",
"\n",
"for",
"name",
",",
"v",
":=",
"range",
"e",
".",
"vservers",
... | // shutdownVservers shuts down all running vservers. | [
"shutdownVservers",
"shuts",
"down",
"all",
"running",
"vservers",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L483-L494 | train |
google/seesaw | engine/core.go | updateVLANs | func (e *Engine) updateVLANs() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
add := make([]*seesaw.VLAN, 0)
remove := make([]*seesaw.VLAN, 0)
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for key, vlan := range e.vlans {
if cluster.VLANs[key] == nil {
remove = append(remove, vlan)
... | go | func (e *Engine) updateVLANs() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
add := make([]*seesaw.VLAN, 0)
remove := make([]*seesaw.VLAN, 0)
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for key, vlan := range e.vlans {
if cluster.VLANs[key] == nil {
remove = append(remove, vlan)
... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"updateVLANs",
"(",
")",
"{",
"e",
".",
"clusterLock",
".",
"RLock",
"(",
")",
"\n",
"cluster",
":=",
"e",
".",
"cluster",
"\n",
"e",
".",
"clusterLock",
".",
"RUnlock",
"(",
")",
"\n\n",
"add",
":=",
"make",
... | // updateVLANs creates and destroys VLAN interfaces for the load balancer per
// the cluster configuration. | [
"updateVLANs",
"creates",
"and",
"destroys",
"VLAN",
"interfaces",
"for",
"the",
"load",
"balancer",
"per",
"the",
"cluster",
"configuration",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L498-L544 | train |
google/seesaw | engine/core.go | deleteVLANs | func (e *Engine) deleteVLANs() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for k, v := range e.vlans {
if err := e.lbInterface.DeleteVLAN(v); err != nil {
log.Fatalf("Failed to remove VLAN interfa... | go | func (e *Engine) deleteVLANs() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for k, v := range e.vlans {
if err := e.lbInterface.DeleteVLAN(v); err != nil {
log.Fatalf("Failed to remove VLAN interfa... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"deleteVLANs",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"... | // deleteVLANs removes all the VLAN interfaces that have been created by this
// engine. | [
"deleteVLANs",
"removes",
"all",
"the",
"VLAN",
"interfaces",
"that",
"have",
"been",
"created",
"by",
"this",
"engine",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L548-L563 | train |
google/seesaw | engine/core.go | handleOverride | func (e *Engine) handleOverride(o seesaw.Override) {
e.overrides[o.Target()] = o
e.distributeOverride(o)
if o.State() == seesaw.OverrideDefault {
delete(e.overrides, o.Target())
}
} | go | func (e *Engine) handleOverride(o seesaw.Override) {
e.overrides[o.Target()] = o
e.distributeOverride(o)
if o.State() == seesaw.OverrideDefault {
delete(e.overrides, o.Target())
}
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"handleOverride",
"(",
"o",
"seesaw",
".",
"Override",
")",
"{",
"e",
".",
"overrides",
"[",
"o",
".",
"Target",
"(",
")",
"]",
"=",
"o",
"\n",
"e",
".",
"distributeOverride",
"(",
"o",
")",
"\n",
"if",
"o",
... | // handleOverride handles an incoming Override. | [
"handleOverride",
"handles",
"an",
"incoming",
"Override",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L566-L572 | train |
google/seesaw | engine/core.go | distributeOverride | func (e *Engine) distributeOverride(o seesaw.Override) {
// Send VserverOverrides and DestinationOverrides to the appropriate vserver.
// Send BackendOverrides to all vservers.
switch override := o.(type) {
case *seesaw.VserverOverride:
if vserver, ok := e.vservers[override.VserverName]; ok {
vserver.queueOver... | go | func (e *Engine) distributeOverride(o seesaw.Override) {
// Send VserverOverrides and DestinationOverrides to the appropriate vserver.
// Send BackendOverrides to all vservers.
switch override := o.(type) {
case *seesaw.VserverOverride:
if vserver, ok := e.vservers[override.VserverName]; ok {
vserver.queueOver... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"distributeOverride",
"(",
"o",
"seesaw",
".",
"Override",
")",
"{",
"// Send VserverOverrides and DestinationOverrides to the appropriate vserver.",
"// Send BackendOverrides to all vservers.",
"switch",
"override",
":=",
"o",
".",
"("... | // distributeOverride distributes an Override to the appropriate vservers. | [
"distributeOverride",
"distributes",
"an",
"Override",
"to",
"the",
"appropriate",
"vservers",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L575-L592 | train |
google/seesaw | engine/core.go | becomeMaster | func (e *Engine) becomeMaster() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.disable()
e.hcManager.enable()
e.notifier.SetSource(config.SourceServer)
if err := e.lbInterface.Up(); err != nil {
log.Fatalf("Failed to bring LB interf... | go | func (e *Engine) becomeMaster() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.disable()
e.hcManager.enable()
e.notifier.SetSource(config.SourceServer)
if err := e.lbInterface.Up(); err != nil {
log.Fatalf("Failed to bring LB interf... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"becomeMaster",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
... | // becomeMaster performs the necessary actions for the Seesaw Engine to
// become the master node. | [
"becomeMaster",
"performs",
"the",
"necessary",
"actions",
"for",
"the",
"Seesaw",
"Engine",
"to",
"become",
"the",
"master",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L596-L609 | train |
google/seesaw | engine/core.go | becomeBackup | func (e *Engine) becomeBackup() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.enable()
e.hcManager.disable()
e.notifier.SetSource(config.SourcePeer)
if err := e.lbInterface.Down(); err != nil {
log.Fatalf("Failed to bring LB interf... | go | func (e *Engine) becomeBackup() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.enable()
e.hcManager.disable()
e.notifier.SetSource(config.SourcePeer)
if err := e.lbInterface.Down(); err != nil {
log.Fatalf("Failed to bring LB interf... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"becomeBackup",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
... | // becomeBackup performs the neccesary actions for the Seesaw Engine to
// stop being the master node and become the backup node. | [
"becomeBackup",
"performs",
"the",
"neccesary",
"actions",
"for",
"the",
"Seesaw",
"Engine",
"to",
"stop",
"being",
"the",
"master",
"node",
"and",
"become",
"the",
"backup",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L613-L631 | train |
google/seesaw | engine/core.go | newMarkAllocator | func newMarkAllocator(base, size int) *markAllocator {
ma := &markAllocator{
marks: make([]uint32, 0, size),
}
for i := 0; i < size; i++ {
ma.put(uint32(base + i))
}
return ma
} | go | func newMarkAllocator(base, size int) *markAllocator {
ma := &markAllocator{
marks: make([]uint32, 0, size),
}
for i := 0; i < size; i++ {
ma.put(uint32(base + i))
}
return ma
} | [
"func",
"newMarkAllocator",
"(",
"base",
",",
"size",
"int",
")",
"*",
"markAllocator",
"{",
"ma",
":=",
"&",
"markAllocator",
"{",
"marks",
":",
"make",
"(",
"[",
"]",
"uint32",
",",
"0",
",",
"size",
")",
",",
"}",
"\n",
"for",
"i",
":=",
"0",
... | // newMarkAllocator returns a mark allocator initialised with the specified
// base and size. | [
"newMarkAllocator",
"returns",
"a",
"mark",
"allocator",
"initialised",
"with",
"the",
"specified",
"base",
"and",
"size",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L641-L649 | train |
google/seesaw | engine/core.go | get | func (ma *markAllocator) get() (uint32, error) {
ma.lock.Lock()
defer ma.lock.Unlock()
if len(ma.marks) == 0 {
return 0, errors.New("allocator exhausted")
}
mark := ma.marks[0]
ma.marks = ma.marks[1:]
return mark, nil
} | go | func (ma *markAllocator) get() (uint32, error) {
ma.lock.Lock()
defer ma.lock.Unlock()
if len(ma.marks) == 0 {
return 0, errors.New("allocator exhausted")
}
mark := ma.marks[0]
ma.marks = ma.marks[1:]
return mark, nil
} | [
"func",
"(",
"ma",
"*",
"markAllocator",
")",
"get",
"(",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"ma",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ma",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"len",
"(",
"ma",
".",
"mar... | // get returns the next available mark from the mark allocator. | [
"get",
"returns",
"the",
"next",
"available",
"mark",
"from",
"the",
"mark",
"allocator",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L652-L661 | train |
google/seesaw | engine/core.go | put | func (ma *markAllocator) put(mark uint32) {
ma.lock.Lock()
defer ma.lock.Unlock()
ma.marks = append(ma.marks, mark)
} | go | func (ma *markAllocator) put(mark uint32) {
ma.lock.Lock()
defer ma.lock.Unlock()
ma.marks = append(ma.marks, mark)
} | [
"func",
"(",
"ma",
"*",
"markAllocator",
")",
"put",
"(",
"mark",
"uint32",
")",
"{",
"ma",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ma",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"ma",
".",
"marks",
"=",
"append",
"(",
"ma",
".",
... | // put returns the specified mark to the mark allocator. | [
"put",
"returns",
"the",
"specified",
"mark",
"to",
"the",
"mark",
"allocator",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L664-L668 | train |
google/seesaw | ecu/auth.go | authenticate | func (e *ECU) authenticate(ctx *ipc.Context) (*ipc.Context, error) {
return nil, errors.New("unimplemented")
} | go | func (e *ECU) authenticate(ctx *ipc.Context) (*ipc.Context, error) {
return nil, errors.New("unimplemented")
} | [
"func",
"(",
"e",
"*",
"ECU",
")",
"authenticate",
"(",
"ctx",
"*",
"ipc",
".",
"Context",
")",
"(",
"*",
"ipc",
".",
"Context",
",",
"error",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // authenticate attempts to validate the given authentication token. | [
"authenticate",
"attempts",
"to",
"validate",
"the",
"given",
"authentication",
"token",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/auth.go#L36-L38 | train |
google/seesaw | ecu/auth.go | authConnect | func (e *ECU) authConnect(ctx *ipc.Context) (*conn.Seesaw, error) {
if ctx == nil {
return nil, errors.New("context is nil")
}
authCtx, err := e.authenticate(ctx)
if err != nil {
return nil, fmt.Errorf("authentication failed: %v", err)
}
seesawConn, err := conn.NewSeesawIPC(authCtx)
if err != nil {
return... | go | func (e *ECU) authConnect(ctx *ipc.Context) (*conn.Seesaw, error) {
if ctx == nil {
return nil, errors.New("context is nil")
}
authCtx, err := e.authenticate(ctx)
if err != nil {
return nil, fmt.Errorf("authentication failed: %v", err)
}
seesawConn, err := conn.NewSeesawIPC(authCtx)
if err != nil {
return... | [
"func",
"(",
"e",
"*",
"ECU",
")",
"authConnect",
"(",
"ctx",
"*",
"ipc",
".",
"Context",
")",
"(",
"*",
"conn",
".",
"Seesaw",
",",
"error",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | // authConnect attempts to authenticate the user using the given context. If
// authentication succeeds an authenticated IPC connection to the Seesaw
// Engine is returned. | [
"authConnect",
"attempts",
"to",
"authenticate",
"the",
"user",
"using",
"the",
"given",
"context",
".",
"If",
"authentication",
"succeeds",
"an",
"authenticated",
"IPC",
"connection",
"to",
"the",
"Seesaw",
"Engine",
"is",
"returned",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/auth.go#L43-L61 | train |
google/seesaw | binaries/seesaw_cli/main.go | commandChain | func commandChain(chain []*cli.Command, args []string) string {
s := make([]string, 0)
for _, c := range chain {
s = append(s, c.Command)
}
s = append(s, args...)
if len(s) > 0 && len(args) == 0 {
s = append(s, "")
}
return strings.Join(s, " ")
} | go | func commandChain(chain []*cli.Command, args []string) string {
s := make([]string, 0)
for _, c := range chain {
s = append(s, c.Command)
}
s = append(s, args...)
if len(s) > 0 && len(args) == 0 {
s = append(s, "")
}
return strings.Join(s, " ")
} | [
"func",
"commandChain",
"(",
"chain",
"[",
"]",
"*",
"cli",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"string",
"{",
"s",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"chain",
"{",... | // commandChain builds a command chain from the given command slice. | [
"commandChain",
"builds",
"a",
"command",
"chain",
"from",
"the",
"given",
"command",
"slice",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_cli/main.go#L93-L103 | train |
google/seesaw | binaries/seesaw_cli/main.go | autoComplete | func autoComplete(line string, pos int, key rune) (string, int, bool) {
switch key {
case 0x01: // Ctrl-A
return line, 0, true
case 0x03: // Ctrl-C
exit()
case 0x05: // Ctrl-E
return line, len(line), true
case 0x09: // Ctrl-I (Tab)
_, _, chain, args := cli.FindCommand(string(line))
line := commandChain(c... | go | func autoComplete(line string, pos int, key rune) (string, int, bool) {
switch key {
case 0x01: // Ctrl-A
return line, 0, true
case 0x03: // Ctrl-C
exit()
case 0x05: // Ctrl-E
return line, len(line), true
case 0x09: // Ctrl-I (Tab)
_, _, chain, args := cli.FindCommand(string(line))
line := commandChain(c... | [
"func",
"autoComplete",
"(",
"line",
"string",
",",
"pos",
"int",
",",
"key",
"rune",
")",
"(",
"string",
",",
"int",
",",
"bool",
")",
"{",
"switch",
"key",
"{",
"case",
"0x01",
":",
"// Ctrl-A",
"return",
"line",
",",
"0",
",",
"true",
"\n",
"cas... | // autoComplete attempts to complete the user's input when certain
// characters are typed. | [
"autoComplete",
"attempts",
"to",
"complete",
"the",
"user",
"s",
"input",
"when",
"certain",
"characters",
"are",
"typed",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_cli/main.go#L107-L143 | train |
google/seesaw | binaries/seesaw_cli/main.go | interactive | func interactive() {
status, err := seesawConn.ClusterStatus()
if err != nil {
fatalf("Failed to get cluster status: %v", err)
}
fmt.Printf("\nSeesaw CLI - Engine version %d\n\n", status.Version)
u, err := user.Current()
if err != nil {
fatalf("Failed to get current user: %v", err)
}
ha, err := seesawConn... | go | func interactive() {
status, err := seesawConn.ClusterStatus()
if err != nil {
fatalf("Failed to get cluster status: %v", err)
}
fmt.Printf("\nSeesaw CLI - Engine version %d\n\n", status.Version)
u, err := user.Current()
if err != nil {
fatalf("Failed to get current user: %v", err)
}
ha, err := seesawConn... | [
"func",
"interactive",
"(",
")",
"{",
"status",
",",
"err",
":=",
"seesawConn",
".",
"ClusterStatus",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\... | // interactive invokes the interactive CLI interface. | [
"interactive",
"invokes",
"the",
"interactive",
"CLI",
"interface",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_cli/main.go#L146-L191 | train |
google/seesaw | ipvs/ipvs.go | newIPVSService | func newIPVSService(svc *Service) *ipvsService {
ipvsSvc := &ipvsService{
Address: svc.Address,
Protocol: svc.Protocol,
Port: svc.Port,
FirewallMark: svc.FirewallMark,
Scheduler: svc.Scheduler,
Flags: svc.Flags,
Timeout: svc.Timeout,
Pe... | go | func newIPVSService(svc *Service) *ipvsService {
ipvsSvc := &ipvsService{
Address: svc.Address,
Protocol: svc.Protocol,
Port: svc.Port,
FirewallMark: svc.FirewallMark,
Scheduler: svc.Scheduler,
Flags: svc.Flags,
Timeout: svc.Timeout,
Pe... | [
"func",
"newIPVSService",
"(",
"svc",
"*",
"Service",
")",
"*",
"ipvsService",
"{",
"ipvsSvc",
":=",
"&",
"ipvsService",
"{",
"Address",
":",
"svc",
".",
"Address",
",",
"Protocol",
":",
"svc",
".",
"Protocol",
",",
"Port",
":",
"svc",
".",
"Port",
","... | // newIPVSService converts a service to its IPVS representation. | [
"newIPVSService",
"converts",
"a",
"service",
"to",
"its",
"IPVS",
"representation",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L81-L102 | train |
google/seesaw | ipvs/ipvs.go | newIPVSDestination | func newIPVSDestination(dst *Destination) *ipvsDestination {
return &ipvsDestination{
Address: dst.Address,
Port: dst.Port,
Flags: dst.Flags,
Weight: uint32(dst.Weight),
UpperThreshold: dst.UpperThreshold,
LowerThreshold: dst.LowerThreshold,
}
} | go | func newIPVSDestination(dst *Destination) *ipvsDestination {
return &ipvsDestination{
Address: dst.Address,
Port: dst.Port,
Flags: dst.Flags,
Weight: uint32(dst.Weight),
UpperThreshold: dst.UpperThreshold,
LowerThreshold: dst.LowerThreshold,
}
} | [
"func",
"newIPVSDestination",
"(",
"dst",
"*",
"Destination",
")",
"*",
"ipvsDestination",
"{",
"return",
"&",
"ipvsDestination",
"{",
"Address",
":",
"dst",
".",
"Address",
",",
"Port",
":",
"dst",
".",
"Port",
",",
"Flags",
":",
"dst",
".",
"Flags",
",... | // newIPVSDestination converts a destination to its IPVS representation. | [
"newIPVSDestination",
"converts",
"a",
"destination",
"to",
"its",
"IPVS",
"representation",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L105-L114 | train |
google/seesaw | ipvs/ipvs.go | toService | func (ipvsSvc ipvsService) toService() *Service {
svc := &Service{
Address: ipvsSvc.Address,
Protocol: ipvsSvc.Protocol,
Port: ipvsSvc.Port,
FirewallMark: ipvsSvc.FirewallMark,
Scheduler: ipvsSvc.Scheduler,
Flags: ipvsSvc.Flags,
Timeout: ... | go | func (ipvsSvc ipvsService) toService() *Service {
svc := &Service{
Address: ipvsSvc.Address,
Protocol: ipvsSvc.Protocol,
Port: ipvsSvc.Port,
FirewallMark: ipvsSvc.FirewallMark,
Scheduler: ipvsSvc.Scheduler,
Flags: ipvsSvc.Flags,
Timeout: ... | [
"func",
"(",
"ipvsSvc",
"ipvsService",
")",
"toService",
"(",
")",
"*",
"Service",
"{",
"svc",
":=",
"&",
"Service",
"{",
"Address",
":",
"ipvsSvc",
".",
"Address",
",",
"Protocol",
":",
"ipvsSvc",
".",
"Protocol",
",",
"Port",
":",
"ipvsSvc",
".",
"Po... | // toService converts a service entry from its IPVS representation to the Go
// equivalent Service structure. | [
"toService",
"converts",
"a",
"service",
"entry",
"from",
"its",
"IPVS",
"representation",
"to",
"the",
"Go",
"equivalent",
"Service",
"structure",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L118-L147 | train |
google/seesaw | ipvs/ipvs.go | toDestination | func (ipvsDst ipvsDestination) toDestination() *Destination {
dst := &Destination{
Address: ipvsDst.Address,
Port: ipvsDst.Port,
Weight: int32(ipvsDst.Weight), // TODO(jsing): uint32?
Flags: ipvsDst.Flags,
LowerThreshold: ipvsDst.LowerThreshold,
UpperThreshold: ipvsDst.Upp... | go | func (ipvsDst ipvsDestination) toDestination() *Destination {
dst := &Destination{
Address: ipvsDst.Address,
Port: ipvsDst.Port,
Weight: int32(ipvsDst.Weight), // TODO(jsing): uint32?
Flags: ipvsDst.Flags,
LowerThreshold: ipvsDst.LowerThreshold,
UpperThreshold: ipvsDst.Upp... | [
"func",
"(",
"ipvsDst",
"ipvsDestination",
")",
"toDestination",
"(",
")",
"*",
"Destination",
"{",
"dst",
":=",
"&",
"Destination",
"{",
"Address",
":",
"ipvsDst",
".",
"Address",
",",
"Port",
":",
"ipvsDst",
".",
"Port",
",",
"Weight",
":",
"int32",
"(... | // toDestination converts a destination entry from its IPVS representation
// to the Go equivalent Destination structure. | [
"toDestination",
"converts",
"a",
"destination",
"entry",
"from",
"its",
"IPVS",
"representation",
"to",
"the",
"Go",
"equivalent",
"Destination",
"structure",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L151-L171 | train |
google/seesaw | ipvs/ipvs.go | Bytes | func (f ServiceFlags) Bytes() []byte {
x := make([]byte, 8)
var b [4]byte
*(*uint32)(unsafe.Pointer(&b)) = uint32(f)
copy(x[:4], b[:])
*(*uint32)(unsafe.Pointer(&b)) = ^uint32(0)
copy(x[4:], b[:])
return x
} | go | func (f ServiceFlags) Bytes() []byte {
x := make([]byte, 8)
var b [4]byte
*(*uint32)(unsafe.Pointer(&b)) = uint32(f)
copy(x[:4], b[:])
*(*uint32)(unsafe.Pointer(&b)) = ^uint32(0)
copy(x[4:], b[:])
return x
} | [
"func",
"(",
"f",
"ServiceFlags",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"x",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"8",
")",
"\n",
"var",
"b",
"[",
"4",
"]",
"byte",
"\n",
"*",
"(",
"*",
"uint32",
")",
"(",
"unsafe",
".",
"Poin... | // Bytes returns the netlink representation of the service flags. | [
"Bytes",
"returns",
"the",
"netlink",
"representation",
"of",
"the",
"service",
"flags",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L203-L211 | train |
google/seesaw | ipvs/ipvs.go | SetBytes | func (f *ServiceFlags) SetBytes(x []byte) {
var b [4]byte
copy(b[:], x)
*f = ServiceFlags(*(*uint32)(unsafe.Pointer(&b)))
} | go | func (f *ServiceFlags) SetBytes(x []byte) {
var b [4]byte
copy(b[:], x)
*f = ServiceFlags(*(*uint32)(unsafe.Pointer(&b)))
} | [
"func",
"(",
"f",
"*",
"ServiceFlags",
")",
"SetBytes",
"(",
"x",
"[",
"]",
"byte",
")",
"{",
"var",
"b",
"[",
"4",
"]",
"byte",
"\n",
"copy",
"(",
"b",
"[",
":",
"]",
",",
"x",
")",
"\n",
"*",
"f",
"=",
"ServiceFlags",
"(",
"*",
"(",
"*",
... | // SetBytes sets the service flags from its netlink representation. | [
"SetBytes",
"sets",
"the",
"service",
"flags",
"from",
"its",
"netlink",
"representation",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L214-L218 | train |
google/seesaw | ipvs/ipvs.go | Equal | func (svc Service) Equal(other Service) bool {
return svc.Address.Equal(other.Address) &&
svc.Protocol == other.Protocol &&
svc.Port == other.Port &&
svc.FirewallMark == other.FirewallMark &&
svc.Scheduler == other.Scheduler &&
svc.Flags == other.Flags &&
svc.Timeout == other.Timeout &&
svc.PersistenceEn... | go | func (svc Service) Equal(other Service) bool {
return svc.Address.Equal(other.Address) &&
svc.Protocol == other.Protocol &&
svc.Port == other.Port &&
svc.FirewallMark == other.FirewallMark &&
svc.Scheduler == other.Scheduler &&
svc.Flags == other.Flags &&
svc.Timeout == other.Timeout &&
svc.PersistenceEn... | [
"func",
"(",
"svc",
"Service",
")",
"Equal",
"(",
"other",
"Service",
")",
"bool",
"{",
"return",
"svc",
".",
"Address",
".",
"Equal",
"(",
"other",
".",
"Address",
")",
"&&",
"svc",
".",
"Protocol",
"==",
"other",
".",
"Protocol",
"&&",
"svc",
".",
... | // Equal returns true if two Services are the same. | [
"Equal",
"returns",
"true",
"if",
"two",
"Services",
"are",
"the",
"same",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L241-L250 | train |
google/seesaw | ipvs/ipvs.go | String | func (svc Service) String() string {
switch {
case svc.FirewallMark > 0:
return fmt.Sprintf("FWM %d (%s)", svc.FirewallMark, svc.Scheduler)
case svc.Address.To4() == nil:
return fmt.Sprintf("%v [%v]:%d (%s)", svc.Protocol, svc.Address, svc.Port, svc.Scheduler)
default:
return fmt.Sprintf("%v %v:%d (%s)", svc.... | go | func (svc Service) String() string {
switch {
case svc.FirewallMark > 0:
return fmt.Sprintf("FWM %d (%s)", svc.FirewallMark, svc.Scheduler)
case svc.Address.To4() == nil:
return fmt.Sprintf("%v [%v]:%d (%s)", svc.Protocol, svc.Address, svc.Port, svc.Scheduler)
default:
return fmt.Sprintf("%v %v:%d (%s)", svc.... | [
"func",
"(",
"svc",
"Service",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"{",
"case",
"svc",
".",
"FirewallMark",
">",
"0",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"svc",
".",
"FirewallMark",
",",
"svc",
".",
"Scheduler",
... | // String returns a string representation of a Service. | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"a",
"Service",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L253-L262 | train |
google/seesaw | ipvs/ipvs.go | Equal | func (dest Destination) Equal(other Destination) bool {
return dest.Address.Equal(other.Address) &&
dest.Port == other.Port &&
dest.Weight == other.Weight &&
dest.Flags == other.Flags &&
dest.LowerThreshold == other.LowerThreshold &&
dest.UpperThreshold == other.UpperThreshold
} | go | func (dest Destination) Equal(other Destination) bool {
return dest.Address.Equal(other.Address) &&
dest.Port == other.Port &&
dest.Weight == other.Weight &&
dest.Flags == other.Flags &&
dest.LowerThreshold == other.LowerThreshold &&
dest.UpperThreshold == other.UpperThreshold
} | [
"func",
"(",
"dest",
"Destination",
")",
"Equal",
"(",
"other",
"Destination",
")",
"bool",
"{",
"return",
"dest",
".",
"Address",
".",
"Equal",
"(",
"other",
".",
"Address",
")",
"&&",
"dest",
".",
"Port",
"==",
"other",
".",
"Port",
"&&",
"dest",
"... | // Equal returns true if two Destinations are the same. | [
"Equal",
"returns",
"true",
"if",
"two",
"Destinations",
"are",
"the",
"same",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L288-L295 | train |
google/seesaw | ipvs/ipvs.go | String | func (dest Destination) String() string {
addr := dest.Address.String()
if dest.Address.To4() == nil {
addr = fmt.Sprintf("[%s]", addr)
}
return fmt.Sprintf("%s:%d", addr, dest.Port)
} | go | func (dest Destination) String() string {
addr := dest.Address.String()
if dest.Address.To4() == nil {
addr = fmt.Sprintf("[%s]", addr)
}
return fmt.Sprintf("%s:%d", addr, dest.Port)
} | [
"func",
"(",
"dest",
"Destination",
")",
"String",
"(",
")",
"string",
"{",
"addr",
":=",
"dest",
".",
"Address",
".",
"String",
"(",
")",
"\n",
"if",
"dest",
".",
"Address",
".",
"To4",
"(",
")",
"==",
"nil",
"{",
"addr",
"=",
"fmt",
".",
"Sprin... | // String returns a string representation of a Destination. | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"a",
"Destination",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L298-L304 | train |
google/seesaw | ipvs/ipvs.go | Init | func Init() error {
var err error
family, err = netlink.Family(familyName)
if err != nil {
return err
}
return netlink.SendMessageUnmarshal(C.IPVS_CMD_GET_INFO, family, 0, &info)
} | go | func Init() error {
var err error
family, err = netlink.Family(familyName)
if err != nil {
return err
}
return netlink.SendMessageUnmarshal(C.IPVS_CMD_GET_INFO, family, 0, &info)
} | [
"func",
"Init",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"family",
",",
"err",
"=",
"netlink",
".",
"Family",
"(",
"familyName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"netlink",
".",
"Se... | // Init intialises IPVS. | [
"Init",
"intialises",
"IPVS",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L356-L364 | train |
google/seesaw | ipvs/ipvs.go | Version | func Version() IPVSVersion {
v := uint(info.Version)
return IPVSVersion{
Major: (v >> 16) & 0xff,
Minor: (v >> 8) & 0xff,
Patch: v & 0xff,
}
} | go | func Version() IPVSVersion {
v := uint(info.Version)
return IPVSVersion{
Major: (v >> 16) & 0xff,
Minor: (v >> 8) & 0xff,
Patch: v & 0xff,
}
} | [
"func",
"Version",
"(",
")",
"IPVSVersion",
"{",
"v",
":=",
"uint",
"(",
"info",
".",
"Version",
")",
"\n",
"return",
"IPVSVersion",
"{",
"Major",
":",
"(",
"v",
">>",
"16",
")",
"&",
"0xff",
",",
"Minor",
":",
"(",
"v",
">>",
"8",
")",
"&",
"0... | // Version returns the version number for IPVS. | [
"Version",
"returns",
"the",
"version",
"number",
"for",
"IPVS",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L367-L374 | train |
google/seesaw | ipvs/ipvs.go | AddService | func AddService(svc Service) error {
ic := &ipvsCommand{Service: newIPVSService(&svc)}
if err := netlink.SendMessageMarshalled(C.IPVS_CMD_NEW_SERVICE, family, 0, ic); err != nil {
return err
}
for _, dst := range svc.Destinations {
if err := AddDestination(svc, *dst); err != nil {
return err
}
}
return n... | go | func AddService(svc Service) error {
ic := &ipvsCommand{Service: newIPVSService(&svc)}
if err := netlink.SendMessageMarshalled(C.IPVS_CMD_NEW_SERVICE, family, 0, ic); err != nil {
return err
}
for _, dst := range svc.Destinations {
if err := AddDestination(svc, *dst); err != nil {
return err
}
}
return n... | [
"func",
"AddService",
"(",
"svc",
"Service",
")",
"error",
"{",
"ic",
":=",
"&",
"ipvsCommand",
"{",
"Service",
":",
"newIPVSService",
"(",
"&",
"svc",
")",
"}",
"\n",
"if",
"err",
":=",
"netlink",
".",
"SendMessageMarshalled",
"(",
"C",
".",
"IPVS_CMD_N... | // AddService adds the specified service to the IPVS table. Any destinations
// associated with the given service will also be added. | [
"AddService",
"adds",
"the",
"specified",
"service",
"to",
"the",
"IPVS",
"table",
".",
"Any",
"destinations",
"associated",
"with",
"the",
"given",
"service",
"will",
"also",
"be",
"added",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L383-L394 | train |
google/seesaw | ipvs/ipvs.go | UpdateService | func UpdateService(svc Service) error {
ic := &ipvsCommand{Service: newIPVSService(&svc)}
return netlink.SendMessageMarshalled(C.IPVS_CMD_SET_SERVICE, family, 0, ic)
} | go | func UpdateService(svc Service) error {
ic := &ipvsCommand{Service: newIPVSService(&svc)}
return netlink.SendMessageMarshalled(C.IPVS_CMD_SET_SERVICE, family, 0, ic)
} | [
"func",
"UpdateService",
"(",
"svc",
"Service",
")",
"error",
"{",
"ic",
":=",
"&",
"ipvsCommand",
"{",
"Service",
":",
"newIPVSService",
"(",
"&",
"svc",
")",
"}",
"\n",
"return",
"netlink",
".",
"SendMessageMarshalled",
"(",
"C",
".",
"IPVS_CMD_SET_SERVICE... | // UpdateService updates the specified service in the IPVS table. | [
"UpdateService",
"updates",
"the",
"specified",
"service",
"in",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L397-L400 | train |
google/seesaw | ipvs/ipvs.go | DeleteService | func DeleteService(svc Service) error {
ic := &ipvsCommand{Service: newIPVSService(&svc)}
return netlink.SendMessageMarshalled(C.IPVS_CMD_DEL_SERVICE, family, 0, ic)
} | go | func DeleteService(svc Service) error {
ic := &ipvsCommand{Service: newIPVSService(&svc)}
return netlink.SendMessageMarshalled(C.IPVS_CMD_DEL_SERVICE, family, 0, ic)
} | [
"func",
"DeleteService",
"(",
"svc",
"Service",
")",
"error",
"{",
"ic",
":=",
"&",
"ipvsCommand",
"{",
"Service",
":",
"newIPVSService",
"(",
"&",
"svc",
")",
"}",
"\n",
"return",
"netlink",
".",
"SendMessageMarshalled",
"(",
"C",
".",
"IPVS_CMD_DEL_SERVICE... | // DeleteService deletes the specified service from the IPVS table. | [
"DeleteService",
"deletes",
"the",
"specified",
"service",
"from",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L403-L406 | train |
google/seesaw | ipvs/ipvs.go | AddDestination | func AddDestination(svc Service, dst Destination) error {
ic := &ipvsCommand{
Service: newIPVSService(&svc),
Destination: newIPVSDestination(&dst),
}
return netlink.SendMessageMarshalled(C.IPVS_CMD_NEW_DEST, family, 0, ic)
} | go | func AddDestination(svc Service, dst Destination) error {
ic := &ipvsCommand{
Service: newIPVSService(&svc),
Destination: newIPVSDestination(&dst),
}
return netlink.SendMessageMarshalled(C.IPVS_CMD_NEW_DEST, family, 0, ic)
} | [
"func",
"AddDestination",
"(",
"svc",
"Service",
",",
"dst",
"Destination",
")",
"error",
"{",
"ic",
":=",
"&",
"ipvsCommand",
"{",
"Service",
":",
"newIPVSService",
"(",
"&",
"svc",
")",
",",
"Destination",
":",
"newIPVSDestination",
"(",
"&",
"dst",
")",... | // AddDestination adds the specified destination to the IPVS table. | [
"AddDestination",
"adds",
"the",
"specified",
"destination",
"to",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L409-L415 | train |
google/seesaw | ipvs/ipvs.go | UpdateDestination | func UpdateDestination(svc Service, dst Destination) error {
ic := &ipvsCommand{
Service: newIPVSService(&svc),
Destination: newIPVSDestination(&dst),
}
return netlink.SendMessageMarshalled(C.IPVS_CMD_SET_DEST, family, 0, ic)
} | go | func UpdateDestination(svc Service, dst Destination) error {
ic := &ipvsCommand{
Service: newIPVSService(&svc),
Destination: newIPVSDestination(&dst),
}
return netlink.SendMessageMarshalled(C.IPVS_CMD_SET_DEST, family, 0, ic)
} | [
"func",
"UpdateDestination",
"(",
"svc",
"Service",
",",
"dst",
"Destination",
")",
"error",
"{",
"ic",
":=",
"&",
"ipvsCommand",
"{",
"Service",
":",
"newIPVSService",
"(",
"&",
"svc",
")",
",",
"Destination",
":",
"newIPVSDestination",
"(",
"&",
"dst",
"... | // UpdateDestination updates the specified destination in the IPVS table. | [
"UpdateDestination",
"updates",
"the",
"specified",
"destination",
"in",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L418-L424 | train |
google/seesaw | ipvs/ipvs.go | DeleteDestination | func DeleteDestination(svc Service, dst Destination) error {
ic := &ipvsCommand{
Service: newIPVSService(&svc),
Destination: newIPVSDestination(&dst),
}
return netlink.SendMessageMarshalled(C.IPVS_CMD_DEL_DEST, family, 0, ic)
} | go | func DeleteDestination(svc Service, dst Destination) error {
ic := &ipvsCommand{
Service: newIPVSService(&svc),
Destination: newIPVSDestination(&dst),
}
return netlink.SendMessageMarshalled(C.IPVS_CMD_DEL_DEST, family, 0, ic)
} | [
"func",
"DeleteDestination",
"(",
"svc",
"Service",
",",
"dst",
"Destination",
")",
"error",
"{",
"ic",
":=",
"&",
"ipvsCommand",
"{",
"Service",
":",
"newIPVSService",
"(",
"&",
"svc",
")",
",",
"Destination",
":",
"newIPVSDestination",
"(",
"&",
"dst",
"... | // DeleteDestination deletes the specified destination from the IPVS table. | [
"DeleteDestination",
"deletes",
"the",
"specified",
"destination",
"from",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L427-L433 | train |
google/seesaw | ipvs/ipvs.go | destinations | func destinations(svc *Service) ([]*Destination, error) {
msg, err := netlink.NewMessage(C.IPVS_CMD_GET_DEST, family, netlink.MFDump)
if err != nil {
return nil, err
}
defer msg.Free()
ic := &ipvsCommand{Service: newIPVSService(svc)}
if err := msg.Marshal(ic); err != nil {
return nil, err
}
var dsts []*De... | go | func destinations(svc *Service) ([]*Destination, error) {
msg, err := netlink.NewMessage(C.IPVS_CMD_GET_DEST, family, netlink.MFDump)
if err != nil {
return nil, err
}
defer msg.Free()
ic := &ipvsCommand{Service: newIPVSService(svc)}
if err := msg.Marshal(ic); err != nil {
return nil, err
}
var dsts []*De... | [
"func",
"destinations",
"(",
"svc",
"*",
"Service",
")",
"(",
"[",
"]",
"*",
"Destination",
",",
"error",
")",
"{",
"msg",
",",
"err",
":=",
"netlink",
".",
"NewMessage",
"(",
"C",
".",
"IPVS_CMD_GET_DEST",
",",
"family",
",",
"netlink",
".",
"MFDump",... | // destinations returns a list of destinations that are currently
// configured in the kernel IPVS table for the specified service. | [
"destinations",
"returns",
"a",
"list",
"of",
"destinations",
"that",
"are",
"currently",
"configured",
"in",
"the",
"kernel",
"IPVS",
"table",
"for",
"the",
"specified",
"service",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L437-L465 | train |
google/seesaw | ipvs/ipvs.go | services | func services(svc *Service) ([]*Service, error) {
var flags int
if svc == nil {
flags = netlink.MFDump
}
msg, err := netlink.NewMessage(C.IPVS_CMD_GET_SERVICE, family, flags)
if err != nil {
return nil, err
}
defer msg.Free()
if svc != nil {
ic := &ipvsCommand{Service: newIPVSService(svc)}
if err := m... | go | func services(svc *Service) ([]*Service, error) {
var flags int
if svc == nil {
flags = netlink.MFDump
}
msg, err := netlink.NewMessage(C.IPVS_CMD_GET_SERVICE, family, flags)
if err != nil {
return nil, err
}
defer msg.Free()
if svc != nil {
ic := &ipvsCommand{Service: newIPVSService(svc)}
if err := m... | [
"func",
"services",
"(",
"svc",
"*",
"Service",
")",
"(",
"[",
"]",
"*",
"Service",
",",
"error",
")",
"{",
"var",
"flags",
"int",
"\n",
"if",
"svc",
"==",
"nil",
"{",
"flags",
"=",
"netlink",
".",
"MFDump",
"\n",
"}",
"\n\n",
"msg",
",",
"err",
... | // services returns a list of services that are currently configured in the
// kernel IPVS table. If a specific service is given, an exact match will be
// attempted and a single service will be returned if it is found. | [
"services",
"returns",
"a",
"list",
"of",
"services",
"that",
"are",
"currently",
"configured",
"in",
"the",
"kernel",
"IPVS",
"table",
".",
"If",
"a",
"specific",
"service",
"is",
"given",
"an",
"exact",
"match",
"will",
"be",
"attempted",
"and",
"a",
"si... | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L470-L514 | train |
google/seesaw | ipvs/ipvs.go | GetService | func GetService(svc *Service) (*Service, error) {
svcs, err := services(svc)
if err != nil {
return nil, err
}
if len(svcs) == 0 {
return nil, errors.New("no service found")
}
return svcs[0], nil
} | go | func GetService(svc *Service) (*Service, error) {
svcs, err := services(svc)
if err != nil {
return nil, err
}
if len(svcs) == 0 {
return nil, errors.New("no service found")
}
return svcs[0], nil
} | [
"func",
"GetService",
"(",
"svc",
"*",
"Service",
")",
"(",
"*",
"Service",
",",
"error",
")",
"{",
"svcs",
",",
"err",
":=",
"services",
"(",
"svc",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
... | // GetService returns the service entry that is currently configured in the
// kernel IPVS table, which matches the specified service. | [
"GetService",
"returns",
"the",
"service",
"entry",
"that",
"is",
"currently",
"configured",
"in",
"the",
"kernel",
"IPVS",
"table",
"which",
"matches",
"the",
"specified",
"service",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L518-L527 | train |
google/seesaw | common/conn/ipc.go | HAStatus | func (c *engineIPC) HAStatus() (*seesaw.HAStatus, error) {
var ha seesaw.HAStatus
if err := c.client.Call("SeesawEngine.HAStatus", c.ctx, &ha); err != nil {
return nil, err
}
return &ha, nil
} | go | func (c *engineIPC) HAStatus() (*seesaw.HAStatus, error) {
var ha seesaw.HAStatus
if err := c.client.Call("SeesawEngine.HAStatus", c.ctx, &ha); err != nil {
return nil, err
}
return &ha, nil
} | [
"func",
"(",
"c",
"*",
"engineIPC",
")",
"HAStatus",
"(",
")",
"(",
"*",
"seesaw",
".",
"HAStatus",
",",
"error",
")",
"{",
"var",
"ha",
"seesaw",
".",
"HAStatus",
"\n",
"if",
"err",
":=",
"c",
".",
"client",
".",
"Call",
"(",
"\"",
"\"",
",",
... | // HAStatus requests the HA status of the Seesaw Node. | [
"HAStatus",
"requests",
"the",
"HA",
"status",
"of",
"the",
"Seesaw",
"Node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/conn/ipc.go#L85-L91 | train |
google/seesaw | common/conn/ipc.go | ConfigSource | func (c *engineIPC) ConfigSource(source string) (string, error) {
cs := &ipc.ConfigSource{c.ctx, source}
if err := c.client.Call("SeesawEngine.ConfigSource", cs, &source); err != nil {
return "", err
}
return source, nil
} | go | func (c *engineIPC) ConfigSource(source string) (string, error) {
cs := &ipc.ConfigSource{c.ctx, source}
if err := c.client.Call("SeesawEngine.ConfigSource", cs, &source); err != nil {
return "", err
}
return source, nil
} | [
"func",
"(",
"c",
"*",
"engineIPC",
")",
"ConfigSource",
"(",
"source",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"cs",
":=",
"&",
"ipc",
".",
"ConfigSource",
"{",
"c",
".",
"ctx",
",",
"source",
"}",
"\n",
"if",
"err",
":=",
"c",
"."... | // ConfigSource requests the configuration source be changed to the
// specified source. An empty string results in the source remaining
// unchanged. The current configuration source is returned. | [
"ConfigSource",
"requests",
"the",
"configuration",
"source",
"be",
"changed",
"to",
"the",
"specified",
"source",
".",
"An",
"empty",
"string",
"results",
"in",
"the",
"source",
"remaining",
"unchanged",
".",
"The",
"current",
"configuration",
"source",
"is",
"... | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/conn/ipc.go#L96-L102 | train |
google/seesaw | common/conn/ipc.go | BGPNeighbors | func (c *engineIPC) BGPNeighbors() ([]*quagga.Neighbor, error) {
var bn quagga.Neighbors
if err := c.client.Call("SeesawEngine.BGPNeighbors", c.ctx, &bn); err != nil {
return nil, err
}
return bn.Neighbors, nil
} | go | func (c *engineIPC) BGPNeighbors() ([]*quagga.Neighbor, error) {
var bn quagga.Neighbors
if err := c.client.Call("SeesawEngine.BGPNeighbors", c.ctx, &bn); err != nil {
return nil, err
}
return bn.Neighbors, nil
} | [
"func",
"(",
"c",
"*",
"engineIPC",
")",
"BGPNeighbors",
"(",
")",
"(",
"[",
"]",
"*",
"quagga",
".",
"Neighbor",
",",
"error",
")",
"{",
"var",
"bn",
"quagga",
".",
"Neighbors",
"\n",
"if",
"err",
":=",
"c",
".",
"client",
".",
"Call",
"(",
"\""... | // BGPNeighbors requests a list of all BGP neighbors that this seesaw is
// peering with. | [
"BGPNeighbors",
"requests",
"a",
"list",
"of",
"all",
"BGP",
"neighbors",
"that",
"this",
"seesaw",
"is",
"peering",
"with",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/conn/ipc.go#L111-L117 | train |
google/seesaw | common/conn/ipc.go | VLANs | func (c *engineIPC) VLANs() (*seesaw.VLANs, error) {
var v seesaw.VLANs
if err := c.client.Call("SeesawEngine.VLANs", c.ctx, &v); err != nil {
return nil, err
}
return &v, nil
} | go | func (c *engineIPC) VLANs() (*seesaw.VLANs, error) {
var v seesaw.VLANs
if err := c.client.Call("SeesawEngine.VLANs", c.ctx, &v); err != nil {
return nil, err
}
return &v, nil
} | [
"func",
"(",
"c",
"*",
"engineIPC",
")",
"VLANs",
"(",
")",
"(",
"*",
"seesaw",
".",
"VLANs",
",",
"error",
")",
"{",
"var",
"v",
"seesaw",
".",
"VLANs",
"\n",
"if",
"err",
":=",
"c",
".",
"client",
".",
"Call",
"(",
"\"",
"\"",
",",
"c",
"."... | // VLANs requests a list of VLANs configured on the cluster. | [
"VLANs",
"requests",
"a",
"list",
"of",
"VLANs",
"configured",
"on",
"the",
"cluster",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/conn/ipc.go#L120-L126 | train |
google/seesaw | common/conn/ipc.go | Vservers | func (c *engineIPC) Vservers() (map[string]*seesaw.Vserver, error) {
var vm seesaw.VserverMap
if err := c.client.Call("SeesawEngine.Vservers", c.ctx, &vm); err != nil {
return nil, err
}
return vm.Vservers, nil
} | go | func (c *engineIPC) Vservers() (map[string]*seesaw.Vserver, error) {
var vm seesaw.VserverMap
if err := c.client.Call("SeesawEngine.Vservers", c.ctx, &vm); err != nil {
return nil, err
}
return vm.Vservers, nil
} | [
"func",
"(",
"c",
"*",
"engineIPC",
")",
"Vservers",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"seesaw",
".",
"Vserver",
",",
"error",
")",
"{",
"var",
"vm",
"seesaw",
".",
"VserverMap",
"\n",
"if",
"err",
":=",
"c",
".",
"client",
".",
"Cal... | // Vservers requests a list of all vservers that are configured on the cluster. | [
"Vservers",
"requests",
"a",
"list",
"of",
"all",
"vservers",
"that",
"are",
"configured",
"on",
"the",
"cluster",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/conn/ipc.go#L129-L135 | train |
google/seesaw | common/conn/ipc.go | OverrideVserver | func (c *engineIPC) OverrideVserver(vserver *seesaw.VserverOverride) error {
override := &ipc.Override{Ctx: c.ctx, Vserver: vserver}
return c.client.Call("SeesawEngine.OverrideVserver", override, nil)
} | go | func (c *engineIPC) OverrideVserver(vserver *seesaw.VserverOverride) error {
override := &ipc.Override{Ctx: c.ctx, Vserver: vserver}
return c.client.Call("SeesawEngine.OverrideVserver", override, nil)
} | [
"func",
"(",
"c",
"*",
"engineIPC",
")",
"OverrideVserver",
"(",
"vserver",
"*",
"seesaw",
".",
"VserverOverride",
")",
"error",
"{",
"override",
":=",
"&",
"ipc",
".",
"Override",
"{",
"Ctx",
":",
"c",
".",
"ctx",
",",
"Vserver",
":",
"vserver",
"}",
... | // OverrideVserver requests that the specified VserverOverride be applied. | [
"OverrideVserver",
"requests",
"that",
"the",
"specified",
"VserverOverride",
"be",
"applied",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/conn/ipc.go#L159-L162 | train |
google/seesaw | ha/engine_client.go | HAConfig | func (e *EngineClient) HAConfig() (*seesaw.HAConfig, error) {
engineConn, err := net.DialTimeout("unix", e.Socket, engineTimeout)
if err != nil {
return nil, fmt.Errorf("HAConfig: Dial failed: %v", err)
}
engineConn.SetDeadline(time.Now().Add(engineTimeout))
engine := rpc.NewClient(engineConn)
defer engine.Clos... | go | func (e *EngineClient) HAConfig() (*seesaw.HAConfig, error) {
engineConn, err := net.DialTimeout("unix", e.Socket, engineTimeout)
if err != nil {
return nil, fmt.Errorf("HAConfig: Dial failed: %v", err)
}
engineConn.SetDeadline(time.Now().Add(engineTimeout))
engine := rpc.NewClient(engineConn)
defer engine.Clos... | [
"func",
"(",
"e",
"*",
"EngineClient",
")",
"HAConfig",
"(",
")",
"(",
"*",
"seesaw",
".",
"HAConfig",
",",
"error",
")",
"{",
"engineConn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"\"",
"\"",
",",
"e",
".",
"Socket",
",",
"engineTimeout",
... | // HAConfig requests the HAConfig from the Seesaw Engine. | [
"HAConfig",
"requests",
"the",
"HAConfig",
"from",
"the",
"Seesaw",
"Engine",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/engine_client.go#L47-L62 | train |
google/seesaw | ha/engine_client.go | HAUpdate | func (e *EngineClient) HAUpdate(status seesaw.HAStatus) (bool, error) {
engineConn, err := net.DialTimeout("unix", e.Socket, engineTimeout)
if err != nil {
return false, fmt.Errorf("HAUpdate: Dial failed: %v", err)
}
engineConn.SetDeadline(time.Now().Add(engineTimeout))
engine := rpc.NewClient(engineConn)
defer... | go | func (e *EngineClient) HAUpdate(status seesaw.HAStatus) (bool, error) {
engineConn, err := net.DialTimeout("unix", e.Socket, engineTimeout)
if err != nil {
return false, fmt.Errorf("HAUpdate: Dial failed: %v", err)
}
engineConn.SetDeadline(time.Now().Add(engineTimeout))
engine := rpc.NewClient(engineConn)
defer... | [
"func",
"(",
"e",
"*",
"EngineClient",
")",
"HAUpdate",
"(",
"status",
"seesaw",
".",
"HAStatus",
")",
"(",
"bool",
",",
"error",
")",
"{",
"engineConn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"\"",
"\"",
",",
"e",
".",
"Socket",
",",
"e... | // HAUpdate informs the Seesaw Engine of the current HAStatus.
// The Seesaw Engine may request a failover in response. | [
"HAUpdate",
"informs",
"the",
"Seesaw",
"Engine",
"of",
"the",
"current",
"HAStatus",
".",
"The",
"Seesaw",
"Engine",
"may",
"request",
"a",
"failover",
"in",
"response",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/engine_client.go#L84-L99 | train |
google/seesaw | ha/engine_client.go | HAUpdate | func (e *DummyEngine) HAUpdate(status seesaw.HAStatus) (bool, error) {
return false, nil
} | go | func (e *DummyEngine) HAUpdate(status seesaw.HAStatus) (bool, error) {
return false, nil
} | [
"func",
"(",
"e",
"*",
"DummyEngine",
")",
"HAUpdate",
"(",
"status",
"seesaw",
".",
"HAStatus",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"false",
",",
"nil",
"\n",
"}"
] | // HAUpdate does nothing. | [
"HAUpdate",
"does",
"nothing",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/engine_client.go#L117-L119 | train |
google/seesaw | common/server/server.go | signalName | func signalName(s syscall.Signal) string {
if name, ok := signalNames[s]; ok {
return name
}
return fmt.Sprintf("SIG %d", s)
} | go | func signalName(s syscall.Signal) string {
if name, ok := signalNames[s]; ok {
return name
}
return fmt.Sprintf("SIG %d", s)
} | [
"func",
"signalName",
"(",
"s",
"syscall",
".",
"Signal",
")",
"string",
"{",
"if",
"name",
",",
"ok",
":=",
"signalNames",
"[",
"s",
"]",
";",
"ok",
"{",
"return",
"name",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"... | // signalName returns a string containing the standard name for a given signal. | [
"signalName",
"returns",
"a",
"string",
"containing",
"the",
"standard",
"name",
"for",
"a",
"given",
"signal",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/server/server.go#L48-L53 | train |
google/seesaw | common/server/server.go | ShutdownHandler | func ShutdownHandler(server Shutdowner) {
sigc := make(chan os.Signal, 3)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
go func() {
for s := range sigc {
name := s.String()
if sig, ok := s.(syscall.Signal); ok {
name = signalName(sig)
}
log.Infof("Received %v, initiating shu... | go | func ShutdownHandler(server Shutdowner) {
sigc := make(chan os.Signal, 3)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
go func() {
for s := range sigc {
name := s.String()
if sig, ok := s.(syscall.Signal); ok {
name = signalName(sig)
}
log.Infof("Received %v, initiating shu... | [
"func",
"ShutdownHandler",
"(",
"server",
"Shutdowner",
")",
"{",
"sigc",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"3",
")",
"\n",
"signal",
".",
"Notify",
"(",
"sigc",
",",
"syscall",
".",
"SIGINT",
",",
"syscall",
".",
"SIGQUIT",
",",
"... | // ShutdownHandler configures signal handling and initiates a shutdown if a
// SIGINT, SIGQUIT or SIGTERM is received by the process. | [
"ShutdownHandler",
"configures",
"signal",
"handling",
"and",
"initiates",
"a",
"shutdown",
"if",
"a",
"SIGINT",
"SIGQUIT",
"or",
"SIGTERM",
"is",
"received",
"by",
"the",
"process",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/server/server.go#L57-L70 | train |
google/seesaw | common/server/server.go | RemoveUnixSocket | func RemoveUnixSocket(socket string) error {
if _, err := os.Stat(socket); err == nil {
c, err := net.DialTimeout("unix", socket, 5*time.Second)
if err == nil {
c.Close()
return fmt.Errorf("Socket %v is in use", socket)
}
log.Infof("Removing stale socket %v", socket)
return os.Remove(socket)
}
return... | go | func RemoveUnixSocket(socket string) error {
if _, err := os.Stat(socket); err == nil {
c, err := net.DialTimeout("unix", socket, 5*time.Second)
if err == nil {
c.Close()
return fmt.Errorf("Socket %v is in use", socket)
}
log.Infof("Removing stale socket %v", socket)
return os.Remove(socket)
}
return... | [
"func",
"RemoveUnixSocket",
"(",
"socket",
"string",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"socket",
")",
";",
"err",
"==",
"nil",
"{",
"c",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"\"",
"\"",
",",
"soc... | // RemoveUnixSocket checks to see if the given socket already exists and
// removes it if nothing responds to connections. | [
"RemoveUnixSocket",
"checks",
"to",
"see",
"if",
"the",
"given",
"socket",
"already",
"exists",
"and",
"removes",
"it",
"if",
"nothing",
"responds",
"to",
"connections",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/server/server.go#L74-L85 | train |
google/seesaw | common/server/server.go | ServerRunDirectory | func ServerRunDirectory(server string, owner, group int) error {
serverRunDir := path.Join(seesaw.RunPath, server)
if err := os.MkdirAll(seesaw.RunPath, 0755); err != nil {
return fmt.Errorf("Failed to make run directory: %v", err)
}
if err := os.MkdirAll(serverRunDir, 0700); err != nil {
return fmt.Errorf("Fai... | go | func ServerRunDirectory(server string, owner, group int) error {
serverRunDir := path.Join(seesaw.RunPath, server)
if err := os.MkdirAll(seesaw.RunPath, 0755); err != nil {
return fmt.Errorf("Failed to make run directory: %v", err)
}
if err := os.MkdirAll(serverRunDir, 0700); err != nil {
return fmt.Errorf("Fai... | [
"func",
"ServerRunDirectory",
"(",
"server",
"string",
",",
"owner",
",",
"group",
"int",
")",
"error",
"{",
"serverRunDir",
":=",
"path",
".",
"Join",
"(",
"seesaw",
".",
"RunPath",
",",
"server",
")",
"\n",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"... | // ServerRunDirectory ensures that the run directory exists and has the
// appropriate ownership and permissions. | [
"ServerRunDirectory",
"ensures",
"that",
"the",
"run",
"directory",
"exists",
"and",
"has",
"the",
"appropriate",
"ownership",
"and",
"permissions",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/server/server.go#L89-L104 | train |
google/seesaw | common/server/server.go | RPCAccept | func RPCAccept(ln net.Listener, server *rpc.Server) error {
errClosing := errors.New("use of closed network connection")
for {
conn, err := ln.Accept()
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
log.Warningf("RPC accept temporary error: %v", err)
time.Sleep(1 * time.Second)
... | go | func RPCAccept(ln net.Listener, server *rpc.Server) error {
errClosing := errors.New("use of closed network connection")
for {
conn, err := ln.Accept()
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
log.Warningf("RPC accept temporary error: %v", err)
time.Sleep(1 * time.Second)
... | [
"func",
"RPCAccept",
"(",
"ln",
"net",
".",
"Listener",
",",
"server",
"*",
"rpc",
".",
"Server",
")",
"error",
"{",
"errClosing",
":=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"for",
"{",
"conn",
",",
"err",
":=",
"ln",
".",
"Accept",
... | // RPCAccept accepts connections on the listener and dispatches them to the
// RPC server for service. Unfortunately the native Go rpc.Accept function
// fatals on any accept error, including temporary failures and closure of
// the listener. | [
"RPCAccept",
"accepts",
"connections",
"on",
"the",
"listener",
"and",
"dispatches",
"them",
"to",
"the",
"RPC",
"server",
"for",
"service",
".",
"Unfortunately",
"the",
"native",
"Go",
"rpc",
".",
"Accept",
"function",
"fatals",
"on",
"any",
"accept",
"error"... | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/server/server.go#L110-L129 | train |
google/seesaw | engine/config/config.go | SourceByName | func SourceByName(name string) (Source, error) {
for s, n := range sourceNames {
if n == name {
return s, nil
}
}
return -1, fmt.Errorf("unknown source %q", name)
} | go | func SourceByName(name string) (Source, error) {
for s, n := range sourceNames {
if n == name {
return s, nil
}
}
return -1, fmt.Errorf("unknown source %q", name)
} | [
"func",
"SourceByName",
"(",
"name",
"string",
")",
"(",
"Source",
",",
"error",
")",
"{",
"for",
"s",
",",
"n",
":=",
"range",
"sourceNames",
"{",
"if",
"n",
"==",
"name",
"{",
"return",
"s",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"-"... | // SourceByName returns the source that has the given name. | [
"SourceByName",
"returns",
"the",
"source",
"that",
"has",
"the",
"given",
"name",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/config.go#L62-L69 | train |
google/seesaw | engine/config/config.go | String | func (s Source) String() string {
if name, ok := sourceNames[s]; ok {
return name
}
return "(unknown)"
} | go | func (s Source) String() string {
if name, ok := sourceNames[s]; ok {
return name
}
return "(unknown)"
} | [
"func",
"(",
"s",
"Source",
")",
"String",
"(",
")",
"string",
"{",
"if",
"name",
",",
"ok",
":=",
"sourceNames",
"[",
"s",
"]",
";",
"ok",
"{",
"return",
"name",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // String returns the string representation of a source. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"source",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/config.go#L72-L77 | train |
google/seesaw | engine/config/config.go | ReadConfig | func ReadConfig(filename, clusterName string) (*Notification, error) {
p := &pb.Cluster{}
b, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
if err = proto.UnmarshalText(string(b), p); err != nil {
return nil, err
}
c, err := protoToCluster(p, clusterName)
if err != nil {
return nil, e... | go | func ReadConfig(filename, clusterName string) (*Notification, error) {
p := &pb.Cluster{}
b, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
if err = proto.UnmarshalText(string(b), p); err != nil {
return nil, err
}
c, err := protoToCluster(p, clusterName)
if err != nil {
return nil, e... | [
"func",
"ReadConfig",
"(",
"filename",
",",
"clusterName",
"string",
")",
"(",
"*",
"Notification",
",",
"error",
")",
"{",
"p",
":=",
"&",
"pb",
".",
"Cluster",
"{",
"}",
"\n",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
... | // ReadConfig reads a cluster configuration file. | [
"ReadConfig",
"reads",
"a",
"cluster",
"configuration",
"file",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/config.go#L94-L109 | train |
google/seesaw | engine/config/config.go | ConfigFromServer | func ConfigFromServer(cluster string) (*Notification, error) {
cfg := DefaultEngineConfig()
cfg.ClusterName = cluster
n := &Notifier{engineCfg: &cfg}
return n.configFromServer()
} | go | func ConfigFromServer(cluster string) (*Notification, error) {
cfg := DefaultEngineConfig()
cfg.ClusterName = cluster
n := &Notifier{engineCfg: &cfg}
return n.configFromServer()
} | [
"func",
"ConfigFromServer",
"(",
"cluster",
"string",
")",
"(",
"*",
"Notification",
",",
"error",
")",
"{",
"cfg",
":=",
"DefaultEngineConfig",
"(",
")",
"\n",
"cfg",
".",
"ClusterName",
"=",
"cluster",
"\n",
"n",
":=",
"&",
"Notifier",
"{",
"engineCfg",
... | // ConfigFromServer fetches the cluster configuration for the given cluster. | [
"ConfigFromServer",
"fetches",
"the",
"cluster",
"configuration",
"for",
"the",
"given",
"cluster",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/config.go#L112-L117 | train |
google/seesaw | engine/config/config.go | pruneArchive | func pruneArchive(archiveDir string, refTime time.Time, max archiveConfig) (*pruneStats, error) {
d, err := os.Open(archiveDir)
if err != nil {
return nil, err
}
defer d.Close()
files, err := d.Readdir(0)
if err != nil {
return nil, err
}
sort.Sort(sort.Reverse(byModTime(files)))
var seen, curr pruneSta... | go | func pruneArchive(archiveDir string, refTime time.Time, max archiveConfig) (*pruneStats, error) {
d, err := os.Open(archiveDir)
if err != nil {
return nil, err
}
defer d.Close()
files, err := d.Readdir(0)
if err != nil {
return nil, err
}
sort.Sort(sort.Reverse(byModTime(files)))
var seen, curr pruneSta... | [
"func",
"pruneArchive",
"(",
"archiveDir",
"string",
",",
"refTime",
"time",
".",
"Time",
",",
"max",
"archiveConfig",
")",
"(",
"*",
"pruneStats",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"archiveDir",
")",
"\n",
"if",
... | // pruneArchive removes files from the given directory to ensure that the specified
// maximums are not exceeded. It returns the number of the files removed along with
// the maximums observed in the current archive. | [
"pruneArchive",
"removes",
"files",
"from",
"the",
"given",
"directory",
"to",
"ensure",
"that",
"the",
"specified",
"maximums",
"are",
"not",
"exceeded",
".",
"It",
"returns",
"the",
"number",
"of",
"the",
"files",
"removed",
"along",
"with",
"the",
"maximums... | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/config.go#L548-L575 | train |
google/seesaw | ncc/core.go | NewServer | func NewServer(socket string) *Server {
return &Server{
nccSocket: socket,
shutdown: make(chan bool),
}
} | go | func NewServer(socket string) *Server {
return &Server{
nccSocket: socket,
shutdown: make(chan bool),
}
} | [
"func",
"NewServer",
"(",
"socket",
"string",
")",
"*",
"Server",
"{",
"return",
"&",
"Server",
"{",
"nccSocket",
":",
"socket",
",",
"shutdown",
":",
"make",
"(",
"chan",
"bool",
")",
",",
"}",
"\n",
"}"
] | // NewServer returns an initialised NCC Server struct. | [
"NewServer",
"returns",
"an",
"initialised",
"NCC",
"Server",
"struct",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/core.go#L55-L60 | train |
google/seesaw | ncc/core.go | Run | func (n *Server) Run() {
if err := server.RemoveUnixSocket(n.nccSocket); err != nil {
log.Fatalf("Failed to remove socket: %v", err)
}
ln, err := net.Listen("unix", n.nccSocket)
if err != nil {
log.Fatalf("listen error: %v", err)
}
defer ln.Close()
defer os.Remove(n.nccSocket)
seesawNCC := rpc.NewServer()
... | go | func (n *Server) Run() {
if err := server.RemoveUnixSocket(n.nccSocket); err != nil {
log.Fatalf("Failed to remove socket: %v", err)
}
ln, err := net.Listen("unix", n.nccSocket)
if err != nil {
log.Fatalf("listen error: %v", err)
}
defer ln.Close()
defer os.Remove(n.nccSocket)
seesawNCC := rpc.NewServer()
... | [
"func",
"(",
"n",
"*",
"Server",
")",
"Run",
"(",
")",
"{",
"if",
"err",
":=",
"server",
".",
"RemoveUnixSocket",
"(",
"n",
".",
"nccSocket",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
... | // Run starts the NCC server. | [
"Run",
"starts",
"the",
"NCC",
"server",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/core.go#L63-L79 | train |
google/seesaw | ha/core.go | NewNode | func NewNode(cfg NodeConfig, conn HAConn, engine Engine) *Node {
n := &Node{
NodeConfig: cfg,
conn: conn,
engine: engine,
lastMasterAdvertTime: time.Now(),
errChannel: make(chan error),
recvChannel: make(chan *advertisement, 20),
stopSenderChanne... | go | func NewNode(cfg NodeConfig, conn HAConn, engine Engine) *Node {
n := &Node{
NodeConfig: cfg,
conn: conn,
engine: engine,
lastMasterAdvertTime: time.Now(),
errChannel: make(chan error),
recvChannel: make(chan *advertisement, 20),
stopSenderChanne... | [
"func",
"NewNode",
"(",
"cfg",
"NodeConfig",
",",
"conn",
"HAConn",
",",
"engine",
"Engine",
")",
"*",
"Node",
"{",
"n",
":=",
"&",
"Node",
"{",
"NodeConfig",
":",
"cfg",
",",
"conn",
":",
"conn",
",",
"engine",
":",
"engine",
",",
"lastMasterAdvertTim... | // NewNode creates a new Node with the given NodeConfig and HAConn. | [
"NewNode",
"creates",
"a",
"new",
"Node",
"with",
"the",
"given",
"NodeConfig",
"and",
"HAConn",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/core.go#L93-L107 | train |
google/seesaw | ha/core.go | resetMasterDownInterval | func (n *Node) resetMasterDownInterval(advertInterval time.Duration) {
skewTime := (time.Duration((256 - int(n.Priority))) * (advertInterval)) / 256
masterDownInterval := 3*(advertInterval) + skewTime
if masterDownInterval != n.masterDownInterval {
n.masterDownInterval = masterDownInterval
log.Infof("resetMaster... | go | func (n *Node) resetMasterDownInterval(advertInterval time.Duration) {
skewTime := (time.Duration((256 - int(n.Priority))) * (advertInterval)) / 256
masterDownInterval := 3*(advertInterval) + skewTime
if masterDownInterval != n.masterDownInterval {
n.masterDownInterval = masterDownInterval
log.Infof("resetMaster... | [
"func",
"(",
"n",
"*",
"Node",
")",
"resetMasterDownInterval",
"(",
"advertInterval",
"time",
".",
"Duration",
")",
"{",
"skewTime",
":=",
"(",
"time",
".",
"Duration",
"(",
"(",
"256",
"-",
"int",
"(",
"n",
".",
"Priority",
")",
")",
")",
"*",
"(",
... | // resetMasterDownInterval calculates masterDownInterval per RFC 5798. | [
"resetMasterDownInterval",
"calculates",
"masterDownInterval",
"per",
"RFC",
"5798",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/core.go#L110-L118 | train |
google/seesaw | ha/core.go | state | func (n *Node) state() seesaw.HAState {
n.statusLock.RLock()
defer n.statusLock.RUnlock()
return n.haStatus.State
} | go | func (n *Node) state() seesaw.HAState {
n.statusLock.RLock()
defer n.statusLock.RUnlock()
return n.haStatus.State
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"state",
"(",
")",
"seesaw",
".",
"HAState",
"{",
"n",
".",
"statusLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"statusLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"n",
".",
"haStatus",
".",
"Sta... | // state returns the current HA state for this node. | [
"state",
"returns",
"the",
"current",
"HA",
"state",
"for",
"this",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/core.go#L121-L125 | train |
google/seesaw | ha/core.go | setState | func (n *Node) setState(s seesaw.HAState) {
n.statusLock.Lock()
defer n.statusLock.Unlock()
if n.haStatus.State != s {
n.haStatus.State = s
n.haStatus.Since = time.Now()
n.haStatus.Transitions++
}
} | go | func (n *Node) setState(s seesaw.HAState) {
n.statusLock.Lock()
defer n.statusLock.Unlock()
if n.haStatus.State != s {
n.haStatus.State = s
n.haStatus.Since = time.Now()
n.haStatus.Transitions++
}
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"setState",
"(",
"s",
"seesaw",
".",
"HAState",
")",
"{",
"n",
".",
"statusLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"statusLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"n",
".",
"haStatus",
".",
... | // setState changes the HA state for this node. | [
"setState",
"changes",
"the",
"HA",
"state",
"for",
"this",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/core.go#L128-L136 | train |
google/seesaw | ha/core.go | status | func (n *Node) status() seesaw.HAStatus {
n.statusLock.Lock()
defer n.statusLock.Unlock()
n.haStatus.Sent = atomic.LoadUint64(&n.sendCount)
n.haStatus.Received = atomic.LoadUint64(&n.receiveCount)
n.haStatus.ReceivedQueued = uint64(len(n.recvChannel))
return n.haStatus
} | go | func (n *Node) status() seesaw.HAStatus {
n.statusLock.Lock()
defer n.statusLock.Unlock()
n.haStatus.Sent = atomic.LoadUint64(&n.sendCount)
n.haStatus.Received = atomic.LoadUint64(&n.receiveCount)
n.haStatus.ReceivedQueued = uint64(len(n.recvChannel))
return n.haStatus
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"status",
"(",
")",
"seesaw",
".",
"HAStatus",
"{",
"n",
".",
"statusLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"statusLock",
".",
"Unlock",
"(",
")",
"\n",
"n",
".",
"haStatus",
".",
"Sent",
"=",
... | // status returns the current HA status for this node. | [
"status",
"returns",
"the",
"current",
"HA",
"status",
"for",
"this",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/core.go#L139-L146 | train |
google/seesaw | ha/core.go | newAdvertisement | func (n *Node) newAdvertisement() *advertisement {
return &advertisement{
VersionType: vrrpVersionType,
VRID: n.VRID,
Priority: n.Priority,
AdvertInt: uint16(n.MasterAdvertInterval / time.Millisecond / 10), // AdvertInt is in centiseconds
}
} | go | func (n *Node) newAdvertisement() *advertisement {
return &advertisement{
VersionType: vrrpVersionType,
VRID: n.VRID,
Priority: n.Priority,
AdvertInt: uint16(n.MasterAdvertInterval / time.Millisecond / 10), // AdvertInt is in centiseconds
}
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"newAdvertisement",
"(",
")",
"*",
"advertisement",
"{",
"return",
"&",
"advertisement",
"{",
"VersionType",
":",
"vrrpVersionType",
",",
"VRID",
":",
"n",
".",
"VRID",
",",
"Priority",
":",
"n",
".",
"Priority",
",",
... | // newAdvertisement creates a new advertisement with this Node's VRID and priority. | [
"newAdvertisement",
"creates",
"a",
"new",
"advertisement",
"with",
"this",
"Node",
"s",
"VRID",
"and",
"priority",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/core.go#L149-L156 | train |
google/seesaw | ha/core.go | Run | func (n *Node) Run() error {
go n.receiveAdvertisements()
go n.reportStatus()
go n.checkConfig()
for n.state() != seesaw.HAShutdown {
if err := n.runOnce(); err != nil {
return err
}
}
return nil
} | go | func (n *Node) Run() error {
go n.receiveAdvertisements()
go n.reportStatus()
go n.checkConfig()
for n.state() != seesaw.HAShutdown {
if err := n.runOnce(); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Run",
"(",
")",
"error",
"{",
"go",
"n",
".",
"receiveAdvertisements",
"(",
")",
"\n",
"go",
"n",
".",
"reportStatus",
"(",
")",
"\n",
"go",
"n",
".",
"checkConfig",
"(",
")",
"\n\n",
"for",
"n",
".",
"state",... | // Run sends and receives advertisements, changes this Node's state in response to incoming
// advertisements, and periodically notifies the engine of the current state. Run does not return
// until Shutdown is called or an unrecoverable error occurs. | [
"Run",
"sends",
"and",
"receives",
"advertisements",
"changes",
"this",
"Node",
"s",
"state",
"in",
"response",
"to",
"incoming",
"advertisements",
"and",
"periodically",
"notifies",
"the",
"engine",
"of",
"the",
"current",
"state",
".",
"Run",
"does",
"not",
... | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ha/core.go#L161-L172 | train |
google/seesaw | netlink/message.go | registerCallback | func registerCallback(cbArg *callbackArg) uintptr {
callbacksLock.Lock()
defer callbacksLock.Unlock()
cbArg.id = nextCallbackID
nextCallbackID++
if _, ok := callbacks[cbArg.id]; ok {
panic(fmt.Sprintf("Callback ID %d already in use", cbArg.id))
}
callbacks[cbArg.id] = cbArg
return cbArg.id
} | go | func registerCallback(cbArg *callbackArg) uintptr {
callbacksLock.Lock()
defer callbacksLock.Unlock()
cbArg.id = nextCallbackID
nextCallbackID++
if _, ok := callbacks[cbArg.id]; ok {
panic(fmt.Sprintf("Callback ID %d already in use", cbArg.id))
}
callbacks[cbArg.id] = cbArg
return cbArg.id
} | [
"func",
"registerCallback",
"(",
"cbArg",
"*",
"callbackArg",
")",
"uintptr",
"{",
"callbacksLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"callbacksLock",
".",
"Unlock",
"(",
")",
"\n",
"cbArg",
".",
"id",
"=",
"nextCallbackID",
"\n",
"nextCallbackID",
"++",... | // registerCallback registers a callback and returns the allocated callback ID. | [
"registerCallback",
"registers",
"a",
"callback",
"and",
"returns",
"the",
"allocated",
"callback",
"ID",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L77-L87 | train |
google/seesaw | netlink/message.go | unregisterCallback | func unregisterCallback(cbArg *callbackArg) {
callbacksLock.Lock()
defer callbacksLock.Unlock()
if _, ok := callbacks[cbArg.id]; !ok {
panic(fmt.Sprintf("Callback ID %d not registered", cbArg.id))
}
delete(callbacks, cbArg.id)
} | go | func unregisterCallback(cbArg *callbackArg) {
callbacksLock.Lock()
defer callbacksLock.Unlock()
if _, ok := callbacks[cbArg.id]; !ok {
panic(fmt.Sprintf("Callback ID %d not registered", cbArg.id))
}
delete(callbacks, cbArg.id)
} | [
"func",
"unregisterCallback",
"(",
"cbArg",
"*",
"callbackArg",
")",
"{",
"callbacksLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"callbacksLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"callbacks",
"[",
"cbArg",
".",
"id",
"]",
";",... | // unregisterCallback unregisters a callback. | [
"unregisterCallback",
"unregisters",
"a",
"callback",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L90-L97 | train |
google/seesaw | netlink/message.go | callback | func callback(nlm *C.struct_nl_msg, nla unsafe.Pointer) C.int {
cbID := uintptr(nla)
callbacksLock.RLock()
cbArg := callbacks[cbID]
callbacksLock.RUnlock()
if cbArg == nil {
panic(fmt.Sprintf("No netlink callback with ID %d", cbID))
}
cbMsg := &Message{nlm: nlm}
if err := cbArg.fn(cbMsg, cbArg.arg); err != ... | go | func callback(nlm *C.struct_nl_msg, nla unsafe.Pointer) C.int {
cbID := uintptr(nla)
callbacksLock.RLock()
cbArg := callbacks[cbID]
callbacksLock.RUnlock()
if cbArg == nil {
panic(fmt.Sprintf("No netlink callback with ID %d", cbID))
}
cbMsg := &Message{nlm: nlm}
if err := cbArg.fn(cbMsg, cbArg.arg); err != ... | [
"func",
"callback",
"(",
"nlm",
"*",
"C",
".",
"struct_nl_msg",
",",
"nla",
"unsafe",
".",
"Pointer",
")",
"C",
".",
"int",
"{",
"cbID",
":=",
"uintptr",
"(",
"nla",
")",
"\n",
"callbacksLock",
".",
"RLock",
"(",
")",
"\n",
"cbArg",
":=",
"callbacks"... | // callback is the Go callback trampoline that is called from the
// callbackGateway C function, which in turn gets called from libnl.
//
//export callback | [
"callback",
"is",
"the",
"Go",
"callback",
"trampoline",
"that",
"is",
"called",
"from",
"the",
"callbackGateway",
"C",
"function",
"which",
"in",
"turn",
"gets",
"called",
"from",
"libnl",
".",
"export",
"callback"
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L103-L119 | train |
google/seesaw | netlink/message.go | NewMessage | func NewMessage(command, family, flags int) (*Message, error) {
nlm := C.nlmsg_alloc()
if nlm == nil {
return nil, errors.New("failed to create netlink message")
}
C.genlmsg_put(nlm, C.NL_AUTO_PID, C.NL_AUTO_SEQ, C.int(family), 0, C.int(flags), C.uint8_t(command), genlVersion)
return &Message{nlm: nlm}, nil
} | go | func NewMessage(command, family, flags int) (*Message, error) {
nlm := C.nlmsg_alloc()
if nlm == nil {
return nil, errors.New("failed to create netlink message")
}
C.genlmsg_put(nlm, C.NL_AUTO_PID, C.NL_AUTO_SEQ, C.int(family), 0, C.int(flags), C.uint8_t(command), genlVersion)
return &Message{nlm: nlm}, nil
} | [
"func",
"NewMessage",
"(",
"command",
",",
"family",
",",
"flags",
"int",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"nlm",
":=",
"C",
".",
"nlmsg_alloc",
"(",
")",
"\n",
"if",
"nlm",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
... | // NewMessage returns an initialised netlink message. | [
"NewMessage",
"returns",
"an",
"initialised",
"netlink",
"message",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L135-L142 | train |
google/seesaw | netlink/message.go | NewMessageFromBytes | func NewMessageFromBytes(nlb []byte) (*Message, error) {
nlm := C.nlmsg_alloc_size(C.size_t(len(nlb)))
if nlm == nil {
return nil, errors.New("failed to create netlink message")
}
nlh := C.nlmsg_hdr(nlm)
copy((*[1 << 20]byte)(unsafe.Pointer(nlh))[:len(nlb)], nlb)
return &Message{nlm: nlm}, nil
} | go | func NewMessageFromBytes(nlb []byte) (*Message, error) {
nlm := C.nlmsg_alloc_size(C.size_t(len(nlb)))
if nlm == nil {
return nil, errors.New("failed to create netlink message")
}
nlh := C.nlmsg_hdr(nlm)
copy((*[1 << 20]byte)(unsafe.Pointer(nlh))[:len(nlb)], nlb)
return &Message{nlm: nlm}, nil
} | [
"func",
"NewMessageFromBytes",
"(",
"nlb",
"[",
"]",
"byte",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"nlm",
":=",
"C",
".",
"nlmsg_alloc_size",
"(",
"C",
".",
"size_t",
"(",
"len",
"(",
"nlb",
")",
")",
")",
"\n",
"if",
"nlm",
"==",
"ni... | // NewMessageFromBytes returns a netlink message that is initialised from the
// given byte slice. | [
"NewMessageFromBytes",
"returns",
"a",
"netlink",
"message",
"that",
"is",
"initialised",
"from",
"the",
"given",
"byte",
"slice",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L146-L154 | train |
google/seesaw | netlink/message.go | Free | func (m *Message) Free() {
C.nlmsg_free(m.nlm)
m.nlm = nil
} | go | func (m *Message) Free() {
C.nlmsg_free(m.nlm)
m.nlm = nil
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"Free",
"(",
")",
"{",
"C",
".",
"nlmsg_free",
"(",
"m",
".",
"nlm",
")",
"\n",
"m",
".",
"nlm",
"=",
"nil",
"\n",
"}"
] | // Free frees resources associated with a netlink message. | [
"Free",
"frees",
"resources",
"associated",
"with",
"a",
"netlink",
"message",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L157-L160 | train |
google/seesaw | netlink/message.go | Bytes | func (m *Message) Bytes() ([]byte, error) {
if m.nlm == nil {
return nil, errors.New("no netlink message")
}
nlh := C.nlmsg_hdr(m.nlm)
nlb := make([]byte, nlh.nlmsg_len)
copy(nlb, (*[1 << 20]byte)(unsafe.Pointer(nlh))[:nlh.nlmsg_len])
return nlb, nil
} | go | func (m *Message) Bytes() ([]byte, error) {
if m.nlm == nil {
return nil, errors.New("no netlink message")
}
nlh := C.nlmsg_hdr(m.nlm)
nlb := make([]byte, nlh.nlmsg_len)
copy(nlb, (*[1 << 20]byte)(unsafe.Pointer(nlh))[:nlh.nlmsg_len])
return nlb, nil
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"m",
".",
"nlm",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"nlh",
":="... | // Bytes returns the byte slice representation of a netlink message. | [
"Bytes",
"returns",
"the",
"byte",
"slice",
"representation",
"of",
"a",
"netlink",
"message",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L163-L171 | train |
google/seesaw | netlink/message.go | Unmarshal | func (m *Message) Unmarshal(v interface{}) error {
val := reflect.Indirect(reflect.ValueOf(v))
if val.Kind() != reflect.Struct || !val.CanSet() {
return fmt.Errorf("%v is not a pointer to a struct", reflect.TypeOf(v))
}
maxAttrID, err := structMaxAttrID(val)
if err != nil {
return err
}
attrs, err := parseMe... | go | func (m *Message) Unmarshal(v interface{}) error {
val := reflect.Indirect(reflect.ValueOf(v))
if val.Kind() != reflect.Struct || !val.CanSet() {
return fmt.Errorf("%v is not a pointer to a struct", reflect.TypeOf(v))
}
maxAttrID, err := structMaxAttrID(val)
if err != nil {
return err
}
attrs, err := parseMe... | [
"func",
"(",
"m",
"*",
"Message",
")",
"Unmarshal",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"val",
":=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
")",
"\n",
"if",
"val",
".",
"Kind",
"(",
")",
"!=",
... | // Unmarshal parses the netlink message and fills the struct referenced by the
// given pointer. The supported data types and netlink encodings are the same
// as for Marshal. | [
"Unmarshal",
"parses",
"the",
"netlink",
"message",
"and",
"fills",
"the",
"struct",
"referenced",
"by",
"the",
"given",
"pointer",
".",
"The",
"supported",
"data",
"types",
"and",
"netlink",
"encodings",
"are",
"the",
"same",
"as",
"for",
"Marshal",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L209-L223 | train |
google/seesaw | netlink/message.go | SendCallback | func (m *Message) SendCallback(fn CallbackFunc, arg interface{}) error {
s, err := newSocket()
if err != nil {
return err
}
defer s.free()
if errno := C.genl_connect(s.nls); errno != 0 {
return &Error{errno, "failed to connect to netlink"}
}
defer C.nl_close(s.nls)
cbArg := &callbackArg{fn: fn, arg: arg}
... | go | func (m *Message) SendCallback(fn CallbackFunc, arg interface{}) error {
s, err := newSocket()
if err != nil {
return err
}
defer s.free()
if errno := C.genl_connect(s.nls); errno != 0 {
return &Error{errno, "failed to connect to netlink"}
}
defer C.nl_close(s.nls)
cbArg := &callbackArg{fn: fn, arg: arg}
... | [
"func",
"(",
"m",
"*",
"Message",
")",
"SendCallback",
"(",
"fn",
"CallbackFunc",
",",
"arg",
"interface",
"{",
"}",
")",
"error",
"{",
"s",
",",
"err",
":=",
"newSocket",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
... | // SendCallback sends the netlink message. The specified callback function
// will be called for each message that is received in response. | [
"SendCallback",
"sends",
"the",
"netlink",
"message",
".",
"The",
"specified",
"callback",
"function",
"will",
"be",
"called",
"for",
"each",
"message",
"that",
"is",
"received",
"in",
"response",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L232-L260 | train |
google/seesaw | netlink/message.go | SendMessage | func SendMessage(command, family, flags int) error {
return SendMessageCallback(command, family, flags, callbackDefault, nil)
} | go | func SendMessage(command, family, flags int) error {
return SendMessageCallback(command, family, flags, callbackDefault, nil)
} | [
"func",
"SendMessage",
"(",
"command",
",",
"family",
",",
"flags",
"int",
")",
"error",
"{",
"return",
"SendMessageCallback",
"(",
"command",
",",
"family",
",",
"flags",
",",
"callbackDefault",
",",
"nil",
")",
"\n",
"}"
] | // SendMessage creates and sends a netlink message. | [
"SendMessage",
"creates",
"and",
"sends",
"a",
"netlink",
"message",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L263-L265 | train |
google/seesaw | netlink/message.go | SendMessageCallback | func SendMessageCallback(command, family, flags int, cb CallbackFunc, arg interface{}) error {
msg, err := NewMessage(command, family, flags)
if err != nil {
return err
}
defer msg.Free()
return msg.SendCallback(cb, arg)
} | go | func SendMessageCallback(command, family, flags int, cb CallbackFunc, arg interface{}) error {
msg, err := NewMessage(command, family, flags)
if err != nil {
return err
}
defer msg.Free()
return msg.SendCallback(cb, arg)
} | [
"func",
"SendMessageCallback",
"(",
"command",
",",
"family",
",",
"flags",
"int",
",",
"cb",
"CallbackFunc",
",",
"arg",
"interface",
"{",
"}",
")",
"error",
"{",
"msg",
",",
"err",
":=",
"NewMessage",
"(",
"command",
",",
"family",
",",
"flags",
")",
... | // SendMessageCallback creates and sends a netlink message. The specified
// callback function will be called for each message that is received in
// response. | [
"SendMessageCallback",
"creates",
"and",
"sends",
"a",
"netlink",
"message",
".",
"The",
"specified",
"callback",
"function",
"will",
"be",
"called",
"for",
"each",
"message",
"that",
"is",
"received",
"in",
"response",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L270-L278 | train |
google/seesaw | netlink/message.go | SendMessageMarshalled | func SendMessageMarshalled(command, family, flags int, v interface{}) error {
msg, err := NewMessage(command, family, flags)
if err != nil {
return err
}
defer msg.Free()
if err := msg.Marshal(v); err != nil {
return err
}
return msg.Send()
} | go | func SendMessageMarshalled(command, family, flags int, v interface{}) error {
msg, err := NewMessage(command, family, flags)
if err != nil {
return err
}
defer msg.Free()
if err := msg.Marshal(v); err != nil {
return err
}
return msg.Send()
} | [
"func",
"SendMessageMarshalled",
"(",
"command",
",",
"family",
",",
"flags",
"int",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"msg",
",",
"err",
":=",
"NewMessage",
"(",
"command",
",",
"family",
",",
"flags",
")",
"\n",
"if",
"err",
"!=",
... | // SendMessageMarshalled creates a netlink message and marshals the given
// struct into the message, before sending it. | [
"SendMessageMarshalled",
"creates",
"a",
"netlink",
"message",
"and",
"marshals",
"the",
"given",
"struct",
"into",
"the",
"message",
"before",
"sending",
"it",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L282-L293 | train |
google/seesaw | netlink/message.go | SendMessageUnmarshal | func SendMessageUnmarshal(command, family, flags int, v interface{}) error {
return SendMessageCallback(command, family, flags, callbackUnmarshal, v)
} | go | func SendMessageUnmarshal(command, family, flags int, v interface{}) error {
return SendMessageCallback(command, family, flags, callbackUnmarshal, v)
} | [
"func",
"SendMessageUnmarshal",
"(",
"command",
",",
"family",
",",
"flags",
"int",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"SendMessageCallback",
"(",
"command",
",",
"family",
",",
"flags",
",",
"callbackUnmarshal",
",",
"v",
")",
"... | // SendMessageUnmarshal creates and sends a netlink message. All messages
// received in response will be unmarshalled into the given struct. | [
"SendMessageUnmarshal",
"creates",
"and",
"sends",
"a",
"netlink",
"message",
".",
"All",
"messages",
"received",
"in",
"response",
"will",
"be",
"unmarshalled",
"into",
"the",
"given",
"struct",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/message.go#L297-L299 | train |
google/seesaw | binaries/seesaw_ha/main.go | config | func config(e ha.Engine) *seesaw.HAConfig {
for {
c, err := e.HAConfig()
switch {
case err != nil:
log.Errorf("config: Failed to retrieve HAConfig: %v", err)
case !c.Enabled:
log.Infof("config: HA peering is currently disabled for this node")
default:
return c
}
time.Sleep(*initConfigRetryDela... | go | func config(e ha.Engine) *seesaw.HAConfig {
for {
c, err := e.HAConfig()
switch {
case err != nil:
log.Errorf("config: Failed to retrieve HAConfig: %v", err)
case !c.Enabled:
log.Infof("config: HA peering is currently disabled for this node")
default:
return c
}
time.Sleep(*initConfigRetryDela... | [
"func",
"config",
"(",
"e",
"ha",
".",
"Engine",
")",
"*",
"seesaw",
".",
"HAConfig",
"{",
"for",
"{",
"c",
",",
"err",
":=",
"e",
".",
"HAConfig",
"(",
")",
"\n",
"switch",
"{",
"case",
"err",
"!=",
"nil",
":",
"log",
".",
"Errorf",
"(",
"\"",... | // config reads the HAConfig from the engine. It does not return until it
// successfully retrieves an HAConfig that has HA peering enabled. | [
"config",
"reads",
"the",
"HAConfig",
"from",
"the",
"engine",
".",
"It",
"does",
"not",
"return",
"until",
"it",
"successfully",
"retrieves",
"an",
"HAConfig",
"that",
"has",
"HA",
"peering",
"enabled",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_ha/main.go#L81-L96 | train |
google/seesaw | engine/bgp.go | newBGPManager | func newBGPManager(engine *Engine, interval time.Duration) *bgpManager {
return &bgpManager{engine: engine, updateInterval: interval}
} | go | func newBGPManager(engine *Engine, interval time.Duration) *bgpManager {
return &bgpManager{engine: engine, updateInterval: interval}
} | [
"func",
"newBGPManager",
"(",
"engine",
"*",
"Engine",
",",
"interval",
"time",
".",
"Duration",
")",
"*",
"bgpManager",
"{",
"return",
"&",
"bgpManager",
"{",
"engine",
":",
"engine",
",",
"updateInterval",
":",
"interval",
"}",
"\n",
"}"
] | // newBGPManager returns an initialised bgpManager struct. | [
"newBGPManager",
"returns",
"an",
"initialised",
"bgpManager",
"struct",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/bgp.go#L41-L43 | train |
google/seesaw | engine/bgp.go | run | func (b *bgpManager) run() {
ticker := time.NewTicker(b.updateInterval)
for {
log.V(1).Infof("Updating BGP state and statistics...")
b.update()
<-ticker.C
}
} | go | func (b *bgpManager) run() {
ticker := time.NewTicker(b.updateInterval)
for {
log.V(1).Infof("Updating BGP state and statistics...")
b.update()
<-ticker.C
}
} | [
"func",
"(",
"b",
"*",
"bgpManager",
")",
"run",
"(",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"b",
".",
"updateInterval",
")",
"\n",
"for",
"{",
"log",
".",
"V",
"(",
"1",
")",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"b",
"... | // run runs the BGP configuration manager. | [
"run",
"runs",
"the",
"BGP",
"configuration",
"manager",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/bgp.go#L46-L53 | train |
google/seesaw | engine/bgp.go | update | func (b *bgpManager) update() {
ncc := b.engine.ncc
if err := ncc.Dial(); err != nil {
log.Warningf("BGP manager failed to connect to NCC: %v", err)
return
}
defer ncc.Close()
neighbors, err := ncc.BGPNeighbors()
if err != nil {
log.Warningf("Failed to get BGP neighbors: %v", err)
return
}
b.lock.Lock(... | go | func (b *bgpManager) update() {
ncc := b.engine.ncc
if err := ncc.Dial(); err != nil {
log.Warningf("BGP manager failed to connect to NCC: %v", err)
return
}
defer ncc.Close()
neighbors, err := ncc.BGPNeighbors()
if err != nil {
log.Warningf("Failed to get BGP neighbors: %v", err)
return
}
b.lock.Lock(... | [
"func",
"(",
"b",
"*",
"bgpManager",
")",
"update",
"(",
")",
"{",
"ncc",
":=",
"b",
".",
"engine",
".",
"ncc",
"\n",
"if",
"err",
":=",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",... | // update updates BGP related state and statistics from the BGP daemon. | [
"update",
"updates",
"BGP",
"related",
"state",
"and",
"statistics",
"from",
"the",
"BGP",
"daemon",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/bgp.go#L56-L72 | train |
google/seesaw | healthcheck/http.go | NewHTTPChecker | func NewHTTPChecker(ip net.IP, port int) *HTTPChecker {
return &HTTPChecker{
Target: Target{
IP: ip,
Port: port,
Proto: seesaw.IPProtoTCP,
},
Secure: false,
TLSVerify: true,
Method: "GET",
Proxy: false,
Request: "/",
Response: "",
ResponseCode: 200,
}
} | go | func NewHTTPChecker(ip net.IP, port int) *HTTPChecker {
return &HTTPChecker{
Target: Target{
IP: ip,
Port: port,
Proto: seesaw.IPProtoTCP,
},
Secure: false,
TLSVerify: true,
Method: "GET",
Proxy: false,
Request: "/",
Response: "",
ResponseCode: 200,
}
} | [
"func",
"NewHTTPChecker",
"(",
"ip",
"net",
".",
"IP",
",",
"port",
"int",
")",
"*",
"HTTPChecker",
"{",
"return",
"&",
"HTTPChecker",
"{",
"Target",
":",
"Target",
"{",
"IP",
":",
"ip",
",",
"Port",
":",
"port",
",",
"Proto",
":",
"seesaw",
".",
"... | // NewHTTPChecker returns an initialised HTTPChecker. | [
"NewHTTPChecker",
"returns",
"an",
"initialised",
"HTTPChecker",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/http.go#L52-L67 | train |
google/seesaw | healthcheck/http.go | String | func (hc *HTTPChecker) String() string {
attr := []string{fmt.Sprintf("code %d", hc.ResponseCode)}
if hc.Proxy {
attr = append(attr, "proxy")
}
if hc.Secure {
attr = append(attr, "secure")
if hc.TLSVerify {
attr = append(attr, "verify")
}
}
s := strings.Join(attr, "; ")
return fmt.Sprintf("HTTP %s %s ... | go | func (hc *HTTPChecker) String() string {
attr := []string{fmt.Sprintf("code %d", hc.ResponseCode)}
if hc.Proxy {
attr = append(attr, "proxy")
}
if hc.Secure {
attr = append(attr, "secure")
if hc.TLSVerify {
attr = append(attr, "verify")
}
}
s := strings.Join(attr, "; ")
return fmt.Sprintf("HTTP %s %s ... | [
"func",
"(",
"hc",
"*",
"HTTPChecker",
")",
"String",
"(",
")",
"string",
"{",
"attr",
":=",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"hc",
".",
"ResponseCode",
")",
"}",
"\n",
"if",
"hc",
".",
"Proxy",
"{",
"attr",
... | // String returns the string representation of an HTTP healthcheck. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"an",
"HTTP",
"healthcheck",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/http.go#L70-L83 | train |
google/seesaw | healthcheck/tcp.go | NewTCPChecker | func NewTCPChecker(ip net.IP, port int) *TCPChecker {
return &TCPChecker{
Target: Target{
IP: ip,
Port: port,
Proto: seesaw.IPProtoTCP,
},
}
} | go | func NewTCPChecker(ip net.IP, port int) *TCPChecker {
return &TCPChecker{
Target: Target{
IP: ip,
Port: port,
Proto: seesaw.IPProtoTCP,
},
}
} | [
"func",
"NewTCPChecker",
"(",
"ip",
"net",
".",
"IP",
",",
"port",
"int",
")",
"*",
"TCPChecker",
"{",
"return",
"&",
"TCPChecker",
"{",
"Target",
":",
"Target",
"{",
"IP",
":",
"ip",
",",
"Port",
":",
"port",
",",
"Proto",
":",
"seesaw",
".",
"IPP... | // NewTCPChecker returns an initialised TCPChecker. | [
"NewTCPChecker",
"returns",
"an",
"initialised",
"TCPChecker",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/tcp.go#L46-L54 | train |
google/seesaw | healthcheck/tcp.go | String | func (hc *TCPChecker) String() string {
attr := []string{}
if hc.Secure {
attr = append(attr, "secure")
if hc.TLSVerify {
attr = append(attr, "verify")
}
}
var s string
if len(attr) > 0 {
s = fmt.Sprintf(" [%s]", strings.Join(attr, "; "))
}
return fmt.Sprintf("TCP%s %s", s, hc.Target)
} | go | func (hc *TCPChecker) String() string {
attr := []string{}
if hc.Secure {
attr = append(attr, "secure")
if hc.TLSVerify {
attr = append(attr, "verify")
}
}
var s string
if len(attr) > 0 {
s = fmt.Sprintf(" [%s]", strings.Join(attr, "; "))
}
return fmt.Sprintf("TCP%s %s", s, hc.Target)
} | [
"func",
"(",
"hc",
"*",
"TCPChecker",
")",
"String",
"(",
")",
"string",
"{",
"attr",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"if",
"hc",
".",
"Secure",
"{",
"attr",
"=",
"append",
"(",
"attr",
",",
"\"",
"\"",
")",
"\n",
"if",
"hc",
".",
"... | // String returns the string representation of a TCP healthcheck. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"TCP",
"healthcheck",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/tcp.go#L57-L70 | train |
google/seesaw | healthcheck/tcp.go | Check | func (hc *TCPChecker) Check(timeout time.Duration) *Result {
msg := fmt.Sprintf("TCP connect to %s", hc.addr())
start := time.Now()
if timeout == time.Duration(0) {
timeout = defaultTCPTimeout
}
deadline := start.Add(timeout)
tcpConn, err := dialTCP(hc.network(), hc.addr(), timeout, hc.Mark)
if err != nil {
... | go | func (hc *TCPChecker) Check(timeout time.Duration) *Result {
msg := fmt.Sprintf("TCP connect to %s", hc.addr())
start := time.Now()
if timeout == time.Duration(0) {
timeout = defaultTCPTimeout
}
deadline := start.Add(timeout)
tcpConn, err := dialTCP(hc.network(), hc.addr(), timeout, hc.Mark)
if err != nil {
... | [
"func",
"(",
"hc",
"*",
"TCPChecker",
")",
"Check",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"Result",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"hc",
".",
"addr",
"(",
")",
")",
"\n",
"start",
":=",
"time",
".",
... | // Check executes a TCP healthcheck. | [
"Check",
"executes",
"a",
"TCP",
"healthcheck",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/tcp.go#L73-L141 | train |
google/seesaw | ncc/types/ncc_types.go | Interface | func (lb *LBInterface) Interface() (*net.Interface, error) {
iface, err := net.InterfaceByName(lb.Name)
if err != nil {
return nil, err
}
return iface, nil
} | go | func (lb *LBInterface) Interface() (*net.Interface, error) {
iface, err := net.InterfaceByName(lb.Name)
if err != nil {
return nil, err
}
return iface, nil
} | [
"func",
"(",
"lb",
"*",
"LBInterface",
")",
"Interface",
"(",
")",
"(",
"*",
"net",
".",
"Interface",
",",
"error",
")",
"{",
"iface",
",",
"err",
":=",
"net",
".",
"InterfaceByName",
"(",
"lb",
".",
"Name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // Interface returns the network interface associated with the LBInterface. | [
"Interface",
"returns",
"the",
"network",
"interface",
"associated",
"with",
"the",
"LBInterface",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/types/ncc_types.go#L73-L79 | train |
google/seesaw | cli/show.go | label | func label(l string, indent, width int) string {
pad := width - indent - len(l)
if pad < 0 {
pad = 0
}
return fmt.Sprintf("%s%s%s", strings.Repeat(" ", indent), l,
strings.Repeat(" ", pad))
} | go | func label(l string, indent, width int) string {
pad := width - indent - len(l)
if pad < 0 {
pad = 0
}
return fmt.Sprintf("%s%s%s", strings.Repeat(" ", indent), l,
strings.Repeat(" ", pad))
} | [
"func",
"label",
"(",
"l",
"string",
",",
"indent",
",",
"width",
"int",
")",
"string",
"{",
"pad",
":=",
"width",
"-",
"indent",
"-",
"len",
"(",
"l",
")",
"\n",
"if",
"pad",
"<",
"0",
"{",
"pad",
"=",
"0",
"\n",
"}",
"\n",
"return",
"fmt",
... | // label returns a string containing the label with indentation and padding. | [
"label",
"returns",
"a",
"string",
"containing",
"the",
"label",
"with",
"indentation",
"and",
"padding",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/cli/show.go#L554-L561 | train |
google/seesaw | cli/show.go | printFmt | func printFmt(l, v string, args ...interface{}) {
l = label(l, subIndent, valIndent)
fmt.Printf("%s %s\n", l, fmt.Sprintf(v, args...))
} | go | func printFmt(l, v string, args ...interface{}) {
l = label(l, subIndent, valIndent)
fmt.Printf("%s %s\n", l, fmt.Sprintf(v, args...))
} | [
"func",
"printFmt",
"(",
"l",
",",
"v",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
"=",
"label",
"(",
"l",
",",
"subIndent",
",",
"valIndent",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"l",
",",
"fmt... | // printFmt formats and prints a given value with the specified label. | [
"printFmt",
"formats",
"and",
"prints",
"a",
"given",
"value",
"with",
"the",
"specified",
"label",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/cli/show.go#L569-L572 | train |
google/seesaw | cli/show.go | printVal | func printVal(l string, v interface{}) {
switch f := v.(type) {
case uint, uint64:
printFmt(l, "%d", f)
case string:
printFmt(l, "%s", f)
default:
printFmt(l, "%v", f)
}
} | go | func printVal(l string, v interface{}) {
switch f := v.(type) {
case uint, uint64:
printFmt(l, "%d", f)
case string:
printFmt(l, "%s", f)
default:
printFmt(l, "%v", f)
}
} | [
"func",
"printVal",
"(",
"l",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"{",
"switch",
"f",
":=",
"v",
".",
"(",
"type",
")",
"{",
"case",
"uint",
",",
"uint64",
":",
"printFmt",
"(",
"l",
",",
"\"",
"\"",
",",
"f",
")",
"\n",
"case",
"... | // printVal prints the given value with the specified label. | [
"printVal",
"prints",
"the",
"given",
"value",
"with",
"the",
"specified",
"label",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/cli/show.go#L575-L584 | train |
google/seesaw | engine/sync.go | String | func (snt SyncNoteType) String() string {
if name, ok := syncNoteTypeNames[snt]; ok {
return name
}
return fmt.Sprintf("(Unknown %d)", snt)
} | go | func (snt SyncNoteType) String() string {
if name, ok := syncNoteTypeNames[snt]; ok {
return name
}
return fmt.Sprintf("(Unknown %d)", snt)
} | [
"func",
"(",
"snt",
"SyncNoteType",
")",
"String",
"(",
")",
"string",
"{",
"if",
"name",
",",
"ok",
":=",
"syncNoteTypeNames",
"[",
"snt",
"]",
";",
"ok",
"{",
"return",
"name",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",... | // String returns the string representation of a synchronisation notification
// type. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"synchronisation",
"notification",
"type",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L73-L78 | train |
google/seesaw | engine/sync.go | Register | func (s *SeesawSync) Register(node net.IP, id *SyncSessionID) error {
if id == nil {
return errors.New("id is nil")
}
// TODO(jsing): Reject if not master?
s.sync.sessionLock.Lock()
session := newSyncSession(node, s.sync.nextSessionID)
s.sync.nextSessionID++
s.sync.sessions[session.id] = session
s.sync.sess... | go | func (s *SeesawSync) Register(node net.IP, id *SyncSessionID) error {
if id == nil {
return errors.New("id is nil")
}
// TODO(jsing): Reject if not master?
s.sync.sessionLock.Lock()
session := newSyncSession(node, s.sync.nextSessionID)
s.sync.nextSessionID++
s.sync.sessions[session.id] = session
s.sync.sess... | [
"func",
"(",
"s",
"*",
"SeesawSync",
")",
"Register",
"(",
"node",
"net",
".",
"IP",
",",
"id",
"*",
"SyncSessionID",
")",
"error",
"{",
"if",
"id",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// TO... | // Register registers our Seesaw peer for synchronisation notifications. | [
"Register",
"registers",
"our",
"Seesaw",
"peer",
"for",
"synchronisation",
"notifications",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L103-L125 | train |
google/seesaw | engine/sync.go | Deregister | func (s *SeesawSync) Deregister(id SyncSessionID, reply *int) error {
s.sync.sessionLock.Lock()
session, ok := s.sync.sessions[id]
delete(s.sync.sessions, id)
s.sync.sessionLock.Unlock()
if ok {
log.Infof("Synchronisation session %d deregistered with %v", id, session.node)
}
return nil
} | go | func (s *SeesawSync) Deregister(id SyncSessionID, reply *int) error {
s.sync.sessionLock.Lock()
session, ok := s.sync.sessions[id]
delete(s.sync.sessions, id)
s.sync.sessionLock.Unlock()
if ok {
log.Infof("Synchronisation session %d deregistered with %v", id, session.node)
}
return nil
} | [
"func",
"(",
"s",
"*",
"SeesawSync",
")",
"Deregister",
"(",
"id",
"SyncSessionID",
",",
"reply",
"*",
"int",
")",
"error",
"{",
"s",
".",
"sync",
".",
"sessionLock",
".",
"Lock",
"(",
")",
"\n",
"session",
",",
"ok",
":=",
"s",
".",
"sync",
".",
... | // Deregister deregisters a Seesaw peer for synchronisation. | [
"Deregister",
"deregisters",
"a",
"Seesaw",
"peer",
"for",
"synchronisation",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L128-L139 | train |
google/seesaw | engine/sync.go | Poll | func (s *SeesawSync) Poll(id SyncSessionID, sn *SyncNotes) error {
if sn == nil {
return errors.New("sync notes is nil")
}
s.sync.sessionLock.RLock()
session, ok := s.sync.sessions[id]
s.sync.sessionLock.RUnlock()
if !ok {
return errors.New("no session with ID %d")
}
// Reset expiry time and check for des... | go | func (s *SeesawSync) Poll(id SyncSessionID, sn *SyncNotes) error {
if sn == nil {
return errors.New("sync notes is nil")
}
s.sync.sessionLock.RLock()
session, ok := s.sync.sessions[id]
s.sync.sessionLock.RUnlock()
if !ok {
return errors.New("no session with ID %d")
}
// Reset expiry time and check for des... | [
"func",
"(",
"s",
"*",
"SeesawSync",
")",
"Poll",
"(",
"id",
"SyncSessionID",
",",
"sn",
"*",
"SyncNotes",
")",
"error",
"{",
"if",
"sn",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"s",
".",
"sync",... | // Poll returns one or more synchronisation notifications to the caller,
// blocking until at least one notification becomes available or the poll
// timeout is reached. | [
"Poll",
"returns",
"one",
"or",
"more",
"synchronisation",
"notifications",
"to",
"the",
"caller",
"blocking",
"until",
"at",
"least",
"one",
"notification",
"becomes",
"available",
"or",
"the",
"poll",
"timeout",
"is",
"reached",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L144-L188 | train |
google/seesaw | engine/sync.go | Config | func (s *SeesawSync) Config(arg int, config *config.Notification) error {
return errors.New("unimplemented")
} | go | func (s *SeesawSync) Config(arg int, config *config.Notification) error {
return errors.New("unimplemented")
} | [
"func",
"(",
"s",
"*",
"SeesawSync",
")",
"Config",
"(",
"arg",
"int",
",",
"config",
"*",
"config",
".",
"Notification",
")",
"error",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Config requests the current configuration from the peer Seesaw node. | [
"Config",
"requests",
"the",
"current",
"configuration",
"from",
"the",
"peer",
"Seesaw",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L191-L193 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.