mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2024-11-14 11:56:45 +01:00
Mohammed Sohail
9c6310440c
- asynq bootstrap handlers - graceful shutdown of goroutines - remove unnecessary global App struct - unmarhsal toml/env to koanf struct
25 lines
490 B
Go
25 lines
490 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"github.com/georgysavva/scany/pgxscan"
|
|
"github.com/hibiken/asynq"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func ussdSyncer(ctx context.Context, t *asynq.Task) error {
|
|
_, err := db.Exec(ctx, queries["ussd-syncer"])
|
|
if err != nil {
|
|
return asynq.SkipRetry
|
|
}
|
|
|
|
var count tableCount
|
|
if err := pgxscan.Get(ctx, db, &count, "SELECT COUNT(*) from users"); err != nil {
|
|
return asynq.SkipRetry
|
|
}
|
|
|
|
log.Info().Msgf("=> %d users synced", count.Count)
|
|
|
|
return nil
|
|
}
|