cic-custodial/cmd/init_tasker.go
Mohammed Sohail 611addbf64
feat: add service mode flags, other refactors
* closes #32
* bin can now run in full (default), tasker, api mode
* move logg bootstrpping earlier
* config file loading via flag
* rename service to main
* graceful shutdown now in main and dependant on mode
2022-12-01 14:29:34 +00:00

66 lines
1.5 KiB
Go

package main
import (
"github.com/grassrootseconomics/cic-custodial/internal/tasker"
"github.com/grassrootseconomics/cic-custodial/internal/tasker/task"
"github.com/hibiken/asynq"
)
func initTasker() *tasker.TaskerServer {
lo.Debug("Bootstrapping tasker")
taskerServerOpts := tasker.TaskerServerOpts{
Concurrency: ko.MustInt("asynq.concurrency"),
Logg: lo,
RedisPool: asynqRedisPool,
SystemContainer: nil,
TaskerClient: taskerClient,
}
if debugFlag {
taskerServerOpts.LogLevel = asynq.DebugLevel
}
taskerServer := tasker.NewTaskerServer(taskerServerOpts)
taskerServer.RegisterHandlers(tasker.PrepareAccountTask, task.PrepareAccount(
redisNoncestore,
taskerClient,
))
taskerServer.RegisterHandlers(tasker.GiftGasTask, task.GiftGasProcessor(
celoProvider,
redisNoncestore,
lockProvider,
system,
taskerClient,
))
taskerServer.RegisterHandlers(tasker.GiftTokenTask, task.GiftTokenProcessor(
celoProvider,
redisNoncestore,
lockProvider,
system,
taskerClient,
))
taskerServer.RegisterHandlers(tasker.RefillGasTask, task.RefillGasProcessor(
celoProvider,
redisNoncestore,
lockProvider,
system,
taskerClient,
))
taskerServer.RegisterHandlers(tasker.TransferTokenTask, task.TransferToken(
celoProvider,
redisNoncestore,
postgresKeystore,
lockProvider,
system,
taskerClient,
))
taskerServer.RegisterHandlers(tasker.TxDispatchTask, task.TxDispatch(
celoProvider,
))
lo.Debug("Registered all tasker handlers")
return taskerServer
}