Added asynq and a task client to the container to faciliate task queues.

This commit is contained in:
mikestefanello 2022-02-02 21:24:52 -05:00
parent eb1e42bb02
commit a8bd9f8b2d
12 changed files with 392 additions and 34 deletions

View file

@ -46,6 +46,9 @@ type Container struct {
// TemplateRenderer stores a service to easily render and cache templates
TemplateRenderer *TemplateRenderer
// Tasks stores the task client
Tasks *TaskClient
}
// NewContainer creates and initializes a new Container
@ -60,6 +63,7 @@ func NewContainer() *Container {
c.initAuth()
c.initTemplateRenderer()
c.initMail()
c.initTasks()
return c
}
@ -74,6 +78,9 @@ func (c *Container) Shutdown() error {
if err := c.Database.Close(); err != nil {
return err
}
if err := c.Tasks.Close(); err != nil {
return err
}
return nil
}
@ -182,3 +189,8 @@ func (c *Container) initMail() {
panic(fmt.Sprintf("failed to create mail client: %v", err))
}
}
// initTasks initializes the task client
func (c *Container) initTasks() {
c.Tasks = NewTaskClient(c.Config.Cache)
}