mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-19 21:36:30 +00:00
0cbe516ca3
* rough implementation of WS based event system for server side notifications of mutation
* fix test construction
* fix deadlock on event bus
* disable linter error
* add item mutation events
* remove old event bus code
* refactor event system to use composables
* refresh items table when new item is added
* fix create form errors
* cleanup unnecessary calls
* fix importer erorrs + limit fn calls on import
Former-commit-id: 2cbcc8bb1d
49 lines
1 KiB
Go
49 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hay-kot/homebox/backend/internal/core/services"
|
|
"github.com/hay-kot/homebox/backend/internal/core/services/reporting/eventbus"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent"
|
|
"github.com/hay-kot/homebox/backend/internal/data/repo"
|
|
"github.com/hay-kot/homebox/backend/internal/sys/config"
|
|
"github.com/hay-kot/homebox/backend/pkgs/mailer"
|
|
"github.com/hay-kot/httpkit/server"
|
|
)
|
|
|
|
type app struct {
|
|
conf *config.Config
|
|
mailer mailer.Mailer
|
|
db *ent.Client
|
|
server *server.Server
|
|
repos *repo.AllRepos
|
|
services *services.AllServices
|
|
bus *eventbus.EventBus
|
|
}
|
|
|
|
func new(conf *config.Config) *app {
|
|
s := &app{
|
|
conf: conf,
|
|
}
|
|
|
|
s.mailer = mailer.Mailer{
|
|
Host: s.conf.Mailer.Host,
|
|
Port: s.conf.Mailer.Port,
|
|
Username: s.conf.Mailer.Username,
|
|
Password: s.conf.Mailer.Password,
|
|
From: s.conf.Mailer.From,
|
|
}
|
|
|
|
return s
|
|
}
|
|
|
|
func (a *app) startBgTask(t time.Duration, fn func()) {
|
|
timer := time.NewTimer(t)
|
|
|
|
for {
|
|
timer.Reset(t)
|
|
a.server.Background(fn)
|
|
<-timer.C
|
|
}
|
|
}
|