MCPcopy
hub / github.com/google/seesaw / runOnce

Method runOnce

engine/sync.go:420–447  ·  view source on GitHub ↗

runOnce establishes a connection to the synchronisation server, registers for notifications, polls for notifications, then deregisters.

()

Source from the content-addressed store, hash-verified

418// runOnce establishes a connection to the synchronisation server, registers
419// for notifications, polls for notifications, then deregisters.
420func (sc *syncClient) runOnce() {
421 if err := sc.dial(); err != nil {
422 log.Warningf("Sync client dial failed: %v", err)
423 return
424 }
425 defer sc.close()
426
427 var sid SyncSessionID
428 self := sc.engine.config.Node.IPv4Addr
429
430 // Register for synchronisation events.
431 // TODO(jsing): Implement timeout on RPC?
432 if err := sc.client.Call("SeesawSync.Register", self, &sid); err != nil {
433 log.Warningf("Sync registration failed: %v", err)
434 return
435 }
436 log.Infof("Registered for synchronisation notifications (ID %d)", sid)
437
438 // TODO(jsing): Export synchronisation data to ECU/CLI.
439
440 sc.poll(sid)
441
442 // Attempt to deregister for notifications.
443 // TODO(jsing): Implement timeout on RPC?
444 if err := sc.client.Call("SeesawSync.Deregister", sid, nil); err != nil {
445 log.Warningf("Sync deregistration failed: %v", err)
446 }
447}
448
449// poll polls the synchronisation server for notifications, then dispatches
450// them for processing.

Callers 3

runMethod · 0.95
TestBasicSyncFunction · 0.45
TestSyncDesyncFunction · 0.45

Calls 3

dialMethod · 0.95
closeMethod · 0.95
pollMethod · 0.95

Tested by 2

TestBasicSyncFunction · 0.36
TestSyncDesyncFunction · 0.36