33 lines
781 B
Go
33 lines
781 B
Go
package main
|
|
|
|
import (
|
|
"github.com/hibiken/asynq"
|
|
"github.com/joho/godotenv"
|
|
"sipro-mps/internal/config"
|
|
"sipro-mps/internal/tasks/types"
|
|
)
|
|
|
|
func main() {
|
|
godotenv.Load()
|
|
cfg, err := config.LoadConfig()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
client := asynq.NewClient(asynq.RedisClientOpt{Addr: cfg.Redis.Host + ":" + cfg.Redis.Port, Password: cfg.Redis.Password})
|
|
defer func(client *asynq.Client) {
|
|
err := client.Close()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}(client)
|
|
task, err := types.NewFetchProductsTask(types.TypeOzonFetchProducts, 930)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
info, err := client.Enqueue(task)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
println("Task enqueued successfully:", info.ID, "with queue name:", info.Queue, "and payload size:", len(info.Payload), "bytes")
|
|
}
|