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