2023-02-15 08:05:43 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-02-20 10:56:30 +01:00
|
|
|
"github.com/grassrootseconomics/cic-custodial/internal/custodial"
|
2023-02-15 08:05:43 +01:00
|
|
|
"github.com/grassrootseconomics/cic-custodial/internal/tasker"
|
|
|
|
"github.com/grassrootseconomics/cic-custodial/internal/tasker/task"
|
|
|
|
"github.com/grassrootseconomics/cic-custodial/pkg/redis"
|
|
|
|
"github.com/hibiken/asynq"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Load tasker handlers, injecting any necessary handler dependencies from the system container.
|
2023-02-20 10:56:30 +01:00
|
|
|
func initTasker(custodialContainer *custodial.Custodial, redisPool *redis.RedisPool) *tasker.TaskerServer {
|
2023-02-15 08:05:43 +01:00
|
|
|
lo.Debug("Bootstrapping tasker")
|
|
|
|
|
|
|
|
taskerServerOpts := tasker.TaskerServerOpts{
|
2023-02-20 10:56:30 +01:00
|
|
|
Concurrency: ko.MustInt("asynq.worker_count"),
|
|
|
|
Logg: lo,
|
|
|
|
LogLevel: asynq.InfoLevel,
|
|
|
|
RedisPool: redisPool,
|
2023-02-15 08:05:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
taskerServer := tasker.NewTaskerServer(taskerServerOpts)
|
|
|
|
|
2023-02-20 10:56:30 +01:00
|
|
|
taskerServer.RegisterHandlers(tasker.AccountPrepareTask, task.AccountPrepare(custodialContainer))
|
|
|
|
taskerServer.RegisterHandlers(tasker.AccountRegisterTask, task.AccountRegisterOnChainProcessor(custodialContainer))
|
|
|
|
taskerServer.RegisterHandlers(tasker.AccountGiftGasTask, task.AccountGiftGasProcessor(custodialContainer))
|
|
|
|
taskerServer.RegisterHandlers(tasker.AccountGiftVoucherTask, task.GiftVoucherProcessor(custodialContainer))
|
|
|
|
taskerServer.RegisterHandlers(tasker.AccountRefillGasTask, task.AccountRefillGasProcessor(custodialContainer))
|
|
|
|
taskerServer.RegisterHandlers(tasker.SignTransferTask, task.SignTransfer(custodialContainer))
|
|
|
|
taskerServer.RegisterHandlers(tasker.DispatchTxTask, task.DispatchTx(custodialContainer))
|
2023-02-15 08:05:43 +01:00
|
|
|
|
|
|
|
return taskerServer
|
|
|
|
}
|