mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-10 01:06:46 +01:00
Mohammed Sohail
611addbf64
* 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
66 lines
1.5 KiB
Go
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
|
|
}
|