Changed permissions cache save interval to 30 minutes
This commit is contained in:
@@ -24,7 +24,7 @@ func New(c *common.Config) *Chronos {
|
||||
func (c *Chronos) Start() error {
|
||||
job := NewCachePermissionsJob(c)
|
||||
sch := clockwerk.New()
|
||||
sch.Every(30 * time.Second).Do(job)
|
||||
sch.Every(30 * time.Minute).Do(job)
|
||||
sch.Start()
|
||||
|
||||
return nil
|
||||
@@ -37,7 +37,8 @@ func (c *Chronos) RegisterHandler(name string, fn func() any) {
|
||||
func (c *Chronos) OnShutdown() {
|
||||
log.Println("Chronos is going down...")
|
||||
|
||||
// c.GetDatabase().Close()
|
||||
c.GetDatabase().Close()
|
||||
c.GetCache().Close()
|
||||
}
|
||||
|
||||
// Plugin helper funcitons - refactor needed cause funcs are duplcated in server.go
|
||||
|
||||
@@ -16,12 +16,7 @@ func (s *Server) LoginHandlerFn(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
userRepo := repository.NewUserRepository(s.GetDatabase())
|
||||
roleRepo := repository.NewRoleRepository(s.GetDatabase())
|
||||
urlRepo := repository.NewURLAccessRepository(s.GetDatabase())
|
||||
authSrv := service.NewAuthService(userRepo, s.GetCache())
|
||||
guardSrv := service.NewGuardService(authSrv, s.GetCache(), userRepo, roleRepo, urlRepo)
|
||||
|
||||
guardSrv.CacheAllPermissions() // FIXME: Move it to the worker and fire-up as a CRONJOB
|
||||
|
||||
token, err := ui.NewLoginActionUI(authSrv).Execute(data)
|
||||
if err != nil { // TODO: handle other response status codes -- add struct to decorate error with code and message
|
||||
|
||||
@@ -67,6 +67,7 @@ func (s *Server) OnShutdown() {
|
||||
log.Printf("Server %s is going down...", s.ID)
|
||||
|
||||
s.GetDatabase().Close()
|
||||
s.GetCache().Close()
|
||||
s.Shutdown()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user