-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use options pattern to configure backfill (#630)
Use the options pattern to configure backfill. Backfill will take some new options as part of #583, so refactor the `backfill` package to use the options pattern, given that `Start` already takes many arguments. Part of #583
- Loading branch information
1 parent
c237001
commit c4cd645
Showing
3 changed files
with
64 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package backfill | ||
|
||
import "time" | ||
|
||
type OptionFn func(*Backfill) | ||
|
||
// WithBatchSize sets the batch size for the backfill operation. | ||
func WithBatchSize(batchSize int) OptionFn { | ||
return func(o *Backfill) { | ||
o.batchSize = batchSize | ||
} | ||
} | ||
|
||
// WithBatchDelay sets the delay between batches for the backfill operation. | ||
func WithBatchDelay(delay time.Duration) OptionFn { | ||
return func(o *Backfill) { | ||
o.batchDelay = delay | ||
} | ||
} | ||
|
||
// WithCallbacks sets the callbacks for the backfill operation. | ||
// Callbacks are invoked after each batch is processed. | ||
func WithCallbacks(cbs ...CallbackFn) OptionFn { | ||
return func(o *Backfill) { | ||
o.callbacks = cbs | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters