@@ -23,27 +23,14 @@ func (b *BinlogSyncer) StartBackupToFile(backupDir string, p Position, timeout t
23
23
})
24
24
}
25
25
26
- // StartBackup initiates a backup process for binlog events starting from a specified position.
27
- // It continuously fetches binlog events and writes them to files managed by a provided handler function.
28
- // The backup process can be controlled with a timeout duration, after which the backup will stop if no new events are received.
26
+ // StartBackup starts the backup process for the binary log using the specified position and handler.
27
+ // The process will continue until the timeout is reached or an error occurs.
29
28
//
30
29
// Parameters:
31
- // - p Position : The starting position in the binlog from which to begin the backup.
32
- // - timeout time.Duration : The maximum duration to wait for new binlog events before stopping the backup process.
30
+ // - p: The starting position in the binlog from which to begin the backup.
31
+ // - timeout: The maximum duration to wait for new binlog events before stopping the backup process.
33
32
// If set to 0, a default very long timeout (30 days) is used instead.
34
- // - handler func(filename string) (io.WriteCloser, error): A function provided by the caller to handle file creation and writing.
35
- // This function is expected to return an io.WriteCloser for the specified filename, which will be used to write binlog events.
36
- //
37
- // The function first checks if a timeout is specified, setting a default if not. It then enables raw mode parsing for binlog events
38
- // to ensure that events are not parsed but passed as raw data for backup. It starts syncing binlog events from the specified position
39
- // and enters a loop to continuously fetch and write events.
40
- //
41
- // For each event, it checks the event type. If it's a ROTATE_EVENT, it updates the filename to the next log file as indicated by the event.
42
- // If it's a FORMAT_DESCRIPTION_EVENT, it signifies the start of a new binlog file, and the function closes the current file (if open) and opens
43
- // a new one using the handler function. It also writes the binlog file header to the new file.
44
- //
45
- // The function writes the raw data of each event to the current file and handles errors such as context deadline exceeded (timeout),
46
- // write errors, or short writes.
33
+ // - handler: A function that takes a binlog filename and returns an WriteCloser for writing raw events to.
47
34
func (b * BinlogSyncer ) StartBackup (p Position , timeout time.Duration ,
48
35
handler func (binlogFilename string ) (io.WriteCloser , error )) (retErr error ) {
49
36
if timeout == 0 {
0 commit comments