id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,400 | 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 |
26,401 | 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 |
26,402 | 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 |
26,403 | 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 |
26,404 | 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 |
26,405 | 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 |
26,406 | 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 |
26,407 | 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 |
26,408 | 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 |
26,409 | 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 |
26,410 | 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 |
26,411 | 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 |
26,412 | 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 |
26,413 | 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 |
26,414 | 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 |
26,415 | 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 |
26,416 | 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 |
26,417 | 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 |
26,418 | 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 |
26,419 | 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 |
26,420 | 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 |
26,421 | 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 |
26,422 | 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 |
26,423 | 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 |
26,424 | 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 |
26,425 | 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 |
26,426 | 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 |
26,427 | 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 |
26,428 | 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 |
26,429 | 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 |
26,430 | 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 |
26,431 | 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 |
26,432 | 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 |
26,433 | 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 |
26,434 | 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 |
26,435 | 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 |
26,436 | 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 |
26,437 | 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 |
26,438 | 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 |
26,439 | 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 |
26,440 | 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 |
26,441 | 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 |
26,442 | 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 |
26,443 | 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 |
26,444 | 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 |
26,445 | 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 |
26,446 | 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 |
26,447 | 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 |
26,448 | 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 |
26,449 | 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 |
26,450 | 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 |
26,451 | 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 |
26,452 | 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 |
26,453 | 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 |
26,454 | 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 |
26,455 | 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 |
26,456 | 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 |
26,457 | 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 |
26,458 | 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 |
26,459 | 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 |
26,460 | 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 |
26,461 | 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 |
26,462 | 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 |
26,463 | 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 |
26,464 | 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 |
26,465 | 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 |
26,466 | 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 |
26,467 | 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 |
26,468 | 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 |
26,469 | 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 |
26,470 | 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 |
26,471 | 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 |
26,472 | 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 |
26,473 | 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 |
26,474 | 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 |
26,475 | 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 |
26,476 | google/seesaw | engine/sync.go | Failover | func (s *SeesawSync) Failover(arg int, reply *int) error {
return s.sync.engine.haManager.requestFailover(true)
} | go | func (s *SeesawSync) Failover(arg int, reply *int) error {
return s.sync.engine.haManager.requestFailover(true)
} | [
"func",
"(",
"s",
"*",
"SeesawSync",
")",
"Failover",
"(",
"arg",
"int",
",",
"reply",
"*",
"int",
")",
"error",
"{",
"return",
"s",
".",
"sync",
".",
"engine",
".",
"haManager",
".",
"requestFailover",
"(",
"true",
")",
"\n",
"}"
] | // Failover requests that we relinquish master state. | [
"Failover",
"requests",
"that",
"we",
"relinquish",
"master",
"state",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L196-L198 |
26,477 | google/seesaw | engine/sync.go | Healthchecks | func (s *SeesawSync) Healthchecks(arg int, reply *int) error {
return errors.New("unimplemented")
} | go | func (s *SeesawSync) Healthchecks(arg int, reply *int) error {
return errors.New("unimplemented")
} | [
"func",
"(",
"s",
"*",
"SeesawSync",
")",
"Healthchecks",
"(",
"arg",
"int",
",",
"reply",
"*",
"int",
")",
"error",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Healthchecks requests the current healthchecks from the peer Seesaw node. | [
"Healthchecks",
"requests",
"the",
"current",
"healthchecks",
"from",
"the",
"peer",
"Seesaw",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L201-L203 |
26,478 | google/seesaw | engine/sync.go | newSyncSession | func newSyncSession(node net.IP, id SyncSessionID) *syncSession {
return &syncSession{
id: id,
node: node,
desync: true,
startTime: time.Now(),
expiryTime: time.Now().Add(sessionDeadtime),
notes: make(chan *SyncNote, sessionNotesQueueSize),
}
} | go | func newSyncSession(node net.IP, id SyncSessionID) *syncSession {
return &syncSession{
id: id,
node: node,
desync: true,
startTime: time.Now(),
expiryTime: time.Now().Add(sessionDeadtime),
notes: make(chan *SyncNote, sessionNotesQueueSize),
}
} | [
"func",
"newSyncSession",
"(",
"node",
"net",
".",
"IP",
",",
"id",
"SyncSessionID",
")",
"*",
"syncSession",
"{",
"return",
"&",
"syncSession",
"{",
"id",
":",
"id",
",",
"node",
":",
"node",
",",
"desync",
":",
"true",
",",
"startTime",
":",
"time",
... | // newSyncSession returns an initialised synchronisation session. | [
"newSyncSession",
"returns",
"an",
"initialised",
"synchronisation",
"session",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L218-L227 |
26,479 | google/seesaw | engine/sync.go | addNote | func (ss *syncSession) addNote(note *SyncNote) {
select {
case ss.notes <- note:
default:
ss.Lock()
if !ss.desync {
log.Warningf("Sync session with %v is desynchronised", ss.node)
ss.desync = true
}
ss.Unlock()
}
} | go | func (ss *syncSession) addNote(note *SyncNote) {
select {
case ss.notes <- note:
default:
ss.Lock()
if !ss.desync {
log.Warningf("Sync session with %v is desynchronised", ss.node)
ss.desync = true
}
ss.Unlock()
}
} | [
"func",
"(",
"ss",
"*",
"syncSession",
")",
"addNote",
"(",
"note",
"*",
"SyncNote",
")",
"{",
"select",
"{",
"case",
"ss",
".",
"notes",
"<-",
"note",
":",
"default",
":",
"ss",
".",
"Lock",
"(",
")",
"\n",
"if",
"!",
"ss",
".",
"desync",
"{",
... | // addNote adds a notification to the synchronisation session. If the notes
// channel is full the session is marked as desynchronised and the notification
// is discarded. | [
"addNote",
"adds",
"a",
"notification",
"to",
"the",
"synchronisation",
"session",
".",
"If",
"the",
"notes",
"channel",
"is",
"full",
"the",
"session",
"is",
"marked",
"as",
"desynchronised",
"and",
"the",
"notification",
"is",
"discarded",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L232-L243 |
26,480 | google/seesaw | engine/sync.go | newSyncServer | func newSyncServer(e *Engine) *syncServer {
return &syncServer{
engine: e,
heartbeatInterval: syncHeartbeatInterval,
sessions: make(map[SyncSessionID]*syncSession),
}
} | go | func newSyncServer(e *Engine) *syncServer {
return &syncServer{
engine: e,
heartbeatInterval: syncHeartbeatInterval,
sessions: make(map[SyncSessionID]*syncSession),
}
} | [
"func",
"newSyncServer",
"(",
"e",
"*",
"Engine",
")",
"*",
"syncServer",
"{",
"return",
"&",
"syncServer",
"{",
"engine",
":",
"e",
",",
"heartbeatInterval",
":",
"syncHeartbeatInterval",
",",
"sessions",
":",
"make",
"(",
"map",
"[",
"SyncSessionID",
"]",
... | // newSyncServer returns an initalised synchronisation server. | [
"newSyncServer",
"returns",
"an",
"initalised",
"synchronisation",
"server",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L257-L263 |
26,481 | google/seesaw | engine/sync.go | serve | func (s *syncServer) serve(l *net.TCPListener) error {
defer l.Close()
s.server = rpc.NewServer()
s.server.Register(&SeesawSync{s})
for {
c, err := l.AcceptTCP()
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
time.Sleep(100 * time.Millisecond)
continue
}
return err
}
... | go | func (s *syncServer) serve(l *net.TCPListener) error {
defer l.Close()
s.server = rpc.NewServer()
s.server.Register(&SeesawSync{s})
for {
c, err := l.AcceptTCP()
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
time.Sleep(100 * time.Millisecond)
continue
}
return err
}
... | [
"func",
"(",
"s",
"*",
"syncServer",
")",
"serve",
"(",
"l",
"*",
"net",
".",
"TCPListener",
")",
"error",
"{",
"defer",
"l",
".",
"Close",
"(",
")",
"\n\n",
"s",
".",
"server",
"=",
"rpc",
".",
"NewServer",
"(",
")",
"\n",
"s",
".",
"server",
... | // serve accepts connections from the given TCP listener and dispatches each
// connection to the RPC server. Connections are only accepted from localhost
// and the seesaw node that we are configured to peer with. | [
"serve",
"accepts",
"connections",
"from",
"the",
"given",
"TCP",
"listener",
"and",
"dispatches",
"each",
"connection",
"to",
"the",
"RPC",
"server",
".",
"Connections",
"are",
"only",
"accepted",
"from",
"localhost",
"and",
"the",
"seesaw",
"node",
"that",
"... | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L268-L299 |
26,482 | google/seesaw | engine/sync.go | notify | func (s *syncServer) notify(sn *SyncNote) {
s.sessionLock.RLock()
sessions := s.sessions
s.sessionLock.RUnlock()
for _, ss := range sessions {
ss.addNote(sn)
}
} | go | func (s *syncServer) notify(sn *SyncNote) {
s.sessionLock.RLock()
sessions := s.sessions
s.sessionLock.RUnlock()
for _, ss := range sessions {
ss.addNote(sn)
}
} | [
"func",
"(",
"s",
"*",
"syncServer",
")",
"notify",
"(",
"sn",
"*",
"SyncNote",
")",
"{",
"s",
".",
"sessionLock",
".",
"RLock",
"(",
")",
"\n",
"sessions",
":=",
"s",
".",
"sessions",
"\n",
"s",
".",
"sessionLock",
".",
"RUnlock",
"(",
")",
"\n",
... | // notify queues a synchronisation notification with each of the active
// synchronisation sessions. | [
"notify",
"queues",
"a",
"synchronisation",
"notification",
"with",
"each",
"of",
"the",
"active",
"synchronisation",
"sessions",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L303-L310 |
26,483 | google/seesaw | engine/sync.go | run | func (s *syncServer) run() error {
heartbeat := time.NewTicker(s.heartbeatInterval)
for {
select {
case <-heartbeat.C:
now := time.Now()
s.sessionLock.Lock()
for id, ss := range s.sessions {
ss.RLock()
expiry := ss.expiryTime
ss.RUnlock()
if now.After(expiry) {
log.Warningf("Sync ses... | go | func (s *syncServer) run() error {
heartbeat := time.NewTicker(s.heartbeatInterval)
for {
select {
case <-heartbeat.C:
now := time.Now()
s.sessionLock.Lock()
for id, ss := range s.sessions {
ss.RLock()
expiry := ss.expiryTime
ss.RUnlock()
if now.After(expiry) {
log.Warningf("Sync ses... | [
"func",
"(",
"s",
"*",
"syncServer",
")",
"run",
"(",
")",
"error",
"{",
"heartbeat",
":=",
"time",
".",
"NewTicker",
"(",
"s",
".",
"heartbeatInterval",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"heartbeat",
".",
"C",
":",
"now",
":=",
"... | // run runs the synchronisation server, which is responsible for queueing
// heartbeat notifications and removing expired synchronisation sessions. | [
"run",
"runs",
"the",
"synchronisation",
"server",
"which",
"is",
"responsible",
"for",
"queueing",
"heartbeat",
"notifications",
"and",
"removing",
"expired",
"synchronisation",
"sessions",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L314-L335 |
26,484 | google/seesaw | engine/sync.go | newSyncClient | func newSyncClient(e *Engine) *syncClient {
sc := &syncClient{
engine: e,
quit: make(chan bool),
start: make(chan bool),
stopped: make(chan bool, 1),
}
sc.dispatch = sc.handleNote
sc.stopped <- true
return sc
} | go | func newSyncClient(e *Engine) *syncClient {
sc := &syncClient{
engine: e,
quit: make(chan bool),
start: make(chan bool),
stopped: make(chan bool, 1),
}
sc.dispatch = sc.handleNote
sc.stopped <- true
return sc
} | [
"func",
"newSyncClient",
"(",
"e",
"*",
"Engine",
")",
"*",
"syncClient",
"{",
"sc",
":=",
"&",
"syncClient",
"{",
"engine",
":",
"e",
",",
"quit",
":",
"make",
"(",
"chan",
"bool",
")",
",",
"start",
":",
"make",
"(",
"chan",
"bool",
")",
",",
"... | // newSyncClient returns an initialised synchronisation client. | [
"newSyncClient",
"returns",
"an",
"initialised",
"synchronisation",
"client",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L354-L364 |
26,485 | google/seesaw | engine/sync.go | dial | func (sc *syncClient) dial() error {
sc.lock.Lock()
defer sc.lock.Unlock()
if sc.client != nil {
sc.refs++
return nil
}
// TODO(jsing): Make this default to IPv6, if configured.
peer := &net.TCPAddr{
IP: sc.engine.config.Peer.IPv4Addr,
Port: sc.engine.config.SyncPort,
}
self := &net.TCPAddr{
IP: sc... | go | func (sc *syncClient) dial() error {
sc.lock.Lock()
defer sc.lock.Unlock()
if sc.client != nil {
sc.refs++
return nil
}
// TODO(jsing): Make this default to IPv6, if configured.
peer := &net.TCPAddr{
IP: sc.engine.config.Peer.IPv4Addr,
Port: sc.engine.config.SyncPort,
}
self := &net.TCPAddr{
IP: sc... | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"dial",
"(",
")",
"error",
"{",
"sc",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"sc",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"sc",
".",
"client",
"!=",
"nil",
"{",
"sc",
".",
"ref... | // dial establishes a connection to our peer Seesaw node. | [
"dial",
"establishes",
"a",
"connection",
"to",
"our",
"peer",
"Seesaw",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L367-L390 |
26,486 | google/seesaw | engine/sync.go | close | func (sc *syncClient) close() error {
sc.lock.Lock()
defer sc.lock.Unlock()
if sc.client == nil {
return nil
}
sc.refs--
if sc.refs > 0 {
return nil
}
if err := sc.client.Close(); err != nil {
sc.client = nil
return fmt.Errorf("client close failed: %v", err)
}
sc.client = nil
return nil
} | go | func (sc *syncClient) close() error {
sc.lock.Lock()
defer sc.lock.Unlock()
if sc.client == nil {
return nil
}
sc.refs--
if sc.refs > 0 {
return nil
}
if err := sc.client.Close(); err != nil {
sc.client = nil
return fmt.Errorf("client close failed: %v", err)
}
sc.client = nil
return nil
} | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"close",
"(",
")",
"error",
"{",
"sc",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"sc",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"sc",
".",
"client",
"==",
"nil",
"{",
"return",
"nil",... | // close closes an existing connection to our peer Seesaw node. | [
"close",
"closes",
"an",
"existing",
"connection",
"to",
"our",
"peer",
"Seesaw",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L393-L409 |
26,487 | google/seesaw | engine/sync.go | failover | func (sc *syncClient) failover() error {
if err := sc.dial(); err != nil {
return err
}
defer sc.close()
if err := sc.client.Call("SeesawSync.Failover", 0, nil); err != nil {
return err
}
return nil
} | go | func (sc *syncClient) failover() error {
if err := sc.dial(); err != nil {
return err
}
defer sc.close()
if err := sc.client.Call("SeesawSync.Failover", 0, nil); err != nil {
return err
}
return nil
} | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"failover",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"sc",
".",
"dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"sc",
".",
"close",
"(",
")",
"\n",
"if",
... | // failover requests that the peer node initiate a failover. | [
"failover",
"requests",
"that",
"the",
"peer",
"node",
"initiate",
"a",
"failover",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L412-L421 |
26,488 | google/seesaw | engine/sync.go | runOnce | func (sc *syncClient) runOnce() {
if err := sc.dial(); err != nil {
log.Warningf("Sync client dial failed: %v", err)
return
}
defer sc.close()
var sid SyncSessionID
self := sc.engine.config.Node.IPv4Addr
// Register for synchronisation events.
// TODO(jsing): Implement timeout on RPC?
if err := sc.client.... | go | func (sc *syncClient) runOnce() {
if err := sc.dial(); err != nil {
log.Warningf("Sync client dial failed: %v", err)
return
}
defer sc.close()
var sid SyncSessionID
self := sc.engine.config.Node.IPv4Addr
// Register for synchronisation events.
// TODO(jsing): Implement timeout on RPC?
if err := sc.client.... | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"runOnce",
"(",
")",
"{",
"if",
"err",
":=",
"sc",
".",
"dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"def... | // runOnce establishes a connection to the synchronisation server, registers
// for notifications, polls for notifications, then deregisters. | [
"runOnce",
"establishes",
"a",
"connection",
"to",
"the",
"synchronisation",
"server",
"registers",
"for",
"notifications",
"polls",
"for",
"notifications",
"then",
"deregisters",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L425-L452 |
26,489 | google/seesaw | engine/sync.go | poll | func (sc *syncClient) poll(sid SyncSessionID) {
for {
var sn SyncNotes
poll := sc.client.Go("SeesawSync.Poll", sid, &sn, nil)
select {
case <-poll.Done:
if poll.Error != nil {
log.Errorf("Synchronisation polling failed: %v", poll.Error)
return
}
for _, note := range sn.Notes {
sc.dispatch(... | go | func (sc *syncClient) poll(sid SyncSessionID) {
for {
var sn SyncNotes
poll := sc.client.Go("SeesawSync.Poll", sid, &sn, nil)
select {
case <-poll.Done:
if poll.Error != nil {
log.Errorf("Synchronisation polling failed: %v", poll.Error)
return
}
for _, note := range sn.Notes {
sc.dispatch(... | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"poll",
"(",
"sid",
"SyncSessionID",
")",
"{",
"for",
"{",
"var",
"sn",
"SyncNotes",
"\n",
"poll",
":=",
"sc",
".",
"client",
".",
"Go",
"(",
"\"",
"\"",
",",
"sid",
",",
"&",
"sn",
",",
"nil",
")",
"\... | // poll polls the synchronisation server for notifications, then dispatches
// them for processing. | [
"poll",
"polls",
"the",
"synchronisation",
"server",
"for",
"notifications",
"then",
"dispatches",
"them",
"for",
"processing",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L456-L479 |
26,490 | google/seesaw | engine/sync.go | handleNote | func (sc *syncClient) handleNote(note *SyncNote) {
switch note.Type {
case SNTHeartbeat:
log.V(1).Infoln("Sync client received heartbeat")
case SNTDesync:
sc.handleDesync()
case SNTConfigUpdate:
sc.handleConfigUpdate(note)
case SNTHealthcheck:
sc.handleHealthcheck(note)
case SNTOverride:
sc.handleOv... | go | func (sc *syncClient) handleNote(note *SyncNote) {
switch note.Type {
case SNTHeartbeat:
log.V(1).Infoln("Sync client received heartbeat")
case SNTDesync:
sc.handleDesync()
case SNTConfigUpdate:
sc.handleConfigUpdate(note)
case SNTHealthcheck:
sc.handleHealthcheck(note)
case SNTOverride:
sc.handleOv... | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"handleNote",
"(",
"note",
"*",
"SyncNote",
")",
"{",
"switch",
"note",
".",
"Type",
"{",
"case",
"SNTHeartbeat",
":",
"log",
".",
"V",
"(",
"1",
")",
".",
"Infoln",
"(",
"\"",
"\"",
")",
"\n\n",
"case",
... | // handleNote dispatches a synchronisation note to the appropriate handler. | [
"handleNote",
"dispatches",
"a",
"synchronisation",
"note",
"to",
"the",
"appropriate",
"handler",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L482-L502 |
26,491 | google/seesaw | engine/sync.go | handleOverride | func (sc *syncClient) handleOverride(sn *SyncNote) {
log.V(1).Infoln("Sync client received override notification")
if o := sn.VserverOverride; o != nil {
sc.engine.queueOverride(o)
}
if o := sn.DestinationOverride; o != nil {
sc.engine.queueOverride(o)
}
if o := sn.BackendOverride; o != nil {
sc.engine.que... | go | func (sc *syncClient) handleOverride(sn *SyncNote) {
log.V(1).Infoln("Sync client received override notification")
if o := sn.VserverOverride; o != nil {
sc.engine.queueOverride(o)
}
if o := sn.DestinationOverride; o != nil {
sc.engine.queueOverride(o)
}
if o := sn.BackendOverride; o != nil {
sc.engine.que... | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"handleOverride",
"(",
"sn",
"*",
"SyncNote",
")",
"{",
"log",
".",
"V",
"(",
"1",
")",
".",
"Infoln",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"o",
":=",
"sn",
".",
"VserverOverride",
";",
"o",
"!=",
"nil",
... | // handleOverride handles an override notification. | [
"handleOverride",
"handles",
"an",
"override",
"notification",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L523-L535 |
26,492 | google/seesaw | engine/sync.go | run | func (sc *syncClient) run() error {
for {
select {
case <-sc.stopped:
<-sc.start
log.Infof("Starting sync client...")
default:
sc.runOnce()
select {
case <-time.After(5 * time.Second):
case <-sc.quit:
sc.stopped <- true
}
}
}
} | go | func (sc *syncClient) run() error {
for {
select {
case <-sc.stopped:
<-sc.start
log.Infof("Starting sync client...")
default:
sc.runOnce()
select {
case <-time.After(5 * time.Second):
case <-sc.quit:
sc.stopped <- true
}
}
}
} | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"run",
"(",
")",
"error",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"sc",
".",
"stopped",
":",
"<-",
"sc",
".",
"start",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"sc",... | // run runs the synchronisation client. | [
"run",
"runs",
"the",
"synchronisation",
"client",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L538-L553 |
26,493 | google/seesaw | engine/sync.go | enable | func (sc *syncClient) enable() {
sc.lock.Lock()
start := !sc.enabled
sc.enabled = true
sc.lock.Unlock()
if start {
sc.start <- true
}
} | go | func (sc *syncClient) enable() {
sc.lock.Lock()
start := !sc.enabled
sc.enabled = true
sc.lock.Unlock()
if start {
sc.start <- true
}
} | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"enable",
"(",
")",
"{",
"sc",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"start",
":=",
"!",
"sc",
".",
"enabled",
"\n",
"sc",
".",
"enabled",
"=",
"true",
"\n",
"sc",
".",
"lock",
".",
"Unlock",
"(",
... | // enable enables synchronisation with our peer Seesaw node. | [
"enable",
"enables",
"synchronisation",
"with",
"our",
"peer",
"Seesaw",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L556-L564 |
26,494 | google/seesaw | engine/sync.go | disable | func (sc *syncClient) disable() {
sc.lock.Lock()
quit := sc.enabled
sc.enabled = false
sc.lock.Unlock()
if quit {
sc.quit <- true
}
} | go | func (sc *syncClient) disable() {
sc.lock.Lock()
quit := sc.enabled
sc.enabled = false
sc.lock.Unlock()
if quit {
sc.quit <- true
}
} | [
"func",
"(",
"sc",
"*",
"syncClient",
")",
"disable",
"(",
")",
"{",
"sc",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"quit",
":=",
"sc",
".",
"enabled",
"\n",
"sc",
".",
"enabled",
"=",
"false",
"\n",
"sc",
".",
"lock",
".",
"Unlock",
"(",
")",... | // disable disables synchronisation with our peer Seesaw node. | [
"disable",
"disables",
"synchronisation",
"with",
"our",
"peer",
"Seesaw",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/sync.go#L567-L575 |
26,495 | google/seesaw | common/seesaw/seesaw.go | String | func (sc Component) String() string {
if name, ok := componentNames[sc]; ok {
return name
}
return "(unknown)"
} | go | func (sc Component) String() string {
if name, ok := componentNames[sc]; ok {
return name
}
return "(unknown)"
} | [
"func",
"(",
"sc",
"Component",
")",
"String",
"(",
")",
"string",
"{",
"if",
"name",
",",
"ok",
":=",
"componentNames",
"[",
"sc",
"]",
";",
"ok",
"{",
"return",
"name",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // String returns the string representation of a Component. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"Component",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L93-L98 |
26,496 | google/seesaw | common/seesaw/seesaw.go | String | func (h HealthcheckType) String() string {
switch h {
case HCTypeDNS:
return "DNS"
case HCTypeHTTP:
return "HTTP"
// TODO(angusc): Drop HTTPS as a separate type.
case HCTypeHTTPS:
return "HTTP" // NB: Not HTTPS
case HCTypeICMP:
return "ICMP"
case HCTypeRADIUS:
return "RADIUS"
case HCTypeTCP:
return ... | go | func (h HealthcheckType) String() string {
switch h {
case HCTypeDNS:
return "DNS"
case HCTypeHTTP:
return "HTTP"
// TODO(angusc): Drop HTTPS as a separate type.
case HCTypeHTTPS:
return "HTTP" // NB: Not HTTPS
case HCTypeICMP:
return "ICMP"
case HCTypeRADIUS:
return "RADIUS"
case HCTypeTCP:
return ... | [
"func",
"(",
"h",
"HealthcheckType",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"h",
"{",
"case",
"HCTypeDNS",
":",
"return",
"\"",
"\"",
"\n",
"case",
"HCTypeHTTP",
":",
"return",
"\"",
"\"",
"\n",
"// TODO(angusc): Drop HTTPS as a separate type.",
"ca... | // String returns the name for the given HealthcheckType. | [
"String",
"returns",
"the",
"name",
"for",
"the",
"given",
"HealthcheckType",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L159-L181 |
26,497 | google/seesaw | common/seesaw/seesaw.go | String | func (v VIP) String() string {
return fmt.Sprintf("%v (%v)", v.IP, v.Type)
} | go | func (v VIP) String() string {
return fmt.Sprintf("%v (%v)", v.IP, v.Type)
} | [
"func",
"(",
"v",
"VIP",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"IP",
",",
"v",
".",
"Type",
")",
"\n",
"}"
] | // String returns the string representation of a VIP. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"VIP",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L213-L215 |
26,498 | google/seesaw | common/seesaw/seesaw.go | NewVIP | func NewVIP(ip net.IP, vipSubnets map[string]*net.IPNet) *VIP {
vipType := UnicastVIP
switch {
case IsAnycast(ip):
vipType = AnycastVIP
case InSubnets(ip, vipSubnets):
vipType = DedicatedVIP
}
return &VIP{
IP: NewIP(ip),
Type: vipType,
}
} | go | func NewVIP(ip net.IP, vipSubnets map[string]*net.IPNet) *VIP {
vipType := UnicastVIP
switch {
case IsAnycast(ip):
vipType = AnycastVIP
case InSubnets(ip, vipSubnets):
vipType = DedicatedVIP
}
return &VIP{
IP: NewIP(ip),
Type: vipType,
}
} | [
"func",
"NewVIP",
"(",
"ip",
"net",
".",
"IP",
",",
"vipSubnets",
"map",
"[",
"string",
"]",
"*",
"net",
".",
"IPNet",
")",
"*",
"VIP",
"{",
"vipType",
":=",
"UnicastVIP",
"\n",
"switch",
"{",
"case",
"IsAnycast",
"(",
"ip",
")",
":",
"vipType",
"=... | // NewVIP returns a seesaw VIP. | [
"NewVIP",
"returns",
"a",
"seesaw",
"VIP",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L218-L230 |
26,499 | google/seesaw | common/seesaw/seesaw.go | NewIP | func NewIP(nip net.IP) IP {
var ip IP
copy(ip[:], nip.To16())
return ip
} | go | func NewIP(nip net.IP) IP {
var ip IP
copy(ip[:], nip.To16())
return ip
} | [
"func",
"NewIP",
"(",
"nip",
"net",
".",
"IP",
")",
"IP",
"{",
"var",
"ip",
"IP",
"\n",
"copy",
"(",
"ip",
"[",
":",
"]",
",",
"nip",
".",
"To16",
"(",
")",
")",
"\n",
"return",
"ip",
"\n",
"}"
] | // NewIP returns a seesaw IP initialised from a net.IP address. | [
"NewIP",
"returns",
"a",
"seesaw",
"IP",
"initialised",
"from",
"a",
"net",
".",
"IP",
"address",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L236-L240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.