Skip to content

Commit

Permalink
feat: Add opts.SchedulerOpts() helper to convert `plugin.SyncOption…
Browse files Browse the repository at this point in the history
…s` for scheduler (#1900)

Co-authored-by: Kemal Hadimli <disq@users.noreply.github.com>
  • Loading branch information
disq and disq authored Sep 19, 2024
1 parent ff7a485 commit 242fb55
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions helpers/opts/syncoptions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package opts

import (
"github.com/cloudquery/plugin-sdk/v4/plugin"
"github.com/cloudquery/plugin-sdk/v4/scheduler"
)

// SchedulerOpts converts plugin.SyncOptions to []scheduler.SyncOption, adding additionalOpts.
func SchedulerOpts(o plugin.SyncOptions, additionalOpts ...scheduler.SyncOption) []scheduler.SyncOption {
opts := []scheduler.SyncOption{
scheduler.WithSyncDeterministicCQID(o.DeterministicCQID),
}
if o.Shard != nil {
opts = append(opts, scheduler.WithShard(o.Shard.Num, o.Shard.Total))
}
return append(opts, additionalOpts...)
}

0 comments on commit 242fb55

Please sign in to comment.