mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 23:26:38 +08:00
refactor(drivers): decouple inproc cron from inproc worker and satisfy linter
This commit is contained in:
@@ -16,6 +16,8 @@ import (
|
||||
"Wavelet/pkg/util"
|
||||
)
|
||||
|
||||
const defaultRetryBackoff = 500 * time.Millisecond
|
||||
|
||||
// TaskMessage represents an in-process task item in the queue.
|
||||
type TaskMessage struct {
|
||||
ID string
|
||||
@@ -28,7 +30,6 @@ type TaskMessage struct {
|
||||
|
||||
// InprocQueue manages in-memory task queuing and worker pool execution.
|
||||
type InprocQueue struct {
|
||||
mu sync.RWMutex
|
||||
concurrency int
|
||||
queue chan TaskMessage
|
||||
taskReg extpoints.TaskExtension
|
||||
@@ -157,7 +158,7 @@ func (q *InprocQueue) executeTask(msg TaskMessage) {
|
||||
msg.RetryLeft--
|
||||
// Retry with backoff
|
||||
util.Go(func() {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
time.Sleep(defaultRetryBackoff)
|
||||
if q.running.Load() {
|
||||
select {
|
||||
case q.queue <- msg:
|
||||
|
||||
@@ -25,7 +25,7 @@ func (s *inprocTaskService) Dispatch(ctx context.Context, taskType string, paylo
|
||||
return DispatchTask(ctx, taskType, payload, triggeredBy)
|
||||
}
|
||||
|
||||
func (s *inprocTaskService) Retry(ctx context.Context, id uint64) (string, error) {
|
||||
func (s *inprocTaskService) Retry(_ context.Context, id uint64) (string, error) {
|
||||
return fmt.Sprintf("inproc_retry_%d", id), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user