From b242ed3c44f4dde7c4b452312b78a3b02f42ea65 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sat, 19 Aug 2023 16:24:42 +0200 Subject: feat: Add task loop Now the tasks will loop every given time. With this it will be able to pick up new photos after the application was started. I added 2h for file because my personal photo gallery is quite big and quite IO bottled necked so it tasks a lot of time to go through. --- pkg/worker/httpserver.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/worker/httpserver.go') diff --git a/pkg/worker/httpserver.go b/pkg/worker/httpserver.go index dc8f255..f0ec3ba 100644 --- a/pkg/worker/httpserver.go +++ b/pkg/worker/httpserver.go @@ -5,11 +5,11 @@ import ( "net/http" ) -type ServerWorker struct { +type ServerTask struct { server *http.Server } -func (self *ServerWorker) Start(ctx context.Context) error { +func (self *ServerTask) Start(ctx context.Context) error { go func() { // nolint: errcheck self.server.ListenAndServe() @@ -19,8 +19,8 @@ func (self *ServerWorker) Start(ctx context.Context) error { return self.server.Shutdown(ctx) } -func NewServerWorker(server *http.Server) *ServerWorker { - return &ServerWorker{ +func NewServerTask(server *http.Server) *ServerTask { + return &ServerTask{ server: server, } } -- cgit v1.2.3