From 795655ce4cec2d95fdd9a6148b6486255611aed8 Mon Sep 17 00:00:00 2001 From: Amine Afia Date: Tue, 17 Sep 2024 12:48:04 +0200 Subject: [PATCH] Simplified project structure (#4) --- {data-layer/api => api}/api.go | 0 {data-layer/cmd => cmd}/api/main.go | 0 data-layer/go.mod => go.mod | 0 data-layer/go.sum => go.sum | 0 {data-layer/internal => internal}/handlers/api.go | 0 {data-layer/internal => internal}/handlers/get_blocks.go | 4 +++- {data-layer/internal => internal}/middleware/authorization.go | 0 {data-layer/internal => internal}/tools/clickhouse.go | 2 +- {data-layer/src => src}/Worker.go | 0 {data-layer/src => src}/main.go | 0 10 files changed, 4 insertions(+), 2 deletions(-) rename {data-layer/api => api}/api.go (100%) rename {data-layer/cmd => cmd}/api/main.go (100%) rename data-layer/go.mod => go.mod (100%) rename data-layer/go.sum => go.sum (100%) rename {data-layer/internal => internal}/handlers/api.go (100%) rename {data-layer/internal => internal}/handlers/get_blocks.go (97%) rename {data-layer/internal => internal}/middleware/authorization.go (100%) rename {data-layer/internal => internal}/tools/clickhouse.go (96%) rename {data-layer/src => src}/Worker.go (100%) rename {data-layer/src => src}/main.go (100%) diff --git a/data-layer/api/api.go b/api/api.go similarity index 100% rename from data-layer/api/api.go rename to api/api.go diff --git a/data-layer/cmd/api/main.go b/cmd/api/main.go similarity index 100% rename from data-layer/cmd/api/main.go rename to cmd/api/main.go diff --git a/data-layer/go.mod b/go.mod similarity index 100% rename from data-layer/go.mod rename to go.mod diff --git a/data-layer/go.sum b/go.sum similarity index 100% rename from data-layer/go.sum rename to go.sum diff --git a/data-layer/internal/handlers/api.go b/internal/handlers/api.go similarity index 100% rename from data-layer/internal/handlers/api.go rename to internal/handlers/api.go diff --git a/data-layer/internal/handlers/get_blocks.go b/internal/handlers/get_blocks.go similarity index 97% rename from data-layer/internal/handlers/get_blocks.go rename to internal/handlers/get_blocks.go index bcabf72..51ce078 100644 --- a/data-layer/internal/handlers/get_blocks.go +++ b/internal/handlers/get_blocks.go @@ -31,7 +31,7 @@ func GetBlocks(w http.ResponseWriter, r *http.Request) { api.InternalErrorHandler(w) return } - defer conn.Close() + // defer conn.Close() row := conn.QueryRow(context.Background(), "SELECT block_hash FROM chainsaw.blocks LIMIT 1") var blockHash string @@ -55,4 +55,6 @@ func GetBlocks(w http.ResponseWriter, r *http.Request) { api.InternalErrorHandler(w) return } + + defer conn.Close() } \ No newline at end of file diff --git a/data-layer/internal/middleware/authorization.go b/internal/middleware/authorization.go similarity index 100% rename from data-layer/internal/middleware/authorization.go rename to internal/middleware/authorization.go diff --git a/data-layer/internal/tools/clickhouse.go b/internal/tools/clickhouse.go similarity index 96% rename from data-layer/internal/tools/clickhouse.go rename to internal/tools/clickhouse.go index 747cb53..1fabf88 100644 --- a/data-layer/internal/tools/clickhouse.go +++ b/internal/tools/clickhouse.go @@ -11,7 +11,7 @@ import ( ) func ConnectDB() (clickhouse.Conn, error) { - // Load .env file + // TODO load .env in the mapi main file err := godotenv.Load() if err != nil { return nil, fmt.Errorf("error loading .env file: %w", err) diff --git a/data-layer/src/Worker.go b/src/Worker.go similarity index 100% rename from data-layer/src/Worker.go rename to src/Worker.go diff --git a/data-layer/src/main.go b/src/main.go similarity index 100% rename from data-layer/src/main.go rename to src/main.go