Moved infra/ to internal/ sub-dir
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
"git.ego.freeddns.org/egommerce/identity-service/common"
|
||||
"git.ego.freeddns.org/egommerce/identity-service/internal/chronos/jobs"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
@@ -23,10 +22,10 @@ func New(c *common.Config) *Chronos {
|
||||
}
|
||||
|
||||
func (c *Chronos) Start() error {
|
||||
job := jobs.NewCachePermissionsJob()
|
||||
s := clockwerk.New()
|
||||
s.Every(30 * time.Second).Do(job)
|
||||
s.Start()
|
||||
job := NewCachePermissionsJob(c)
|
||||
sch := clockwerk.New()
|
||||
sch.Every(30 * time.Second).Do(job)
|
||||
sch.Start()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -35,18 +34,18 @@ func (c *Chronos) RegisterHandler(name string, fn func() any) {
|
||||
c.handlers[name] = fn()
|
||||
}
|
||||
|
||||
func (s *Chronos) OnShutdown() {
|
||||
func (c *Chronos) OnShutdown() {
|
||||
log.Println("Chronos is going down...")
|
||||
|
||||
// s.GetDatabase().Close()
|
||||
// c.GetDatabase().Close()
|
||||
}
|
||||
|
||||
// Plugin helper funcitons
|
||||
// Plugin helper funcitons - refactor needed cause funcs are duplcated in server.go
|
||||
// TODO: move functions below to some common place
|
||||
func (s *Chronos) GetCache() *redis.Client {
|
||||
return (s.handlers["cache"]).(*redis.Client)
|
||||
func (c *Chronos) GetCache() *redis.Client {
|
||||
return (c.handlers["cache"]).(*redis.Client)
|
||||
}
|
||||
|
||||
func (s *Chronos) GetDatabase() *pgxpool.Pool {
|
||||
return (s.handlers["database"]).(*pgxpool.Pool)
|
||||
func (c *Chronos) GetDatabase() *pgxpool.Pool {
|
||||
return (c.handlers["database"]).(*pgxpool.Pool)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user