MCPcopy Create free account
hub / github.com/Shopify/ghostferry / Serialize

Method Serialize

state_tracker.go:308–341  ·  view source on GitHub ↗
(lastKnownTableSchemaCache TableSchemaCache, binlogVerifyStore *BinlogVerifyStore)

Source from the content-addressed store, hash-verified

306}
307
308func (s *StateTracker) Serialize(lastKnownTableSchemaCache TableSchemaCache, binlogVerifyStore *BinlogVerifyStore) *SerializableState {
309 s.BinlogRWMutex.RLock()
310 defer s.BinlogRWMutex.RUnlock()
311
312 s.CopyRWMutex.RLock()
313 defer s.CopyRWMutex.RUnlock()
314
315 state := &SerializableState{
316 GhostferryVersion: VersionString,
317 LastKnownTableSchemaCache: lastKnownTableSchemaCache,
318 LastSuccessfulPaginationKeys: make(map[string]PaginationKey),
319 CompletedTables: make(map[string]bool),
320 LastWrittenBinlogPosition: s.lastWrittenBinlogPosition,
321 LastStoredBinlogPositionForInlineVerifier: s.lastStoredBinlogPositionForInlineVerifier,
322 LastStoredBinlogPositionForTargetVerifier: s.lastStoredBinlogPositionForTargetVerifier,
323 }
324
325 if binlogVerifyStore != nil {
326 state.BinlogVerifyStore = binlogVerifyStore.Serialize()
327 }
328
329 // Need a copy because lastSuccessfulPaginationKeys may change after Serialize
330 // returns. This would inaccurately reflect the state of Ghostferry when
331 // Serialize is called.
332 for k, v := range s.lastSuccessfulPaginationKeys {
333 state.LastSuccessfulPaginationKeys[k] = v
334 }
335
336 for k, v := range s.completedTables {
337 state.CompletedTables[k] = v
338 }
339
340 return state
341}

Callers 3

SerializeStateToJSONMethod · 0.45
ProgressMethod · 0.45
completedTablesMethod · 0.45

Calls

no outgoing calls

Tested by 1

completedTablesMethod · 0.36