File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package queue
22
33import (
4+ "fmt"
5+
46 "github.com/Prateet-Github/worker-go/internal/config"
57 "github.com/hibiken/asynq"
68)
79
810func NewServer (cfg * config.Config ) * asynq.Server {
911 return asynq .NewServer (
1012 asynq.RedisClientOpt {
11- Addr : cfg . RedisHost + ":" + cfg .RedisPort ,
13+ Addr : fmt . Sprintf ( "%s:%s" , cfg . RedisHost , cfg .RedisPort ) ,
1214 },
1315 asynq.Config {
1416 Concurrency : 5 ,
Original file line number Diff line number Diff line change 11package queue
22
3- const (
4- TypeProcessVideo = "video:process"
3+ import (
4+ "encoding/json"
5+
6+ "github.com/hibiken/asynq"
57)
68
9+ const TypeProcessVideo = "video:process"
10+
711type VideoTask struct {
812 VideoID string `json:"videoId"`
913 S3Key string `json:"s3Key"`
1014}
15+
16+ func NewProcessVideoTask (payload VideoTask ) (* asynq.Task , error ) {
17+ data , err := json .Marshal (payload )
18+
19+ if err != nil {
20+ return nil , err
21+ }
22+
23+ return asynq .NewTask (TypeProcessVideo , data ), nil
24+ }
You can’t perform that action at this time.
0 commit comments