MCPcopy
hub / github.com/perkeep/perkeep / NewSyncHandler

Function NewSyncHandler

pkg/server/sync.go:261–268  ·  view source on GitHub ↗

NewSyncHandler returns a handler that will asynchronously and continuously copy blobs from src to dest, if missing on dest. Blobs waiting to be copied are stored on pendingQueue. srcName and destName are only used for status and debugging messages. N.B: blobs should be added to src with a method tha

(srcName, destName string,
	src blobserver.Storage, dest blobReceiverEnumerator,
	pendingQueue sorted.KeyValue)

Source from the content-addressed store, hash-verified

259// N.B: blobs should be added to src with a method that notifies the blob hub,
260// such as blobserver.Receive.
261func NewSyncHandler(srcName, destName string,
262 src blobserver.Storage, dest blobReceiverEnumerator,
263 pendingQueue sorted.KeyValue) *SyncHandler {
264 sh := newSyncHandler(srcName, destName, src, dest, pendingQueue)
265 go sh.syncLoop()
266 blobserver.GetHub(sh.from).AddReceiveHook(sh.enqueue)
267 return sh
268}
269
270// IdleWait waits until the sync handler has finished processing the currently
271// queued blobs.

Callers 2

newHostFunction · 0.92
populateFunction · 0.92

Calls 4

GetHubFunction · 0.92
newSyncHandlerFunction · 0.85
syncLoopMethod · 0.80
AddReceiveHookMethod · 0.65

Tested by 2

newHostFunction · 0.74
populateFunction · 0.74