Skip to content

Commit bc1dd07

Browse files
author
Dylan Terry
committed
Make sure to add NewBackupHandler in order to expose the otherwise private handler outside the package
1 parent 06c9268 commit bc1dd07

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

replication/backup.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ type BackupEventHandler struct {
131131
filename string
132132
}
133133

134+
func NewBackupEventHandler(handlerFunction func(filename string) (io.WriteCloser, error)) *BackupEventHandler {
135+
return &BackupEventHandler{
136+
handler: handlerFunction,
137+
}
138+
}
139+
134140
// HandleEvent processes a single event for the backup.
135141
func (h *BackupEventHandler) HandleEvent(e *BinlogEvent) error {
136142
h.mutex.Lock()

replication/backup_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ func testBackup(t *testSyncerSuite, isSynchronous bool) {
7272

7373
if isSynchronous {
7474
// Set up a BackupEventHandler for synchronous mode
75-
backupHandler := &BackupEventHandler{
76-
handler: func(filename string) (io.WriteCloser, error) {
75+
backupHandler := NewBackupEventHandler(
76+
func(filename string) (io.WriteCloser, error) {
7777
return os.OpenFile(path.Join(binlogDir, filename), os.O_CREATE|os.O_WRONLY, 0644)
7878
},
79-
}
79+
)
8080
t.b.cfg.SynchronousEventHandler = backupHandler
8181
} else {
8282
// Ensure SynchronousEventHandler is nil for asynchronous mode

0 commit comments

Comments
 (0)