Skip to content

Commit 7262a89

Browse files
committed
add sethandler
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
1 parent 78ca273 commit 7262a89

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/task/queue.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type TaskQueue interface {
1111
SetStatus(status string)
1212
GetName() string
1313
GetHandler() func(ctx context.Context, t Task) TaskResult
14+
SetHandler(handler func(ctx context.Context, t Task) TaskResult)
1415
Start(ctx context.Context)
1516
Stop()
1617

pkg/task/queue/task_queue_list.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ func (q *TaskQueue) GetHandler() func(ctx context.Context, t task.Task) task.Tas
292292
return q.handler
293293
}
294294

295+
func (q *TaskQueue) SetHandler(handler func(ctx context.Context, t task.Task) task.TaskResult) {
296+
q.m.RLock()
297+
defer q.m.RUnlock()
298+
q.handler = handler
299+
}
300+
295301
func (q *TaskQueue) IsEmpty() bool {
296302
defer q.MeasureActionTime("IsEmpty")()
297303
q.m.RLock()

0 commit comments

Comments
 (0)