mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-16 14:51:06 +08:00
feat: [wip] - implement scheduler
This commit is contained in:
22
examples/tasks/scheduler.go
Normal file
22
examples/tasks/scheduler.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/oarkflow/mq"
|
||||
)
|
||||
|
||||
func SchedulerHandler(ctx context.Context, task *mq.Task) mq.Result {
|
||||
fmt.Printf("Processing task: %s\n", task.ID)
|
||||
return mq.Result{Error: nil}
|
||||
}
|
||||
|
||||
func SchedulerCallback(ctx context.Context, result mq.Result) error {
|
||||
if result.Error != nil {
|
||||
fmt.Println("Task failed!")
|
||||
} else {
|
||||
fmt.Println("Task completed successfully.")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user