Skip to content

Commit 242fb55

Browse files
authored
feat: Add opts.SchedulerOpts() helper to convert plugin.SyncOptions for scheduler (#1900)
Co-authored-by: Kemal Hadimli <[email protected]>
1 parent ff7a485 commit 242fb55

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

helpers/opts/syncoptions.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package opts
2+
3+
import (
4+
"github.com/cloudquery/plugin-sdk/v4/plugin"
5+
"github.com/cloudquery/plugin-sdk/v4/scheduler"
6+
)
7+
8+
// SchedulerOpts converts plugin.SyncOptions to []scheduler.SyncOption, adding additionalOpts.
9+
func SchedulerOpts(o plugin.SyncOptions, additionalOpts ...scheduler.SyncOption) []scheduler.SyncOption {
10+
opts := []scheduler.SyncOption{
11+
scheduler.WithSyncDeterministicCQID(o.DeterministicCQID),
12+
}
13+
if o.Shard != nil {
14+
opts = append(opts, scheduler.WithShard(o.Shard.Num, o.Shard.Total))
15+
}
16+
return append(opts, additionalOpts...)
17+
}

0 commit comments

Comments
 (0)