1
0
Fork 1
mirror of https://github.com/hay-kot/homebox.git synced 2024-12-23 07:16:30 +00:00
homebox/backend/app/api/app.go

45 lines
902 B
Go
Raw Normal View History

2022-08-30 02:30:36 +00:00
package main
import (
"time"
"github.com/hay-kot/homebox/backend/ent"
"github.com/hay-kot/homebox/backend/internal/config"
"github.com/hay-kot/homebox/backend/internal/repo"
"github.com/hay-kot/homebox/backend/internal/services"
"github.com/hay-kot/homebox/backend/pkgs/mailer"
"github.com/hay-kot/homebox/backend/pkgs/server"
2022-08-30 02:30:36 +00:00
)
type app struct {
conf *config.Config
mailer mailer.Mailer
db *ent.Client
server *server.Server
repos *repo.AllRepos
services *services.AllServices
}
2022-09-04 03:27:02 +00:00
func new(conf *config.Config) *app {
2022-08-30 02:30:36 +00:00
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
}
2022-09-04 03:27:02 +00:00
func (a *app) startBgTask(t time.Duration, fn func()) {
2022-08-30 02:30:36 +00:00
for {
a.server.Background(fn)
time.Sleep(t)
}
}