mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
add cron job to sync currencies once in 24 hours
This commit is contained in:
33
pkg/job/job.go
Normal file
33
pkg/job/job.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package job
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"wallet-api/pkg/service"
|
||||
"wallet-api/pkg/utl/common"
|
||||
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
|
||||
/*
|
||||
InitializeJobs
|
||||
|
||||
Initializes Dependency Injection modules and registers Jobs
|
||||
|
||||
Args:
|
||||
*dig.Container: Dig Container
|
||||
*/
|
||||
func InitializeJobs(c *dig.Container) {
|
||||
file, err := os.OpenFile("job.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
|
||||
common.CheckError(err)
|
||||
logger := log.New(file, "Job: ", log.Ldate|log.Ltime|log.Lshortfile)
|
||||
|
||||
jobContainer := c.Scope("job")
|
||||
jobContainer.Provide(func() *log.Logger {
|
||||
return logger
|
||||
})
|
||||
|
||||
service.InitializeServices(jobContainer)
|
||||
|
||||
jobContainer.Invoke(NewCurrencyJob)
|
||||
}
|
||||
Reference in New Issue
Block a user