From 4e218c292abf5ce819e6afb2331493c009667836 Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Thu, 5 Sep 2024 11:01:24 -0400 Subject: [PATCH] move apply resource limits to config package --- {server/utils => config}/applyResourceLimits.go | 2 +- main.go | 2 +- server/handlers/event.go | 2 +- server/handlers/req.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename {server/utils => config}/applyResourceLimits.go (99%) diff --git a/server/utils/applyResourceLimits.go b/config/applyResourceLimits.go similarity index 99% rename from server/utils/applyResourceLimits.go rename to config/applyResourceLimits.go index 022db6d..50755ba 100644 --- a/server/utils/applyResourceLimits.go +++ b/config/applyResourceLimits.go @@ -1,4 +1,4 @@ -package utils +package config import ( "log" diff --git a/main.go b/main.go index 36780a8..04ac759 100644 --- a/main.go +++ b/main.go @@ -39,7 +39,7 @@ func main() { log.Fatal("Error loading config: ", err) } - utils.ApplyResourceLimits(&cfg.ResourceLimits) // Apply limits once before starting the server + config.ApplyResourceLimits(&cfg.ResourceLimits) // Apply limits once before starting the server client, err := db.InitDB(cfg) if err != nil { diff --git a/server/handlers/event.go b/server/handlers/event.go index 22ebe84..4e2094d 100644 --- a/server/handlers/event.go +++ b/server/handlers/event.go @@ -16,7 +16,7 @@ import ( ) func HandleEvent(ws *websocket.Conn, message []interface{}) { - utils.LimitedGoRoutine(func() { + config.LimitedGoRoutine(func() { if len(message) != 2 { fmt.Println("Invalid EVENT message format") response.SendNotice(ws, "", "Invalid EVENT message format") diff --git a/server/handlers/req.go b/server/handlers/req.go index 123769d..743b90a 100644 --- a/server/handlers/req.go +++ b/server/handlers/req.go @@ -17,7 +17,7 @@ var subscriptions = make(map[string]relay.Subscription) var mu sync.Mutex // Protect concurrent access to subscriptions map func HandleReq(ws *websocket.Conn, message []interface{}, subscriptions map[string][]relay.Filter) { - utils.LimitedGoRoutine(func() { + config.LimitedGoRoutine(func() { if len(message) < 3 { fmt.Println("Invalid REQ message format") response.SendClosed(ws, "", "invalid: invalid REQ message format")