cic-custodial/cmd/service/tasker.go
Mohammed Sohail 8676450122
refactor: decouple sql queries, remove transfer
* add inline docs
* removed transfer taks in prep for re-write
2023-02-03 12:29:27 +03:00

59 lines
1.9 KiB
Go

package main
import (
"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.
func initTasker(custodialContainer *custodial, redisPool *redis.RedisPool) *tasker.TaskerServer {
lo.Debug("Bootstrapping tasker")
taskerServerOpts := tasker.TaskerServerOpts{
Concurrency: ko.MustInt("asynq.worker_count"),
Logg: lo,
RedisPool: redisPool,
SystemContainer: custodialContainer.systemContainer,
TaskerClient: custodialContainer.taskerClient,
}
if debugFlag {
taskerServerOpts.LogLevel = asynq.DebugLevel
}
taskerServer := tasker.NewTaskerServer(taskerServerOpts)
taskerServer.RegisterHandlers(tasker.PrepareAccountTask, task.PrepareAccount(
custodialContainer.noncestore,
custodialContainer.taskerClient,
))
taskerServer.RegisterHandlers(tasker.GiftGasTask, task.GiftGasProcessor(
custodialContainer.celoProvider,
custodialContainer.noncestore,
custodialContainer.lockProvider,
custodialContainer.systemContainer,
custodialContainer.taskerClient,
))
taskerServer.RegisterHandlers(tasker.GiftTokenTask, task.GiftTokenProcessor(
custodialContainer.celoProvider,
custodialContainer.noncestore,
custodialContainer.lockProvider,
custodialContainer.systemContainer,
custodialContainer.taskerClient,
))
taskerServer.RegisterHandlers(tasker.RefillGasTask, task.RefillGasProcessor(
custodialContainer.celoProvider,
custodialContainer.noncestore,
custodialContainer.lockProvider,
custodialContainer.systemContainer,
custodialContainer.taskerClient,
))
taskerServer.RegisterHandlers(tasker.TxDispatchTask, task.TxDispatch(
custodialContainer.celoProvider,
))
return taskerServer
}