From a3de00aabd9f4940af20cf4b630995f61124c887 Mon Sep 17 00:00:00 2001 From: Kato Twofold Date: Thu, 19 May 2022 01:55:14 +0300 Subject: [PATCH] + Experimenting with Tasks --- lib/controllers/controllers_taskmanager.go | 22 ++++++++++++++++++++++ main.go | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 lib/controllers/controllers_taskmanager.go diff --git a/lib/controllers/controllers_taskmanager.go b/lib/controllers/controllers_taskmanager.go new file mode 100644 index 0000000..3dd74d8 --- /dev/null +++ b/lib/controllers/controllers_taskmanager.go @@ -0,0 +1,22 @@ +package controllers + +import ( + "time" +) + +func TaskManager() { + + // Run the migrations function + go handleMigrations() + + for range time.Tick(time.Second * 5) { + // fmt.Printf("%s\n", time.Now().Format("02/01/2006 03:04 PM")) + } + +} + +func handleMigrations() { + time.AfterFunc(time.Second*30, func() { + // Run Migrations + }) +} diff --git a/main.go b/main.go index e12a2cf..01643de 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "os" + "github.com/JustKato/FreePad/lib/controllers" "github.com/JustKato/FreePad/lib/routes" "github.com/gin-gonic/gin" ) @@ -13,6 +14,9 @@ func main() { gin.SetMode(gin.ReleaseMode) } + // Run the TaskManager + go controllers.TaskManager() + // Initialize the router router := gin.Default()