repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
google/seesaw
engine/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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
google/seesaw
common/seesaw/seesaw.go
AF
func (ip IP) AF() AF { if ip.IP().To4() != nil { return IPv4 } return IPv6 }
go
func (ip IP) AF() AF { if ip.IP().To4() != nil { return IPv4 } return IPv6 }
[ "func", "(", "ip", "IP", ")", "AF", "(", ")", "AF", "{", "if", "ip", ".", "IP", "(", ")", ".", "To4", "(", ")", "!=", "nil", "{", "return", "IPv4", "\n", "}", "\n", "return", "IPv6", "\n", "}" ]
// AF returns the address family of a seesaw IP address.
[ "AF", "returns", "the", "address", "family", "of", "a", "seesaw", "IP", "address", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L260-L265
train
google/seesaw
common/seesaw/seesaw.go
String
func (lbm LBMode) String() string { if name, ok := modeNames[lbm]; ok { return name } return "(unknown)" }
go
func (lbm LBMode) String() string { if name, ok := modeNames[lbm]; ok { return name } return "(unknown)" }
[ "func", "(", "lbm", "LBMode", ")", "String", "(", ")", "string", "{", "if", "name", ",", "ok", ":=", "modeNames", "[", "lbm", "]", ";", "ok", "{", "return", "name", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// String returns the string representation of a LBMode.
[ "String", "returns", "the", "string", "representation", "of", "a", "LBMode", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L313-L318
train
google/seesaw
common/seesaw/seesaw.go
String
func (lbs LBScheduler) String() string { if name, ok := schedulerNames[lbs]; ok { return name } return "(unknown)" }
go
func (lbs LBScheduler) String() string { if name, ok := schedulerNames[lbs]; ok { return name } return "(unknown)" }
[ "func", "(", "lbs", "LBScheduler", ")", "String", "(", ")", "string", "{", "if", "name", ",", "ok", ":=", "schedulerNames", "[", "lbs", "]", ";", "ok", "{", "return", "name", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// String returns the string representation of a LBScheduler.
[ "String", "returns", "the", "string", "representation", "of", "a", "LBScheduler", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/seesaw.go#L342-L347
train
google/seesaw
healthcheck/dial.go
setSocketMark
func setSocketMark(fd, mark int) error { if err := syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_MARK, mark); err != nil { return os.NewSyscallError("failed to set mark", err) } return nil }
go
func setSocketMark(fd, mark int) error { if err := syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_MARK, mark); err != nil { return os.NewSyscallError("failed to set mark", err) } return nil }
[ "func", "setSocketMark", "(", "fd", ",", "mark", "int", ")", "error", "{", "if", "err", ":=", "syscall", ".", "SetsockoptInt", "(", "fd", ",", "syscall", ".", "SOL_SOCKET", ",", "syscall", ".", "SO_MARK", ",", "mark", ")", ";", "err", "!=", "nil", "{...
// setSocketMark sets packet marking on the given socket.
[ "setSocketMark", "sets", "packet", "marking", "on", "the", "given", "socket", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/dial.go#L198-L203
train
google/seesaw
healthcheck/dial.go
setSocketTimeout
func setSocketTimeout(fd int, timeout time.Duration) error { tv := syscall.NsecToTimeval(timeout.Nanoseconds()) for _, opt := range []int{syscall.SO_RCVTIMEO, syscall.SO_SNDTIMEO} { if err := syscall.SetsockoptTimeval(fd, syscall.SOL_SOCKET, opt, &tv); err != nil { return os.NewSyscallError("setsockopt", err) ...
go
func setSocketTimeout(fd int, timeout time.Duration) error { tv := syscall.NsecToTimeval(timeout.Nanoseconds()) for _, opt := range []int{syscall.SO_RCVTIMEO, syscall.SO_SNDTIMEO} { if err := syscall.SetsockoptTimeval(fd, syscall.SOL_SOCKET, opt, &tv); err != nil { return os.NewSyscallError("setsockopt", err) ...
[ "func", "setSocketTimeout", "(", "fd", "int", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "tv", ":=", "syscall", ".", "NsecToTimeval", "(", "timeout", ".", "Nanoseconds", "(", ")", ")", "\n", "for", "_", ",", "opt", ":=", "range", "[", ...
// setSocketTimeout sets the receive and send timeouts on the given socket.
[ "setSocketTimeout", "sets", "the", "receive", "and", "send", "timeouts", "on", "the", "given", "socket", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/dial.go#L206-L214
train
google/seesaw
engine/vserver.go
newVserver
func newVserver(e *Engine) *vserver { return &vserver{ engine: e, ncc: ncclient.NewNCC(e.config.NCCSocket), fwm: make(map[seesaw.AF]uint32), active: make(map[seesaw.IP]bool), lbVservers: make(map[seesaw.IP]*seesaw.Vserver), vips: make(map[seesaw.VIP]bool), overrideChan: make(chan se...
go
func newVserver(e *Engine) *vserver { return &vserver{ engine: e, ncc: ncclient.NewNCC(e.config.NCCSocket), fwm: make(map[seesaw.AF]uint32), active: make(map[seesaw.IP]bool), lbVservers: make(map[seesaw.IP]*seesaw.Vserver), vips: make(map[seesaw.VIP]bool), overrideChan: make(chan se...
[ "func", "newVserver", "(", "e", "*", "Engine", ")", "*", "vserver", "{", "return", "&", "vserver", "{", "engine", ":", "e", ",", "ncc", ":", "ncclient", ".", "NewNCC", "(", "e", ".", "config", ".", "NCCSocket", ")", ",", "fwm", ":", "make", "(", ...
// newVserver returns an initialised vserver struct.
[ "newVserver", "returns", "an", "initialised", "vserver", "struct", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L61-L78
train
google/seesaw
engine/vserver.go
String
func (v *vserver) String() string { if v.config != nil { return v.config.Name } return fmt.Sprintf("Unconfigured vserver %+v", *v) }
go
func (v *vserver) String() string { if v.config != nil { return v.config.Name } return fmt.Sprintf("Unconfigured vserver %+v", *v) }
[ "func", "(", "v", "*", "vserver", ")", "String", "(", ")", "string", "{", "if", "v", ".", "config", "!=", "nil", "{", "return", "v", ".", "config", ".", "Name", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "*", "v", ...
// String returns a string representing a vserver.
[ "String", "returns", "a", "string", "representing", "a", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L81-L86
train
google/seesaw
engine/vserver.go
ipvsService
func (svc *service) ipvsService() *ipvs.Service { var flags ipvs.ServiceFlags if svc.ventry.Persistence > 0 { flags |= ipvs.SFPersistent } if svc.ventry.OnePacket { flags |= ipvs.SFOnePacket } var ip net.IP switch { case svc.fwm > 0 && svc.af == seesaw.IPv4: ip = net.IPv4zero case svc.fwm > 0 && svc.af =...
go
func (svc *service) ipvsService() *ipvs.Service { var flags ipvs.ServiceFlags if svc.ventry.Persistence > 0 { flags |= ipvs.SFPersistent } if svc.ventry.OnePacket { flags |= ipvs.SFOnePacket } var ip net.IP switch { case svc.fwm > 0 && svc.af == seesaw.IPv4: ip = net.IPv4zero case svc.fwm > 0 && svc.af =...
[ "func", "(", "svc", "*", "service", ")", "ipvsService", "(", ")", "*", "ipvs", ".", "Service", "{", "var", "flags", "ipvs", ".", "ServiceFlags", "\n", "if", "svc", ".", "ventry", ".", "Persistence", ">", "0", "{", "flags", "|=", "ipvs", ".", "SFPersi...
// ipvsService returns an IPVS Service for the given service.
[ "ipvsService", "returns", "an", "IPVS", "Service", "for", "the", "given", "service", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L110-L136
train
google/seesaw
engine/vserver.go
ipvsEqual
func (s *service) ipvsEqual(other *service) bool { return s.ipvsSvc.Equal(*other.ipvsSvc) && s.ventry.Mode == other.ventry.Mode && s.ventry.LThreshold == other.ventry.LThreshold && s.ventry.UThreshold == other.ventry.UThreshold }
go
func (s *service) ipvsEqual(other *service) bool { return s.ipvsSvc.Equal(*other.ipvsSvc) && s.ventry.Mode == other.ventry.Mode && s.ventry.LThreshold == other.ventry.LThreshold && s.ventry.UThreshold == other.ventry.UThreshold }
[ "func", "(", "s", "*", "service", ")", "ipvsEqual", "(", "other", "*", "service", ")", "bool", "{", "return", "s", ".", "ipvsSvc", ".", "Equal", "(", "*", "other", ".", "ipvsSvc", ")", "&&", "s", ".", "ventry", ".", "Mode", "==", "other", ".", "v...
// ipvsEqual returns true if two services have the same IPVS configuration. // Transient state and the services' destinations are ignored.
[ "ipvsEqual", "returns", "true", "if", "two", "services", "have", "the", "same", "IPVS", "configuration", ".", "Transient", "state", "and", "the", "services", "destinations", "are", "ignored", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L140-L145
train
google/seesaw
engine/vserver.go
String
func (s *service) String() string { if s.fwm != 0 { return fmt.Sprintf("%v/fwm:%d", s.ip, s.fwm) } ip := s.ip.String() port := strconv.Itoa(int(s.port)) return fmt.Sprintf("%v/%v", net.JoinHostPort(ip, port), s.proto) }
go
func (s *service) String() string { if s.fwm != 0 { return fmt.Sprintf("%v/fwm:%d", s.ip, s.fwm) } ip := s.ip.String() port := strconv.Itoa(int(s.port)) return fmt.Sprintf("%v/%v", net.JoinHostPort(ip, port), s.proto) }
[ "func", "(", "s", "*", "service", ")", "String", "(", ")", "string", "{", "if", "s", ".", "fwm", "!=", "0", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "ip", ",", "s", ".", "fwm", ")", "\n", "}", "\n", "ip", ":=", ...
// String returns a string representing a service.
[ "String", "returns", "a", "string", "representing", "a", "service", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L148-L155
train
google/seesaw
engine/vserver.go
ipvsDestination
func (dst *destination) ipvsDestination() *ipvs.Destination { var flags ipvs.DestinationFlags switch dst.service.ventry.Mode { case seesaw.LBModeNone: log.Warningf("%v: Unspecified LB mode", dst) case seesaw.LBModeDSR: flags |= ipvs.DFForwardRoute case seesaw.LBModeNAT: flags |= ipvs.DFForwardMasq } return...
go
func (dst *destination) ipvsDestination() *ipvs.Destination { var flags ipvs.DestinationFlags switch dst.service.ventry.Mode { case seesaw.LBModeNone: log.Warningf("%v: Unspecified LB mode", dst) case seesaw.LBModeDSR: flags |= ipvs.DFForwardRoute case seesaw.LBModeNAT: flags |= ipvs.DFForwardMasq } return...
[ "func", "(", "dst", "*", "destination", ")", "ipvsDestination", "(", ")", "*", "ipvs", ".", "Destination", "{", "var", "flags", "ipvs", ".", "DestinationFlags", "\n", "switch", "dst", ".", "service", ".", "ventry", ".", "Mode", "{", "case", "seesaw", "."...
// ipvsDestination returns an IPVS Destination for the given destination.
[ "ipvsDestination", "returns", "an", "IPVS", "Destination", "for", "the", "given", "destination", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L181-L199
train
google/seesaw
engine/vserver.go
ipvsEqual
func (d *destination) ipvsEqual(other *destination) bool { return d.ipvsDst.Equal(*other.ipvsDst) }
go
func (d *destination) ipvsEqual(other *destination) bool { return d.ipvsDst.Equal(*other.ipvsDst) }
[ "func", "(", "d", "*", "destination", ")", "ipvsEqual", "(", "other", "*", "destination", ")", "bool", "{", "return", "d", ".", "ipvsDst", ".", "Equal", "(", "*", "other", ".", "ipvsDst", ")", "\n", "}" ]
// ipvsEqual returns true if two destinations have the same IPVS configuration. // Transient state is ignored.
[ "ipvsEqual", "returns", "true", "if", "two", "destinations", "have", "the", "same", "IPVS", "configuration", ".", "Transient", "state", "is", "ignored", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L203-L205
train
google/seesaw
engine/vserver.go
String
func (d *destination) String() string { if d.service.fwm != 0 { return fmt.Sprintf("%v", d.ip) } ip := d.ip.String() port := strconv.Itoa(int(d.service.port)) return fmt.Sprintf("%v/%v", net.JoinHostPort(ip, port), d.service.proto) }
go
func (d *destination) String() string { if d.service.fwm != 0 { return fmt.Sprintf("%v", d.ip) } ip := d.ip.String() port := strconv.Itoa(int(d.service.port)) return fmt.Sprintf("%v/%v", net.JoinHostPort(ip, port), d.service.proto) }
[ "func", "(", "d", "*", "destination", ")", "String", "(", ")", "string", "{", "if", "d", ".", "service", ".", "fwm", "!=", "0", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "d", ".", "ip", ")", "\n", "}", "\n", "ip", ":=", "d",...
// String returns a string representing a destination.
[ "String", "returns", "a", "string", "representing", "a", "destination", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L208-L215
train
google/seesaw
engine/vserver.go
name
func (d *destination) name() string { return fmt.Sprintf("%v/%v", d.service.vserver.String(), d.String()) }
go
func (d *destination) name() string { return fmt.Sprintf("%v/%v", d.service.vserver.String(), d.String()) }
[ "func", "(", "d", "*", "destination", ")", "name", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "d", ".", "service", ".", "vserver", ".", "String", "(", ")", ",", "d", ".", "String", "(", ")", ")", "\n", "}" ]
// name returns the name of a destination.
[ "name", "returns", "the", "name", "of", "a", "destination", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L218-L220
train
google/seesaw
engine/vserver.go
newCheckKey
func newCheckKey(vip, bip seesaw.IP, port uint16, proto seesaw.IPProto, h *config.Healthcheck) checkKey { return checkKey{ vserverIP: vip, backendIP: bip, servicePort: port, serviceProtocol: proto, healthcheckMode: h.Mode, healthcheckType: h.Type, healthcheckPort: h.Port, name: ...
go
func newCheckKey(vip, bip seesaw.IP, port uint16, proto seesaw.IPProto, h *config.Healthcheck) checkKey { return checkKey{ vserverIP: vip, backendIP: bip, servicePort: port, serviceProtocol: proto, healthcheckMode: h.Mode, healthcheckType: h.Type, healthcheckPort: h.Port, name: ...
[ "func", "newCheckKey", "(", "vip", ",", "bip", "seesaw", ".", "IP", ",", "port", "uint16", ",", "proto", "seesaw", ".", "IPProto", ",", "h", "*", "config", ".", "Healthcheck", ")", "checkKey", "{", "return", "checkKey", "{", "vserverIP", ":", "vip", ",...
// newCheckKey returns an initialised checkKey.
[ "newCheckKey", "returns", "an", "initialised", "checkKey", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L235-L246
train
google/seesaw
engine/vserver.go
String
func (c checkKey) String() string { return fmt.Sprintf("%v:%d/%v backend %v:%d/%v %v %v port %d (%s)", c.vserverIP, c.servicePort, c.serviceProtocol, c.backendIP, c.servicePort, c.serviceProtocol, c.healthcheckMode, c.healthcheckType, c.healthcheckPort, c.name) }
go
func (c checkKey) String() string { return fmt.Sprintf("%v:%d/%v backend %v:%d/%v %v %v port %d (%s)", c.vserverIP, c.servicePort, c.serviceProtocol, c.backendIP, c.servicePort, c.serviceProtocol, c.healthcheckMode, c.healthcheckType, c.healthcheckPort, c.name) }
[ "func", "(", "c", "checkKey", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "vserverIP", ",", "c", ".", "servicePort", ",", "c", ".", "serviceProtocol", ",", "c", ".", "backendIP", ",", "c"...
// String returns the string representation of a checkKey.
[ "String", "returns", "the", "string", "representation", "of", "a", "checkKey", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L249-L254
train
google/seesaw
engine/vserver.go
newCheck
func newCheck(key checkKey, v *vserver, h *config.Healthcheck) *check { return &check{ key: key, vserver: v, healthcheck: h, } }
go
func newCheck(key checkKey, v *vserver, h *config.Healthcheck) *check { return &check{ key: key, vserver: v, healthcheck: h, } }
[ "func", "newCheck", "(", "key", "checkKey", ",", "v", "*", "vserver", ",", "h", "*", "config", ".", "Healthcheck", ")", "*", "check", "{", "return", "&", "check", "{", "key", ":", "key", ",", "vserver", ":", "v", ",", "healthcheck", ":", "h", ",", ...
// newCheck returns an initialised check.
[ "newCheck", "returns", "an", "initialised", "check", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L267-L273
train
google/seesaw
engine/vserver.go
expandServices
func (v *vserver) expandServices() map[serviceKey]*service { if v.config.UseFWM { return v.expandFWMServices() } svcs := make(map[serviceKey]*service) for _, af := range seesaw.AFs() { var ip net.IP switch af { case seesaw.IPv4: ip = v.config.Host.IPv4Addr case seesaw.IPv6: ip = v.config.Host.IPv6A...
go
func (v *vserver) expandServices() map[serviceKey]*service { if v.config.UseFWM { return v.expandFWMServices() } svcs := make(map[serviceKey]*service) for _, af := range seesaw.AFs() { var ip net.IP switch af { case seesaw.IPv4: ip = v.config.Host.IPv4Addr case seesaw.IPv6: ip = v.config.Host.IPv6A...
[ "func", "(", "v", "*", "vserver", ")", "expandServices", "(", ")", "map", "[", "serviceKey", "]", "*", "service", "{", "if", "v", ".", "config", ".", "UseFWM", "{", "return", "v", ".", "expandFWMServices", "(", ")", "\n", "}", "\n\n", "svcs", ":=", ...
// expandServices returns a list of services that have been expanded from the // vserver configuration.
[ "expandServices", "returns", "a", "list", "of", "services", "that", "have", "been", "expanded", "from", "the", "vserver", "configuration", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L290-L325
train
google/seesaw
engine/vserver.go
expandFWMServices
func (v *vserver) expandFWMServices() map[serviceKey]*service { svcs := make(map[serviceKey]*service) for _, af := range seesaw.AFs() { var ip net.IP switch af { case seesaw.IPv4: ip = v.config.Host.IPv4Addr case seesaw.IPv6: ip = v.config.Host.IPv6Addr } if ip == nil { continue } // Persist...
go
func (v *vserver) expandFWMServices() map[serviceKey]*service { svcs := make(map[serviceKey]*service) for _, af := range seesaw.AFs() { var ip net.IP switch af { case seesaw.IPv4: ip = v.config.Host.IPv4Addr case seesaw.IPv6: ip = v.config.Host.IPv6Addr } if ip == nil { continue } // Persist...
[ "func", "(", "v", "*", "vserver", ")", "expandFWMServices", "(", ")", "map", "[", "serviceKey", "]", "*", "service", "{", "svcs", ":=", "make", "(", "map", "[", "serviceKey", "]", "*", "service", ")", "\n", "for", "_", ",", "af", ":=", "range", "se...
// expandFWMServices returns a list of services that have been expanded from the // vserver configuration for a firewall mark based vserver.
[ "expandFWMServices", "returns", "a", "list", "of", "services", "that", "have", "been", "expanded", "from", "the", "vserver", "configuration", "for", "a", "firewall", "mark", "based", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L329-L373
train
google/seesaw
engine/vserver.go
expandDests
func (v *vserver) expandDests(svc *service) map[destinationKey]*destination { dsts := make(map[destinationKey]*destination, len(v.config.Backends)) for _, backend := range v.config.Backends { var ip net.IP switch svc.af { case seesaw.IPv4: ip = backend.Host.IPv4Addr case seesaw.IPv6: ip = backend.Host.I...
go
func (v *vserver) expandDests(svc *service) map[destinationKey]*destination { dsts := make(map[destinationKey]*destination, len(v.config.Backends)) for _, backend := range v.config.Backends { var ip net.IP switch svc.af { case seesaw.IPv4: ip = backend.Host.IPv4Addr case seesaw.IPv6: ip = backend.Host.I...
[ "func", "(", "v", "*", "vserver", ")", "expandDests", "(", "svc", "*", "service", ")", "map", "[", "destinationKey", "]", "*", "destination", "{", "dsts", ":=", "make", "(", "map", "[", "destinationKey", "]", "*", "destination", ",", "len", "(", "v", ...
// expandDests returns a list of destinations that have been expanded from the // vserver configuration and a given service.
[ "expandDests", "returns", "a", "list", "of", "destinations", "that", "have", "been", "expanded", "from", "the", "vserver", "configuration", "and", "a", "given", "service", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L377-L401
train
google/seesaw
engine/vserver.go
expandChecks
func (v *vserver) expandChecks() map[checkKey]*check { checks := make(map[checkKey]*check) for _, svc := range v.services { for _, dest := range svc.dests { dest.checks = make([]*check, 0) if !dest.backend.Enabled { continue } for _, hc := range v.config.Healthchecks { // vserver-level healthche...
go
func (v *vserver) expandChecks() map[checkKey]*check { checks := make(map[checkKey]*check) for _, svc := range v.services { for _, dest := range svc.dests { dest.checks = make([]*check, 0) if !dest.backend.Enabled { continue } for _, hc := range v.config.Healthchecks { // vserver-level healthche...
[ "func", "(", "v", "*", "vserver", ")", "expandChecks", "(", ")", "map", "[", "checkKey", "]", "*", "check", "{", "checks", ":=", "make", "(", "map", "[", "checkKey", "]", "*", "check", ")", "\n", "for", "_", ",", "svc", ":=", "range", "v", ".", ...
// expandChecks returns a list of checks that have been expanded from the // vserver configuration.
[ "expandChecks", "returns", "a", "list", "of", "checks", "that", "have", "been", "expanded", "from", "the", "vserver", "configuration", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L405-L448
train
google/seesaw
engine/vserver.go
healthchecks
func (v *vserver) healthchecks() vserverChecks { vc := vserverChecks{vserverName: v.config.Name} if v.enabled { vc.checks = v.checks } return vc }
go
func (v *vserver) healthchecks() vserverChecks { vc := vserverChecks{vserverName: v.config.Name} if v.enabled { vc.checks = v.checks } return vc }
[ "func", "(", "v", "*", "vserver", ")", "healthchecks", "(", ")", "vserverChecks", "{", "vc", ":=", "vserverChecks", "{", "vserverName", ":", "v", ".", "config", ".", "Name", "}", "\n", "if", "v", ".", "enabled", "{", "vc", ".", "checks", "=", "v", ...
// healthchecks returns the vserverChecks for a vserver.
[ "healthchecks", "returns", "the", "vserverChecks", "for", "a", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L451-L457
train
google/seesaw
engine/vserver.go
run
func (v *vserver) run() { statsTicker := time.NewTicker(v.engine.config.StatsInterval) for { select { case <-v.quit: // Shutdown active vservers, services and destinations. // There is no race between this and new healthcheck // notifications, since they are also handled via the // same vserver go rou...
go
func (v *vserver) run() { statsTicker := time.NewTicker(v.engine.config.StatsInterval) for { select { case <-v.quit: // Shutdown active vservers, services and destinations. // There is no race between this and new healthcheck // notifications, since they are also handled via the // same vserver go rou...
[ "func", "(", "v", "*", "vserver", ")", "run", "(", ")", "{", "statsTicker", ":=", "time", ".", "NewTicker", "(", "v", ".", "engine", ".", "config", ".", "StatsInterval", ")", "\n", "for", "{", "select", "{", "case", "<-", "v", ".", "quit", ":", "...
// run invokes a vserver. This is a long-lived Go routine that lasts for the // duration of the vserver, reacting to configuration changes and healthcheck // notifications.
[ "run", "invokes", "a", "vserver", ".", "This", "is", "a", "long", "-", "lived", "Go", "routine", "that", "lasts", "for", "the", "duration", "of", "the", "vserver", "reacting", "to", "configuration", "changes", "and", "healthcheck", "notifications", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L462-L512
train
google/seesaw
engine/vserver.go
handleConfigUpdate
func (v *vserver) handleConfigUpdate(config *config.Vserver) { if config == nil { return } switch { case v.config == nil: v.configInit(config) return case v.enabled && !vserverEnabled(config, v.vserverOverride.State()): log.Infof("%v: disabling vserver", v) v.downAll() v.unconfigureVIPs() v.configIn...
go
func (v *vserver) handleConfigUpdate(config *config.Vserver) { if config == nil { return } switch { case v.config == nil: v.configInit(config) return case v.enabled && !vserverEnabled(config, v.vserverOverride.State()): log.Infof("%v: disabling vserver", v) v.downAll() v.unconfigureVIPs() v.configIn...
[ "func", "(", "v", "*", "vserver", ")", "handleConfigUpdate", "(", "config", "*", "config", ".", "Vserver", ")", "{", "if", "config", "==", "nil", "{", "return", "\n", "}", "\n", "switch", "{", "case", "v", ".", "config", "==", "nil", ":", "v", ".",...
// handleConfigUpdate updates the internal structures of a vserver using the // new configuration.
[ "handleConfigUpdate", "updates", "the", "internal", "structures", "of", "a", "vserver", "using", "the", "new", "configuration", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L543-L611
train
google/seesaw
engine/vserver.go
configInit
func (v *vserver) configInit(config *config.Vserver) { v.config = config v.enabled = vserverEnabled(config, v.vserverOverride.State()) newSvcs := v.expandServices() // Preserve stats if this is a reinit for svcK, svc := range newSvcs { svc.dests = v.expandDests(svc) if oldSvc, ok := v.services[svcK]; ok { *...
go
func (v *vserver) configInit(config *config.Vserver) { v.config = config v.enabled = vserverEnabled(config, v.vserverOverride.State()) newSvcs := v.expandServices() // Preserve stats if this is a reinit for svcK, svc := range newSvcs { svc.dests = v.expandDests(svc) if oldSvc, ok := v.services[svcK]; ok { *...
[ "func", "(", "v", "*", "vserver", ")", "configInit", "(", "config", "*", "config", ".", "Vserver", ")", "{", "v", ".", "config", "=", "config", "\n", "v", ".", "enabled", "=", "vserverEnabled", "(", "config", ",", "v", ".", "vserverOverride", ".", "S...
// configInit initialises all services, destinations, healthchecks and VIPs for // a vserver.
[ "configInit", "initialises", "all", "services", "destinations", "healthchecks", "and", "VIPs", "for", "a", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L615-L637
train
google/seesaw
engine/vserver.go
configUpdate
func (v *vserver) configUpdate() { newSvcs := v.expandServices() for svcKey, newSvc := range newSvcs { if svc, ok := v.services[svcKey]; ok { if svc.ip.Equal(newSvc.ip) { svc.update(newSvc) continue } log.Infof("%v: service %v: new IP address: %v", v, svc, newSvc.ip) v.deleteService(svc) } l...
go
func (v *vserver) configUpdate() { newSvcs := v.expandServices() for svcKey, newSvc := range newSvcs { if svc, ok := v.services[svcKey]; ok { if svc.ip.Equal(newSvc.ip) { svc.update(newSvc) continue } log.Infof("%v: service %v: new IP address: %v", v, svc, newSvc.ip) v.deleteService(svc) } l...
[ "func", "(", "v", "*", "vserver", ")", "configUpdate", "(", ")", "{", "newSvcs", ":=", "v", ".", "expandServices", "(", ")", "\n", "for", "svcKey", ",", "newSvc", ":=", "range", "newSvcs", "{", "if", "svc", ",", "ok", ":=", "v", ".", "services", "[...
// configUpdate updates the services, destinations, checks, and VIPs for a // vserver.
[ "configUpdate", "updates", "the", "services", "destinations", "checks", "and", "VIPs", "for", "a", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L641-L712
train
google/seesaw
engine/vserver.go
deleteService
func (v *vserver) deleteService(s *service) { if s.active { s.healthy = false v.updateState(s.ip) } log.Infof("%v: deleting service: %v", v, s) delete(v.services, s.serviceKey) // TODO(baptr): Once service contains seesaw.VIP, move check and // unconfigureVIP here. }
go
func (v *vserver) deleteService(s *service) { if s.active { s.healthy = false v.updateState(s.ip) } log.Infof("%v: deleting service: %v", v, s) delete(v.services, s.serviceKey) // TODO(baptr): Once service contains seesaw.VIP, move check and // unconfigureVIP here. }
[ "func", "(", "v", "*", "vserver", ")", "deleteService", "(", "s", "*", "service", ")", "{", "if", "s", ".", "active", "{", "s", ".", "healthy", "=", "false", "\n", "v", ".", "updateState", "(", "s", ".", "ip", ")", "\n", "}", "\n", "log", ".", ...
// deleteService deletes a service for a vserver.
[ "deleteService", "deletes", "a", "service", "for", "a", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L715-L724
train
google/seesaw
engine/vserver.go
handleCheckNotification
func (v *vserver) handleCheckNotification(n *checkNotification) { if !v.enabled { log.Infof("%v: ignoring healthcheck notification %s (vserver disabled)", v, n.description) return } check := v.checks[n.key] if check == nil { log.Warningf("%v: unknown check key %v", v, n.key) return } transition := (chec...
go
func (v *vserver) handleCheckNotification(n *checkNotification) { if !v.enabled { log.Infof("%v: ignoring healthcheck notification %s (vserver disabled)", v, n.description) return } check := v.checks[n.key] if check == nil { log.Warningf("%v: unknown check key %v", v, n.key) return } transition := (chec...
[ "func", "(", "v", "*", "vserver", ")", "handleCheckNotification", "(", "n", "*", "checkNotification", ")", "{", "if", "!", "v", ".", "enabled", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "v", ",", "n", ".", "description", ")", "\n", "return", ...
// handleCheckNotification processes a checkNotification, bringing // destinations, services, and vservers up or down appropriately.
[ "handleCheckNotification", "processes", "a", "checkNotification", "bringing", "destinations", "services", "and", "vservers", "up", "or", "down", "appropriately", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L728-L749
train
google/seesaw
engine/vserver.go
handleOverride
func (v *vserver) handleOverride(o seesaw.Override) { switch override := o.(type) { case *seesaw.VserverOverride: if v.vserverOverride == *override { // No change return } v.vserverOverride = *override if vserverEnabled(v.config, o.State()) == v.enabled { // enable state not changed - nothing to do ...
go
func (v *vserver) handleOverride(o seesaw.Override) { switch override := o.(type) { case *seesaw.VserverOverride: if v.vserverOverride == *override { // No change return } v.vserverOverride = *override if vserverEnabled(v.config, o.State()) == v.enabled { // enable state not changed - nothing to do ...
[ "func", "(", "v", "*", "vserver", ")", "handleOverride", "(", "o", "seesaw", ".", "Override", ")", "{", "switch", "override", ":=", "o", ".", "(", "type", ")", "{", "case", "*", "seesaw", ".", "VserverOverride", ":", "if", "v", ".", "vserverOverride", ...
// handleOverride processes an Override.
[ "handleOverride", "processes", "an", "Override", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L752-L771
train
google/seesaw
engine/vserver.go
vserverEnabled
func vserverEnabled(config *config.Vserver, os seesaw.OverrideState) bool { switch { case config == nil: return false case os == seesaw.OverrideDisable: return false case os == seesaw.OverrideEnable: return true } return config.Enabled }
go
func vserverEnabled(config *config.Vserver, os seesaw.OverrideState) bool { switch { case config == nil: return false case os == seesaw.OverrideDisable: return false case os == seesaw.OverrideEnable: return true } return config.Enabled }
[ "func", "vserverEnabled", "(", "config", "*", "config", ".", "Vserver", ",", "os", "seesaw", ".", "OverrideState", ")", "bool", "{", "switch", "{", "case", "config", "==", "nil", ":", "return", "false", "\n", "case", "os", "==", "seesaw", ".", "OverrideD...
// vserverEnabled returns true if a vserver having the given configuration // and override state should be enabled.
[ "vserverEnabled", "returns", "true", "if", "a", "vserver", "having", "the", "given", "configuration", "and", "override", "state", "should", "be", "enabled", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L775-L785
train
google/seesaw
engine/vserver.go
snapshot
func (v *vserver) snapshot() *seesaw.Vserver { if v.config == nil { return nil } sv := &seesaw.Vserver{ Name: v.config.Name, Entries: make([]*seesaw.VserverEntry, 0, len(v.config.Entries)), Host: seesaw.Host{ Hostname: v.config.Hostname, IPv4Addr: v.config.IPv4Addr, IPv4Mask: v.config.IPv4Mask, ...
go
func (v *vserver) snapshot() *seesaw.Vserver { if v.config == nil { return nil } sv := &seesaw.Vserver{ Name: v.config.Name, Entries: make([]*seesaw.VserverEntry, 0, len(v.config.Entries)), Host: seesaw.Host{ Hostname: v.config.Hostname, IPv4Addr: v.config.IPv4Addr, IPv4Mask: v.config.IPv4Mask, ...
[ "func", "(", "v", "*", "vserver", ")", "snapshot", "(", ")", "*", "seesaw", ".", "Vserver", "{", "if", "v", ".", "config", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "sv", ":=", "&", "seesaw", ".", "Vserver", "{", "Name", ":", "v", "."...
// snapshot exports the current running state of the vserver.
[ "snapshot", "exports", "the", "current", "running", "state", "of", "the", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L788-L819
train
google/seesaw
engine/vserver.go
updateState
func (d *destination) updateState() { // The destination is healthy if the backend is enabled and *all* the checks // for that destination are healthy. healthy := d.backend.Enabled if healthy { for _, c := range d.checks { if c.status.State != healthcheck.StateHealthy { healthy = false break } } ...
go
func (d *destination) updateState() { // The destination is healthy if the backend is enabled and *all* the checks // for that destination are healthy. healthy := d.backend.Enabled if healthy { for _, c := range d.checks { if c.status.State != healthcheck.StateHealthy { healthy = false break } } ...
[ "func", "(", "d", "*", "destination", ")", "updateState", "(", ")", "{", "// The destination is healthy if the backend is enabled and *all* the checks", "// for that destination are healthy.", "healthy", ":=", "d", ".", "backend", ".", "Enabled", "\n", "if", "healthy", "{...
// updateState updates the state of a destination based on the state of checks // and propagates state changes to the service level if necessary.
[ "updateState", "updates", "the", "state", "of", "a", "destination", "based", "on", "the", "state", "of", "checks", "and", "propagates", "state", "changes", "to", "the", "service", "level", "if", "necessary", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L823-L851
train
google/seesaw
engine/vserver.go
up
func (d *destination) up() { d.active = true log.Infof("%v: %v backend %v up", d.service.vserver, d.service, d) ncc := d.service.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", d.service.vserver, err) } defer ncc.Close() if err := ncc.IPVSAddDestination(d.service....
go
func (d *destination) up() { d.active = true log.Infof("%v: %v backend %v up", d.service.vserver, d.service, d) ncc := d.service.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", d.service.vserver, err) } defer ncc.Close() if err := ncc.IPVSAddDestination(d.service....
[ "func", "(", "d", "*", "destination", ")", "up", "(", ")", "{", "d", ".", "active", "=", "true", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "d", ".", "service", ".", "vserver", ",", "d", ".", "service", ",", "d", ")", "\n\n", "ncc", ":=...
// up brings up a destination.
[ "up", "brings", "up", "a", "destination", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L854-L866
train
google/seesaw
engine/vserver.go
down
func (d *destination) down() { d.active = false log.Infof("%v: %v backend %v down", d.service.vserver, d.service, d) ncc := d.service.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", d.service.vserver, err) } defer ncc.Close() if err := ncc.IPVSDeleteDestination(d....
go
func (d *destination) down() { d.active = false log.Infof("%v: %v backend %v down", d.service.vserver, d.service, d) ncc := d.service.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", d.service.vserver, err) } defer ncc.Close() if err := ncc.IPVSDeleteDestination(d....
[ "func", "(", "d", "*", "destination", ")", "down", "(", ")", "{", "d", ".", "active", "=", "false", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "d", ".", "service", ".", "vserver", ",", "d", ".", "service", ",", "d", ")", "\n\n", "ncc", ...
// down takes down a destination.
[ "down", "takes", "down", "a", "destination", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L869-L881
train
google/seesaw
engine/vserver.go
update
func (d *destination) update(dest *destination) { if d.destinationKey != dest.destinationKey { log.Fatalf("%v: can't update destination %v using %v: destinationKey mismatch: %v != %v", d.service.vserver, d, dest, d.destinationKey, dest.destinationKey) } log.Infof("%v: %v updating destination %v", d.service.vser...
go
func (d *destination) update(dest *destination) { if d.destinationKey != dest.destinationKey { log.Fatalf("%v: can't update destination %v using %v: destinationKey mismatch: %v != %v", d.service.vserver, d, dest, d.destinationKey, dest.destinationKey) } log.Infof("%v: %v updating destination %v", d.service.vser...
[ "func", "(", "d", "*", "destination", ")", "update", "(", "dest", "*", "destination", ")", "{", "if", "d", ".", "destinationKey", "!=", "dest", ".", "destinationKey", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",", "d", ".", "service", ".", "vserver...
// update updates a destination while preserving its running state.
[ "update", "updates", "a", "destination", "while", "preserving", "its", "running", "state", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L884-L923
train
google/seesaw
engine/vserver.go
snapshot
func (d *destination) snapshot() *seesaw.Destination { return &seesaw.Destination{ Backend: d.backend, Name: d.name(), VserverName: d.service.vserver.String(), Stats: d.stats, Enabled: d.backend.Enabled, Weight: d.weight, Healthy: d.healthy, Active: d.active, } }
go
func (d *destination) snapshot() *seesaw.Destination { return &seesaw.Destination{ Backend: d.backend, Name: d.name(), VserverName: d.service.vserver.String(), Stats: d.stats, Enabled: d.backend.Enabled, Weight: d.weight, Healthy: d.healthy, Active: d.active, } }
[ "func", "(", "d", "*", "destination", ")", "snapshot", "(", ")", "*", "seesaw", ".", "Destination", "{", "return", "&", "seesaw", ".", "Destination", "{", "Backend", ":", "d", ".", "backend", ",", "Name", ":", "d", ".", "name", "(", ")", ",", "Vser...
// snapshot exports the current running state of a destination.
[ "snapshot", "exports", "the", "current", "running", "state", "of", "a", "destination", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L926-L937
train
google/seesaw
engine/vserver.go
updateState
func (s *service) updateState() { // The service is considered healthy if: // 1) No watermarks are configured, and at least one destination is healthy. // OR // 2) (Num healthy dests) / (Num backends) >= high watermark. // OR // 3) Service is already healthy, and // (Num healthy dests) / (Num backends) >= low...
go
func (s *service) updateState() { // The service is considered healthy if: // 1) No watermarks are configured, and at least one destination is healthy. // OR // 2) (Num healthy dests) / (Num backends) >= high watermark. // OR // 3) Service is already healthy, and // (Num healthy dests) / (Num backends) >= low...
[ "func", "(", "s", "*", "service", ")", "updateState", "(", ")", "{", "// The service is considered healthy if:", "// 1) No watermarks are configured, and at least one destination is healthy.", "// OR", "// 2) (Num healthy dests) / (Num backends) >= high watermark.", "// OR", "// 3) Ser...
// updateState updates the state of a service based on the state of its // destinations and propagates state changes to the vserver level if necessary.
[ "updateState", "updates", "the", "state", "of", "a", "service", "based", "on", "the", "state", "of", "its", "destinations", "and", "propagates", "state", "changes", "to", "the", "vserver", "level", "if", "necessary", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L941-L1005
train
google/seesaw
engine/vserver.go
updateDests
func (s *service) updateDests() { for _, d := range s.dests { if !s.active { d.stats.DestinationStats = &ipvs.DestinationStats{} if d.active { d.down() } continue } switch { case !d.healthy && d.active: d.down() case d.healthy && !d.active: d.up() } } }
go
func (s *service) updateDests() { for _, d := range s.dests { if !s.active { d.stats.DestinationStats = &ipvs.DestinationStats{} if d.active { d.down() } continue } switch { case !d.healthy && d.active: d.down() case d.healthy && !d.active: d.up() } } }
[ "func", "(", "s", "*", "service", ")", "updateDests", "(", ")", "{", "for", "_", ",", "d", ":=", "range", "s", ".", "dests", "{", "if", "!", "s", ".", "active", "{", "d", ".", "stats", ".", "DestinationStats", "=", "&", "ipvs", ".", "DestinationS...
// updateDests brings the destinations for a service up or down based on the // state of the service and the health of each destination.
[ "updateDests", "brings", "the", "destinations", "for", "a", "service", "up", "or", "down", "based", "on", "the", "state", "of", "the", "service", "and", "the", "health", "of", "each", "destination", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1009-L1025
train
google/seesaw
engine/vserver.go
up
func (s *service) up() { s.active = true log.Infof("%v: %v service up", s.vserver, s) ncc := s.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err) } defer ncc.Close() log.Infof("%v: adding IPVS service %v", s.vserver, s.ipvsSvc) if err := ncc.IPVSAdd...
go
func (s *service) up() { s.active = true log.Infof("%v: %v service up", s.vserver, s) ncc := s.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err) } defer ncc.Close() log.Infof("%v: adding IPVS service %v", s.vserver, s.ipvsSvc) if err := ncc.IPVSAdd...
[ "func", "(", "s", "*", "service", ")", "up", "(", ")", "{", "s", ".", "active", "=", "true", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "s", ".", "vserver", ",", "s", ")", "\n\n", "ncc", ":=", "s", ".", "vserver", ".", "ncc", "\n", "i...
// up brings up a service and all healthy destinations.
[ "up", "brings", "up", "a", "service", "and", "all", "healthy", "destinations", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1028-L1045
train
google/seesaw
engine/vserver.go
down
func (s *service) down() { s.active = false s.stats.ServiceStats = &ipvs.ServiceStats{} log.Infof("%v: %v service down", s.vserver, s) ncc := s.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err) } defer ncc.Close() // Remove IPVS destinations *befor...
go
func (s *service) down() { s.active = false s.stats.ServiceStats = &ipvs.ServiceStats{} log.Infof("%v: %v service down", s.vserver, s) ncc := s.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err) } defer ncc.Close() // Remove IPVS destinations *befor...
[ "func", "(", "s", "*", "service", ")", "down", "(", ")", "{", "s", ".", "active", "=", "false", "\n", "s", ".", "stats", ".", "ServiceStats", "=", "&", "ipvs", ".", "ServiceStats", "{", "}", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "s",...
// down takes down all destinations for a service, then takes down the // service.
[ "down", "takes", "down", "all", "destinations", "for", "a", "service", "then", "takes", "down", "the", "service", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1049-L1066
train
google/seesaw
engine/vserver.go
update
func (s *service) update(svc *service) { if s.serviceKey != svc.serviceKey { log.Fatalf("%v: can't update service %v using %v: serviceKey mismatch: %v != %v", s.vserver, s, svc, s.serviceKey, svc.serviceKey) } log.Infof("%v: updating service %v", s.vserver, s) updateIPVS := s.active && !s.ipvsEqual(svc) svc....
go
func (s *service) update(svc *service) { if s.serviceKey != svc.serviceKey { log.Fatalf("%v: can't update service %v using %v: serviceKey mismatch: %v != %v", s.vserver, s, svc, s.serviceKey, svc.serviceKey) } log.Infof("%v: updating service %v", s.vserver, s) updateIPVS := s.active && !s.ipvsEqual(svc) svc....
[ "func", "(", "s", "*", "service", ")", "update", "(", "svc", "*", "service", ")", "{", "if", "s", ".", "serviceKey", "!=", "svc", ".", "serviceKey", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",", "s", ".", "vserver", ",", "s", ",", "svc", ","...
// update updates a service while preserving its running state.
[ "update", "updates", "a", "service", "while", "preserving", "its", "running", "state", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1069-L1097
train
google/seesaw
engine/vserver.go
updateStats
func (s *service) updateStats() { if !s.active { return } log.V(1).Infof("%v: updating IPVS statistics for %v", s.vserver, s) ncc := s.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err) } defer ncc.Close() ipvsSvc, err := ncc.IPVSGetService(s.ipvs...
go
func (s *service) updateStats() { if !s.active { return } log.V(1).Infof("%v: updating IPVS statistics for %v", s.vserver, s) ncc := s.vserver.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err) } defer ncc.Close() ipvsSvc, err := ncc.IPVSGetService(s.ipvs...
[ "func", "(", "s", "*", "service", ")", "updateStats", "(", ")", "{", "if", "!", "s", ".", "active", "{", "return", "\n", "}", "\n", "log", ".", "V", "(", "1", ")", ".", "Infof", "(", "\"", "\"", ",", "s", ".", "vserver", ",", "s", ")", "\n\...
// updateStats updates the IPVS statistics for this service.
[ "updateStats", "updates", "the", "IPVS", "statistics", "for", "this", "service", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1100-L1133
train
google/seesaw
engine/vserver.go
snapshot
func (s *service) snapshot() *seesaw.Service { ss := &seesaw.Service{ ServiceKey: seesaw.ServiceKey{ AF: s.af, Proto: s.proto, Port: s.port, }, Mode: s.ventry.Mode, Scheduler: s.ventry.Scheduler, OnePacket: s.ventry.OnePacket, Persistence: s.ventry.Persistence, IP: ...
go
func (s *service) snapshot() *seesaw.Service { ss := &seesaw.Service{ ServiceKey: seesaw.ServiceKey{ AF: s.af, Proto: s.proto, Port: s.port, }, Mode: s.ventry.Mode, Scheduler: s.ventry.Scheduler, OnePacket: s.ventry.OnePacket, Persistence: s.ventry.Persistence, IP: ...
[ "func", "(", "s", "*", "service", ")", "snapshot", "(", ")", "*", "seesaw", ".", "Service", "{", "ss", ":=", "&", "seesaw", ".", "Service", "{", "ServiceKey", ":", "seesaw", ".", "ServiceKey", "{", "AF", ":", "s", ".", "af", ",", "Proto", ":", "s...
// snapshot exports the current running state of a service.
[ "snapshot", "exports", "the", "current", "running", "state", "of", "a", "service", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1136-L1176
train
google/seesaw
engine/vserver.go
updateState
func (v *vserver) updateState(ip seesaw.IP) { // A vserver anycast IP is healthy if *all* services for that IP are healthy. // A vserver unicast IP is healthy if *any* services for that IP are healthy. var healthy bool for _, s := range v.services { if !s.ip.Equal(ip) { continue } healthy = s.healthy if ...
go
func (v *vserver) updateState(ip seesaw.IP) { // A vserver anycast IP is healthy if *all* services for that IP are healthy. // A vserver unicast IP is healthy if *any* services for that IP are healthy. var healthy bool for _, s := range v.services { if !s.ip.Equal(ip) { continue } healthy = s.healthy if ...
[ "func", "(", "v", "*", "vserver", ")", "updateState", "(", "ip", "seesaw", ".", "IP", ")", "{", "// A vserver anycast IP is healthy if *all* services for that IP are healthy.", "// A vserver unicast IP is healthy if *any* services for that IP are healthy.", "var", "healthy", "boo...
// updateState updates the state of an IP for a vserver based on the state of // that IP's services.
[ "updateState", "updates", "the", "state", "of", "an", "IP", "for", "a", "vserver", "based", "on", "the", "state", "of", "that", "IP", "s", "services", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1180-L1207
train
google/seesaw
engine/vserver.go
updateServices
func (v *vserver) updateServices(ip seesaw.IP) { for _, s := range v.services { if !s.ip.Equal(ip) { continue } if !v.active[ip] { if s.active { s.down() } continue } switch { case !s.healthy && s.active: s.down() case s.healthy && !s.active: s.up() } } }
go
func (v *vserver) updateServices(ip seesaw.IP) { for _, s := range v.services { if !s.ip.Equal(ip) { continue } if !v.active[ip] { if s.active { s.down() } continue } switch { case !s.healthy && s.active: s.down() case s.healthy && !s.active: s.up() } } }
[ "func", "(", "v", "*", "vserver", ")", "updateServices", "(", "ip", "seesaw", ".", "IP", ")", "{", "for", "_", ",", "s", ":=", "range", "v", ".", "services", "{", "if", "!", "s", ".", "ip", ".", "Equal", "(", "ip", ")", "{", "continue", "\n", ...
// updateServices brings the services for a vserver up or down based on the // state of the vserver and the health of each service.
[ "updateServices", "brings", "the", "services", "for", "a", "vserver", "up", "or", "down", "based", "on", "the", "state", "of", "the", "vserver", "and", "the", "health", "of", "each", "service", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1211-L1229
train
google/seesaw
engine/vserver.go
up
func (v *vserver) up(ip seesaw.IP) { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() v.active[ip] = true v.updateServices(ip) // If this is an anycast VIP, start advertising a BGP route. nip := ip.IP() if seesaw.IsAnycast(nip...
go
func (v *vserver) up(ip seesaw.IP) { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() v.active[ip] = true v.updateServices(ip) // If this is an anycast VIP, start advertising a BGP route. nip := ip.IP() if seesaw.IsAnycast(nip...
[ "func", "(", "v", "*", "vserver", ")", "up", "(", "ip", "seesaw", ".", "IP", ")", "{", "ncc", ":=", "v", ".", "engine", ".", "ncc", "\n", "if", "err", ":=", "ncc", ".", "Dial", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Fatalf", "...
// up brings up all healthy services for an IP address for a vserver, then // brings up the IP address.
[ "up", "brings", "up", "all", "healthy", "services", "for", "an", "IP", "address", "for", "a", "vserver", "then", "brings", "up", "the", "IP", "address", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1233-L1274
train
google/seesaw
engine/vserver.go
downAll
func (v *vserver) downAll() { for _, s := range v.services { if v.active[s.ip] { v.down(s.ip) } if s.active { s.down() } } }
go
func (v *vserver) downAll() { for _, s := range v.services { if v.active[s.ip] { v.down(s.ip) } if s.active { s.down() } } }
[ "func", "(", "v", "*", "vserver", ")", "downAll", "(", ")", "{", "for", "_", ",", "s", ":=", "range", "v", ".", "services", "{", "if", "v", ".", "active", "[", "s", ".", "ip", "]", "{", "v", ".", "down", "(", "s", ".", "ip", ")", "\n", "}...
// downAll takes down all IP addresses and services for a vserver.
[ "downAll", "takes", "down", "all", "IP", "addresses", "and", "services", "for", "a", "vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1277-L1286
train
google/seesaw
engine/vserver.go
down
func (v *vserver) down(ip seesaw.IP) { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() // If this is an anycast VIP, withdraw the BGP route. nip := ip.IP() if seesaw.IsAnycast(nip) { if v.engine.config.AnycastEnabled { log....
go
func (v *vserver) down(ip seesaw.IP) { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() // If this is an anycast VIP, withdraw the BGP route. nip := ip.IP() if seesaw.IsAnycast(nip) { if v.engine.config.AnycastEnabled { log....
[ "func", "(", "v", "*", "vserver", ")", "down", "(", "ip", "seesaw", ".", "IP", ")", "{", "ncc", ":=", "v", ".", "engine", ".", "ncc", "\n", "if", "err", ":=", "ncc", ".", "Dial", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Fatalf", ...
// down takes down an IP address for a vserver, then takes down all services // for that IP address.
[ "down", "takes", "down", "an", "IP", "address", "for", "a", "vserver", "then", "takes", "down", "all", "services", "for", "that", "IP", "address", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1290-L1320
train
google/seesaw
engine/vserver.go
configureVIPs
func (v *vserver) configureVIPs() { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() // TODO(ncope): Return to iterating over v.services once they contain seesaw.VIPs. for _, vip := range v.config.VIPs { if _, ok := v.vips[*vip]...
go
func (v *vserver) configureVIPs() { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() // TODO(ncope): Return to iterating over v.services once they contain seesaw.VIPs. for _, vip := range v.config.VIPs { if _, ok := v.vips[*vip]...
[ "func", "(", "v", "*", "vserver", ")", "configureVIPs", "(", ")", "{", "ncc", ":=", "v", ".", "engine", ".", "ncc", "\n", "if", "err", ":=", "ncc", ".", "Dial", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",...
// configureVIPs configures VIPs on the load balancing interface.
[ "configureVIPs", "configures", "VIPs", "on", "the", "load", "balancing", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1330-L1363
train
google/seesaw
engine/vserver.go
unconfigureVIP
func (v *vserver) unconfigureVIP(vip *seesaw.VIP) { configured, ok := v.vips[*vip] if !ok { return } if configured { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() if err := v.engine.lbInterface.DeleteVIP(vip); err !=...
go
func (v *vserver) unconfigureVIP(vip *seesaw.VIP) { configured, ok := v.vips[*vip] if !ok { return } if configured { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() if err := v.engine.lbInterface.DeleteVIP(vip); err !=...
[ "func", "(", "v", "*", "vserver", ")", "unconfigureVIP", "(", "vip", "*", "seesaw", ".", "VIP", ")", "{", "configured", ",", "ok", ":=", "v", ".", "vips", "[", "*", "vip", "]", "\n", "if", "!", "ok", "{", "return", "\n", "}", "\n", "if", "confi...
// unconfigureVIP removes a unicast VIP from the load balancing interface.
[ "unconfigureVIP", "removes", "a", "unicast", "VIP", "from", "the", "load", "balancing", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1366-L1387
train
google/seesaw
engine/vserver.go
unconfigureVIPs
func (v *vserver) unconfigureVIPs() { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() // TODO(jsing): At a later date this will need to support VLAN // interfaces and dedicated VIP subnets. for vip := range v.vips { v.unconfig...
go
func (v *vserver) unconfigureVIPs() { ncc := v.engine.ncc if err := ncc.Dial(); err != nil { log.Fatalf("%v: failed to connect to NCC: %v", v, err) } defer ncc.Close() // TODO(jsing): At a later date this will need to support VLAN // interfaces and dedicated VIP subnets. for vip := range v.vips { v.unconfig...
[ "func", "(", "v", "*", "vserver", ")", "unconfigureVIPs", "(", ")", "{", "ncc", ":=", "v", ".", "engine", ".", "ncc", "\n", "if", "err", ":=", "ncc", ".", "Dial", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "\"", "\"", ...
// unconfigureVIPs removes unicast VIPs from the load balancing interface.
[ "unconfigureVIPs", "removes", "unicast", "VIPs", "from", "the", "load", "balancing", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/vserver.go#L1390-L1402
train
google/seesaw
engine/config/fetcher.go
fetchFromHost
func (f *fetcher) fetchFromHost(ip net.IP, url, contentType string) ([]byte, error) { // TODO(angusc): connection timeout? tcpAddr := &net.TCPAddr{IP: ip, Port: f.port} tcpConn, err := net.DialTCP("tcp", nil, tcpAddr) if err != nil { return nil, err } defer tcpConn.Close() tcpConn.SetDeadline(time.Now().Add(f....
go
func (f *fetcher) fetchFromHost(ip net.IP, url, contentType string) ([]byte, error) { // TODO(angusc): connection timeout? tcpAddr := &net.TCPAddr{IP: ip, Port: f.port} tcpConn, err := net.DialTCP("tcp", nil, tcpAddr) if err != nil { return nil, err } defer tcpConn.Close() tcpConn.SetDeadline(time.Now().Add(f....
[ "func", "(", "f", "*", "fetcher", ")", "fetchFromHost", "(", "ip", "net", ".", "IP", ",", "url", ",", "contentType", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// TODO(angusc): connection timeout?", "tcpAddr", ":=", "&", "net", ".", ...
// fetchFromHost attempts to fetch the specified URL from a specific host.
[ "fetchFromHost", "attempts", "to", "fetch", "the", "specified", "URL", "from", "a", "specific", "host", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/fetcher.go#L86-L130
train
google/seesaw
netlink/netlink.go
uint16FromNetwork
func uint16FromNetwork(u uint16) uint16 { b := *(*[2]byte)(unsafe.Pointer(&u)) return binary.BigEndian.Uint16(b[:]) }
go
func uint16FromNetwork(u uint16) uint16 { b := *(*[2]byte)(unsafe.Pointer(&u)) return binary.BigEndian.Uint16(b[:]) }
[ "func", "uint16FromNetwork", "(", "u", "uint16", ")", "uint16", "{", "b", ":=", "*", "(", "*", "[", "2", "]", "byte", ")", "(", "unsafe", ".", "Pointer", "(", "&", "u", ")", ")", "\n", "return", "binary", ".", "BigEndian", ".", "Uint16", "(", "b"...
// uint16FromNetwork converts the given value from its network byte order.
[ "uint16FromNetwork", "converts", "the", "given", "value", "from", "its", "network", "byte", "order", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L48-L51
train
google/seesaw
netlink/netlink.go
uint16ToNetwork
func uint16ToNetwork(u uint16) uint16 { var b [2]byte binary.BigEndian.PutUint16(b[:], u) return *(*uint16)(unsafe.Pointer(&b)) }
go
func uint16ToNetwork(u uint16) uint16 { var b [2]byte binary.BigEndian.PutUint16(b[:], u) return *(*uint16)(unsafe.Pointer(&b)) }
[ "func", "uint16ToNetwork", "(", "u", "uint16", ")", "uint16", "{", "var", "b", "[", "2", "]", "byte", "\n", "binary", ".", "BigEndian", ".", "PutUint16", "(", "b", "[", ":", "]", ",", "u", ")", "\n", "return", "*", "(", "*", "uint16", ")", "(", ...
// uint16ToNetwork converts the given value to its network byte order.
[ "uint16ToNetwork", "converts", "the", "given", "value", "to", "its", "network", "byte", "order", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L54-L58
train
google/seesaw
netlink/netlink.go
uint32FromNetwork
func uint32FromNetwork(u uint32) uint32 { b := *(*[4]byte)(unsafe.Pointer(&u)) return binary.BigEndian.Uint32(b[:]) }
go
func uint32FromNetwork(u uint32) uint32 { b := *(*[4]byte)(unsafe.Pointer(&u)) return binary.BigEndian.Uint32(b[:]) }
[ "func", "uint32FromNetwork", "(", "u", "uint32", ")", "uint32", "{", "b", ":=", "*", "(", "*", "[", "4", "]", "byte", ")", "(", "unsafe", ".", "Pointer", "(", "&", "u", ")", ")", "\n", "return", "binary", ".", "BigEndian", ".", "Uint32", "(", "b"...
// uint32FromNetwork converts the given value from its network byte order.
[ "uint32FromNetwork", "converts", "the", "given", "value", "from", "its", "network", "byte", "order", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L61-L64
train
google/seesaw
netlink/netlink.go
uint32ToNetwork
func uint32ToNetwork(u uint32) uint32 { var b [4]byte binary.BigEndian.PutUint32(b[:], u) return *(*uint32)(unsafe.Pointer(&b)) }
go
func uint32ToNetwork(u uint32) uint32 { var b [4]byte binary.BigEndian.PutUint32(b[:], u) return *(*uint32)(unsafe.Pointer(&b)) }
[ "func", "uint32ToNetwork", "(", "u", "uint32", ")", "uint32", "{", "var", "b", "[", "4", "]", "byte", "\n", "binary", ".", "BigEndian", ".", "PutUint32", "(", "b", "[", ":", "]", ",", "u", ")", "\n", "return", "*", "(", "*", "uint32", ")", "(", ...
// uint32ToNetwork converts the given value to its network byte order.
[ "uint32ToNetwork", "converts", "the", "given", "value", "to", "its", "network", "byte", "order", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L67-L71
train
google/seesaw
netlink/netlink.go
uint64FromNetwork
func uint64FromNetwork(u uint64) uint64 { b := *(*[8]byte)(unsafe.Pointer(&u)) return binary.BigEndian.Uint64(b[:]) }
go
func uint64FromNetwork(u uint64) uint64 { b := *(*[8]byte)(unsafe.Pointer(&u)) return binary.BigEndian.Uint64(b[:]) }
[ "func", "uint64FromNetwork", "(", "u", "uint64", ")", "uint64", "{", "b", ":=", "*", "(", "*", "[", "8", "]", "byte", ")", "(", "unsafe", ".", "Pointer", "(", "&", "u", ")", ")", "\n", "return", "binary", ".", "BigEndian", ".", "Uint64", "(", "b"...
// uint64FromNetwork converts the given value from its network byte order.
[ "uint64FromNetwork", "converts", "the", "given", "value", "from", "its", "network", "byte", "order", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L74-L77
train
google/seesaw
netlink/netlink.go
uint64ToNetwork
func uint64ToNetwork(u uint64) uint64 { var b [8]byte binary.BigEndian.PutUint64(b[:], u) return *(*uint64)(unsafe.Pointer(&b)) }
go
func uint64ToNetwork(u uint64) uint64 { var b [8]byte binary.BigEndian.PutUint64(b[:], u) return *(*uint64)(unsafe.Pointer(&b)) }
[ "func", "uint64ToNetwork", "(", "u", "uint64", ")", "uint64", "{", "var", "b", "[", "8", "]", "byte", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "b", "[", ":", "]", ",", "u", ")", "\n", "return", "*", "(", "*", "uint64", ")", "(", ...
// uint64ToNetwork converts the given value to its network byte order.
[ "uint64ToNetwork", "converts", "the", "given", "value", "to", "its", "network", "byte", "order", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L80-L84
train
google/seesaw
netlink/netlink.go
structMaxAttrID
func structMaxAttrID(v reflect.Value) (uint16, error) { if v.Kind() != reflect.Struct { return 0, fmt.Errorf("%v is not a struct", v.Type()) } st := v.Type() var maxAttrID uint16 for i := 0; i < st.NumField(); i++ { ft, fv := st.Field(i), v.Field(i) fp, err := parseFieldParams(ft.Tag.Get("netlink")) if er...
go
func structMaxAttrID(v reflect.Value) (uint16, error) { if v.Kind() != reflect.Struct { return 0, fmt.Errorf("%v is not a struct", v.Type()) } st := v.Type() var maxAttrID uint16 for i := 0; i < st.NumField(); i++ { ft, fv := st.Field(i), v.Field(i) fp, err := parseFieldParams(ft.Tag.Get("netlink")) if er...
[ "func", "structMaxAttrID", "(", "v", "reflect", ".", "Value", ")", "(", "uint16", ",", "error", ")", "{", "if", "v", ".", "Kind", "(", ")", "!=", "reflect", ".", "Struct", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "v", ...
// structMaxAttrID returns the maximum attribute ID found on netlink tagged // fields within the given struct and any untagged structs it contains.
[ "structMaxAttrID", "returns", "the", "maximum", "attribute", "ID", "found", "on", "netlink", "tagged", "fields", "within", "the", "given", "struct", "and", "any", "untagged", "structs", "it", "contains", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L130-L157
train
google/seesaw
netlink/netlink.go
Error
func (e *Error) Error() string { nle := C.GoString(C.nl_geterror(e.errno)) return fmt.Sprintf("%s: %s", e.msg, strings.ToLower(nle)) }
go
func (e *Error) Error() string { nle := C.GoString(C.nl_geterror(e.errno)) return fmt.Sprintf("%s: %s", e.msg, strings.ToLower(nle)) }
[ "func", "(", "e", "*", "Error", ")", "Error", "(", ")", "string", "{", "nle", ":=", "C", ".", "GoString", "(", "C", ".", "nl_geterror", "(", "e", ".", "errno", ")", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "...
// Error returns the string representation of a netlink error.
[ "Error", "returns", "the", "string", "representation", "of", "a", "netlink", "error", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L539-L542
train
google/seesaw
netlink/netlink.go
Family
func Family(name string) (int, error) { s, err := newSocket() if err != nil { return -1, err } defer s.free() if errno := C.genl_connect(s.nls); errno != 0 { return -1, &Error{errno, "failed to connect to netlink"} } defer C.nl_close((*C.struct_nl_sock)(s.nls)) cn := C.CString(name) defer C.free(unsafe.P...
go
func Family(name string) (int, error) { s, err := newSocket() if err != nil { return -1, err } defer s.free() if errno := C.genl_connect(s.nls); errno != 0 { return -1, &Error{errno, "failed to connect to netlink"} } defer C.nl_close((*C.struct_nl_sock)(s.nls)) cn := C.CString(name) defer C.free(unsafe.P...
[ "func", "Family", "(", "name", "string", ")", "(", "int", ",", "error", ")", "{", "s", ",", "err", ":=", "newSocket", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n", "}", "\n", "defer", "s", ".", "free", "...
// Family returns the family identifier for the specified family name.
[ "Family", "returns", "the", "family", "identifier", "for", "the", "specified", "family", "name", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/netlink/netlink.go#L545-L564
train
google/seesaw
ncc/ip.go
validateInterface
func validateInterface(iface *net.Interface) error { if !ifaceNameRegexp.MatchString(iface.Name) { return fmt.Errorf("Invalid interface name %q", iface.Name) } return nil }
go
func validateInterface(iface *net.Interface) error { if !ifaceNameRegexp.MatchString(iface.Name) { return fmt.Errorf("Invalid interface name %q", iface.Name) } return nil }
[ "func", "validateInterface", "(", "iface", "*", "net", ".", "Interface", ")", "error", "{", "if", "!", "ifaceNameRegexp", ".", "MatchString", "(", "iface", ".", "Name", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "iface", ".", "Name...
// validateInterface validates the name of a network interface.
[ "validateInterface", "validates", "the", "name", "of", "a", "network", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L45-L50
train
google/seesaw
ncc/ip.go
ifaceDown
func ifaceDown(pIface *net.Interface) error { out, err := ipRunOutput("link show dev %s", pIface.Name) if !strings.Contains(out, "state UP") { return nil } // Unlike IPv4, the kernel removes IPv6 addresses when the link goes down. We // don't want that behavior, so we have to preserve the addresses manually. /...
go
func ifaceDown(pIface *net.Interface) error { out, err := ipRunOutput("link show dev %s", pIface.Name) if !strings.Contains(out, "state UP") { return nil } // Unlike IPv4, the kernel removes IPv6 addresses when the link goes down. We // don't want that behavior, so we have to preserve the addresses manually. /...
[ "func", "ifaceDown", "(", "pIface", "*", "net", ".", "Interface", ")", "error", "{", "out", ",", "err", ":=", "ipRunOutput", "(", "\"", "\"", ",", "pIface", ".", "Name", ")", "\n", "if", "!", "strings", ".", "Contains", "(", "out", ",", "\"", "\"",...
// ifaceDown sets the interface link state to down and preserves IPv6 addresses // for both the given interface and any associated VLAN interfaces.
[ "ifaceDown", "sets", "the", "interface", "link", "state", "to", "down", "and", "preserves", "IPv6", "addresses", "for", "both", "the", "given", "interface", "and", "any", "associated", "VLAN", "interfaces", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L106-L139
train
google/seesaw
ncc/ip.go
ifaceSetMAC
func ifaceSetMAC(iface *net.Interface) error { return ipRunIface(iface, "link set %s address %s", iface.Name, iface.HardwareAddr) }
go
func ifaceSetMAC(iface *net.Interface) error { return ipRunIface(iface, "link set %s address %s", iface.Name, iface.HardwareAddr) }
[ "func", "ifaceSetMAC", "(", "iface", "*", "net", ".", "Interface", ")", "error", "{", "return", "ipRunIface", "(", "iface", ",", "\"", "\"", ",", "iface", ".", "Name", ",", "iface", ".", "HardwareAddr", ")", "\n", "}" ]
// ifaceSetMAC sets the interface MAC address.
[ "ifaceSetMAC", "sets", "the", "interface", "MAC", "address", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L153-L155
train
google/seesaw
ncc/ip.go
ifaceAddIPAddr
func ifaceAddIPAddr(iface *net.Interface, ip net.IP, mask net.IPMask) error { if ip.To4() != nil { return ifaceAddIPv4Addr(iface, ip, mask) } return ifaceAddIPv6Addr(iface, ip, mask) }
go
func ifaceAddIPAddr(iface *net.Interface, ip net.IP, mask net.IPMask) error { if ip.To4() != nil { return ifaceAddIPv4Addr(iface, ip, mask) } return ifaceAddIPv6Addr(iface, ip, mask) }
[ "func", "ifaceAddIPAddr", "(", "iface", "*", "net", ".", "Interface", ",", "ip", "net", ".", "IP", ",", "mask", "net", ".", "IPMask", ")", "error", "{", "if", "ip", ".", "To4", "(", ")", "!=", "nil", "{", "return", "ifaceAddIPv4Addr", "(", "iface", ...
// ifaceAddIPAddr adds the given IP address to the network interface.
[ "ifaceAddIPAddr", "adds", "the", "given", "IP", "address", "to", "the", "network", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L158-L163
train
google/seesaw
ncc/ip.go
ifaceAddIPv4Addr
func ifaceAddIPv4Addr(iface *net.Interface, ip net.IP, mask net.IPMask) error { if ip.To4() == nil { return fmt.Errorf("IP %v is not a valid IPv4 address", ip) } brd := make(net.IP, net.IPv4len) copy(brd, ip.To4()) for i := 0; i < net.IPv4len; i++ { brd[i] |= ^mask[i] } prefixLen, _ := mask.Size() return ip...
go
func ifaceAddIPv4Addr(iface *net.Interface, ip net.IP, mask net.IPMask) error { if ip.To4() == nil { return fmt.Errorf("IP %v is not a valid IPv4 address", ip) } brd := make(net.IP, net.IPv4len) copy(brd, ip.To4()) for i := 0; i < net.IPv4len; i++ { brd[i] |= ^mask[i] } prefixLen, _ := mask.Size() return ip...
[ "func", "ifaceAddIPv4Addr", "(", "iface", "*", "net", ".", "Interface", ",", "ip", "net", ".", "IP", ",", "mask", "net", ".", "IPMask", ")", "error", "{", "if", "ip", ".", "To4", "(", ")", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\...
// ifaceAddIPv4Addr adds the given IPv4 address to the network interface.
[ "ifaceAddIPv4Addr", "adds", "the", "given", "IPv4", "address", "to", "the", "network", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L166-L177
train
google/seesaw
ncc/ip.go
ifaceAddIPv6Addr
func ifaceAddIPv6Addr(iface *net.Interface, ip net.IP, mask net.IPMask) error { prefixLen, _ := mask.Size() return ipRunIface(iface, "addr add %s/%d dev %s", ip, prefixLen, iface.Name) }
go
func ifaceAddIPv6Addr(iface *net.Interface, ip net.IP, mask net.IPMask) error { prefixLen, _ := mask.Size() return ipRunIface(iface, "addr add %s/%d dev %s", ip, prefixLen, iface.Name) }
[ "func", "ifaceAddIPv6Addr", "(", "iface", "*", "net", ".", "Interface", ",", "ip", "net", ".", "IP", ",", "mask", "net", ".", "IPMask", ")", "error", "{", "prefixLen", ",", "_", ":=", "mask", ".", "Size", "(", ")", "\n", "return", "ipRunIface", "(", ...
// ifaceAddIPv6Addr adds the given IPv6 address to the network interface.
[ "ifaceAddIPv6Addr", "adds", "the", "given", "IPv6", "address", "to", "the", "network", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L180-L183
train
google/seesaw
ncc/ip.go
ifaceAddVLAN
func ifaceAddVLAN(iface *net.Interface, vlan *seesaw.VLAN) error { name := fmt.Sprintf("%s.%d", iface.Name, vlan.ID) err := ipRunIface(iface, "link add link %s name %s type vlan id %d", iface.Name, name, vlan.ID) if err != nil { return fmt.Errorf("Failed to create VLAN interface %q: %v", name, err) } vlanIface,...
go
func ifaceAddVLAN(iface *net.Interface, vlan *seesaw.VLAN) error { name := fmt.Sprintf("%s.%d", iface.Name, vlan.ID) err := ipRunIface(iface, "link add link %s name %s type vlan id %d", iface.Name, name, vlan.ID) if err != nil { return fmt.Errorf("Failed to create VLAN interface %q: %v", name, err) } vlanIface,...
[ "func", "ifaceAddVLAN", "(", "iface", "*", "net", ".", "Interface", ",", "vlan", "*", "seesaw", ".", "VLAN", ")", "error", "{", "name", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "iface", ".", "Name", ",", "vlan", ".", "ID", ")", "\n", "e...
// ifaceAddVLAN creates a new VLAN interface on the given physical interface.
[ "ifaceAddVLAN", "creates", "a", "new", "VLAN", "interface", "on", "the", "given", "physical", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L197-L228
train
google/seesaw
ncc/ip.go
ifaceDelVLAN
func ifaceDelVLAN(iface *net.Interface, vlan *seesaw.VLAN) error { name := fmt.Sprintf("%s.%d", iface.Name, vlan.ID) vlanIface, err := net.InterfaceByName(name) if err != nil { return fmt.Errorf("Failed to find VLAN interface %q: %v", name, err) } return ipRunIface(vlanIface, "link del dev %s", vlanIface.Name) }
go
func ifaceDelVLAN(iface *net.Interface, vlan *seesaw.VLAN) error { name := fmt.Sprintf("%s.%d", iface.Name, vlan.ID) vlanIface, err := net.InterfaceByName(name) if err != nil { return fmt.Errorf("Failed to find VLAN interface %q: %v", name, err) } return ipRunIface(vlanIface, "link del dev %s", vlanIface.Name) }
[ "func", "ifaceDelVLAN", "(", "iface", "*", "net", ".", "Interface", ",", "vlan", "*", "seesaw", ".", "VLAN", ")", "error", "{", "name", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "iface", ".", "Name", ",", "vlan", ".", "ID", ")", "\n", "v...
// ifaceDelVLAN removes a VLAN interface from the given physical interface.
[ "ifaceDelVLAN", "removes", "a", "VLAN", "interface", "from", "the", "given", "physical", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L231-L238
train
google/seesaw
ncc/ip.go
ifaceFlushVLANs
func ifaceFlushVLANs(iface *net.Interface) error { if err := validateInterface(iface); err != nil { return err } vlanIfaces, err := vlanInterfaces(iface) if err != nil { return err } for _, vlanIface := range vlanIfaces { if err := ipRunIface(vlanIface, "link del dev %s", vlanIface.Name); err != nil { re...
go
func ifaceFlushVLANs(iface *net.Interface) error { if err := validateInterface(iface); err != nil { return err } vlanIfaces, err := vlanInterfaces(iface) if err != nil { return err } for _, vlanIface := range vlanIfaces { if err := ipRunIface(vlanIface, "link del dev %s", vlanIface.Name); err != nil { re...
[ "func", "ifaceFlushVLANs", "(", "iface", "*", "net", ".", "Interface", ")", "error", "{", "if", "err", ":=", "validateInterface", "(", "iface", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "vlanIfaces", ",", "err", ":=", "vlanIn...
// ifaceFlushVLANs removes all VLAN interfaces from the given physical // interface.
[ "ifaceFlushVLANs", "removes", "all", "VLAN", "interfaces", "from", "the", "given", "physical", "interface", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L242-L256
train
google/seesaw
ncc/ip.go
routeDefaultIPv4
func routeDefaultIPv4() (net.IP, error) { out, err := ipRunAFOutput(seesaw.IPv4, "route show default") if err != nil { return nil, err } if dr := routeDefaultIPv4Regexp.FindStringSubmatch(out); dr != nil { return net.ParseIP(dr[1]).To4(), nil } return nil, fmt.Errorf("Default route not found") }
go
func routeDefaultIPv4() (net.IP, error) { out, err := ipRunAFOutput(seesaw.IPv4, "route show default") if err != nil { return nil, err } if dr := routeDefaultIPv4Regexp.FindStringSubmatch(out); dr != nil { return net.ParseIP(dr[1]).To4(), nil } return nil, fmt.Errorf("Default route not found") }
[ "func", "routeDefaultIPv4", "(", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "out", ",", "err", ":=", "ipRunAFOutput", "(", "seesaw", ".", "IPv4", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n...
// routeDefaultIPv4 returns the default route for IPv4 traffic.
[ "routeDefaultIPv4", "returns", "the", "default", "route", "for", "IPv4", "traffic", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L259-L268
train
google/seesaw
ncc/ip.go
removeRoutes
func removeRoutes(table string, vip net.IP) error { af := seesaw.IPv6 if vip.To4() != nil { af = seesaw.IPv4 } return ipRunAF(af, "route flush table %s %s", table, vip) }
go
func removeRoutes(table string, vip net.IP) error { af := seesaw.IPv6 if vip.To4() != nil { af = seesaw.IPv4 } return ipRunAF(af, "route flush table %s %s", table, vip) }
[ "func", "removeRoutes", "(", "table", "string", ",", "vip", "net", ".", "IP", ")", "error", "{", "af", ":=", "seesaw", ".", "IPv6", "\n", "if", "vip", ".", "To4", "(", ")", "!=", "nil", "{", "af", "=", "seesaw", ".", "IPv4", "\n", "}", "\n", "r...
// removeRoutes deletes the routing table entries for a VIP, from the specified // table.
[ "removeRoutes", "deletes", "the", "routing", "table", "entries", "for", "a", "VIP", "from", "the", "specified", "table", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L272-L278
train
google/seesaw
ncc/ip.go
routeLocal
func routeLocal(iface *net.Interface, vip net.IP, node seesaw.Host) error { af := seesaw.IPv6 src := node.IPv6Addr if vip.To4() != nil { af = seesaw.IPv4 src = node.IPv4Addr } if err := removeLocalRoutes(vip); err != nil { return err } return ipRunAF(af, "route add table local local %s dev %s src %s", vip,...
go
func routeLocal(iface *net.Interface, vip net.IP, node seesaw.Host) error { af := seesaw.IPv6 src := node.IPv6Addr if vip.To4() != nil { af = seesaw.IPv4 src = node.IPv4Addr } if err := removeLocalRoutes(vip); err != nil { return err } return ipRunAF(af, "route add table local local %s dev %s src %s", vip,...
[ "func", "routeLocal", "(", "iface", "*", "net", ".", "Interface", ",", "vip", "net", ".", "IP", ",", "node", "seesaw", ".", "Host", ")", "error", "{", "af", ":=", "seesaw", ".", "IPv6", "\n", "src", ":=", "node", ".", "IPv6Addr", "\n", "if", "vip",...
// routeLocal removes all routes in the local routing table for the given VIP // and adds new routes with the correct source address.
[ "routeLocal", "removes", "all", "routes", "in", "the", "local", "routing", "table", "for", "the", "given", "VIP", "and", "adds", "new", "routes", "with", "the", "correct", "source", "address", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L292-L303
train
google/seesaw
ncc/ip.go
RouteDefaultIPv4
func (ncc *SeesawNCC) RouteDefaultIPv4(unused int, gateway *net.IP) error { ip, err := routeDefaultIPv4() if err != nil { return err } if gateway != nil { *gateway = make(net.IP, len(ip)) copy(*gateway, ip) } return nil }
go
func (ncc *SeesawNCC) RouteDefaultIPv4(unused int, gateway *net.IP) error { ip, err := routeDefaultIPv4() if err != nil { return err } if gateway != nil { *gateway = make(net.IP, len(ip)) copy(*gateway, ip) } return nil }
[ "func", "(", "ncc", "*", "SeesawNCC", ")", "RouteDefaultIPv4", "(", "unused", "int", ",", "gateway", "*", "net", ".", "IP", ")", "error", "{", "ip", ",", "err", ":=", "routeDefaultIPv4", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err",...
// RouteDefaultIPv4 returns the default route for IPv4 traffic.
[ "RouteDefaultIPv4", "returns", "the", "default", "route", "for", "IPv4", "traffic", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ip.go#L306-L316
train
google/seesaw
ncc/lb.go
addClusterVIP
func addClusterVIP(iface *ncctypes.LBInterface, netIface, nodeIface *net.Interface, clusterVIP net.IP) error { nodeIP := iface.Node.IPv4Addr family := seesaw.IPv4 if clusterVIP.To4() == nil { nodeIP = iface.Node.IPv6Addr family = seesaw.IPv6 } if nodeIP == nil { return fmt.Errorf("Node does not have an %s ad...
go
func addClusterVIP(iface *ncctypes.LBInterface, netIface, nodeIface *net.Interface, clusterVIP net.IP) error { nodeIP := iface.Node.IPv4Addr family := seesaw.IPv4 if clusterVIP.To4() == nil { nodeIP = iface.Node.IPv6Addr family = seesaw.IPv6 } if nodeIP == nil { return fmt.Errorf("Node does not have an %s ad...
[ "func", "addClusterVIP", "(", "iface", "*", "ncctypes", ".", "LBInterface", ",", "netIface", ",", "nodeIface", "*", "net", ".", "Interface", ",", "clusterVIP", "net", ".", "IP", ")", "error", "{", "nodeIP", ":=", "iface", ".", "Node", ".", "IPv4Addr", "\...
// addClusterVIP adds a cluster VIP to the load balancing interface and // performs additional network configuration.
[ "addClusterVIP", "adds", "a", "cluster", "VIP", "to", "the", "load", "balancing", "interface", "and", "performs", "additional", "network", "configuration", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/lb.go#L120-L171
train
google/seesaw
ncc/lb.go
LBInterfaceDown
func (ncc *SeesawNCC) LBInterfaceDown(iface *ncctypes.LBInterface, out *int) error { netIface, err := iface.Interface() if err != nil { return err } log.Infof("Bringing down LB interface %s", netIface.Name) return ifaceDown(netIface) }
go
func (ncc *SeesawNCC) LBInterfaceDown(iface *ncctypes.LBInterface, out *int) error { netIface, err := iface.Interface() if err != nil { return err } log.Infof("Bringing down LB interface %s", netIface.Name) return ifaceDown(netIface) }
[ "func", "(", "ncc", "*", "SeesawNCC", ")", "LBInterfaceDown", "(", "iface", "*", "ncctypes", ".", "LBInterface", ",", "out", "*", "int", ")", "error", "{", "netIface", ",", "err", ":=", "iface", ".", "Interface", "(", ")", "\n", "if", "err", "!=", "n...
// LBInterfaceDown brings the load balancing interface down.
[ "LBInterfaceDown", "brings", "the", "load", "balancing", "interface", "down", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/lb.go#L174-L181
train