Skip to content

Commit

Permalink
feat: configurable sync worker job timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
batrov committed Jan 5, 2024
1 parent 4cbcaf2 commit b194794
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions compass.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ worker:
username: compass
password: compass_password
job_manager_port: 8085
sync_job_timeout: 15m

client:
host: localhost:8081
Expand Down
2 changes: 1 addition & 1 deletion internal/workermanager/discovery_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (m *Manager) syncAssetHandler() worker.JobHandler {
Handle: m.SyncAssets,
JobOpts: worker.JobOptions{
MaxAttempts: 1,
Timeout: 5 * time.Minute,
Timeout: m.syncTimeout,
BackoffStrategy: worker.DefaultExponentialBackoff,
},
}
Expand Down
3 changes: 3 additions & 0 deletions internal/workermanager/worker_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Manager struct {
discoveryRepo DiscoveryRepository
assetRepo asset.Repository
logger log.Logger
syncTimeout time.Duration
}

//go:generate mockery --name=Worker -r --case underscore --with-expecter --structname Worker --filename worker_mock.go --output=./mocks
Expand All @@ -44,6 +45,7 @@ type Config struct {
ActivePollPercent float64 `mapstructure:"active_poll_percent" default:"20"`
PGQ pgq.Config `mapstructure:"pgq"`
JobManagerPort int `mapstructure:"job_manager_port"`
SyncJobTimeout time.Duration `mapstructure:"sync_job_timeout" default:"15m"`
}

type Deps struct {
Expand Down Expand Up @@ -77,6 +79,7 @@ func New(ctx context.Context, deps Deps) (*Manager, error) {
discoveryRepo: deps.DiscoveryRepo,
assetRepo: deps.AssetRepo,
logger: deps.Logger,
syncTimeout: cfg.SyncJobTimeout,
}, nil
}

Expand Down

0 comments on commit b194794

Please sign in to comment.