From 66476275e4fe6acc472185f31b9f1f65b9498ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Mon, 1 Nov 2021 01:17:35 +0100 Subject: [PATCH] Fix of snapshotProcessor initiation Second try --- handlers_nats.go | 20 -------------------- main.go | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/handlers_nats.go b/handlers_nats.go index 2a6d804..cb3f3dd 100644 --- a/handlers_nats.go +++ b/handlers_nats.go @@ -20,31 +20,11 @@ import ( "github.com/nats-io/nats.go" "github.com/pkg/errors" "github.com/rosti-cz/node-api/apps" - "github.com/rosti-cz/node-api/apps/drivers" "github.com/rosti-cz/node-api/common" "github.com/rosti-cz/node-api/docker" "github.com/rosti-cz/node-api/node" ) -var snapshotProcessor apps.SnapshotProcessor - -func init() { - // Prepare snapshot processor - snapshotProcessor = apps.SnapshotProcessor{ - AppsPath: config.AppsPath, - TmpSnapshotPath: config.SnapshotsPath, - IndexLabel: config.SnapshotsIndexLabel, - - Driver: drivers.S3Driver{ - S3AccessKey: config.SnapshotsS3AccessKey, - S3SecretKey: config.SnapshotsS3SecretKey, - S3Endpoint: config.SnapshotsS3Endpoint, - S3SSL: config.SnapshotsS3SSL, - Bucket: config.SnapshotsS3Bucket, - }, - } -} - // This handler only passes messages to another function for easier testing func messageHandler(msg *nats.Msg) { go _messageHandler(msg) diff --git a/main.go b/main.go index 6556043..2210c05 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "github.com/labstack/echo" "github.com/nats-io/nats.go" "github.com/rosti-cz/node-api/apps" + "github.com/rosti-cz/node-api/apps/drivers" "github.com/rosti-cz/node-api/common" "github.com/rosti-cz/node-api/node" ) @@ -17,6 +18,7 @@ const JSONIndent = " " var config common.Config var nc *nats.Conn +var snapshotProcessor apps.SnapshotProcessor func _init() { var err error @@ -35,6 +37,21 @@ func _init() { DB: common.GetDBConnection(), } processor.Init() + + // Prepare snapshot processor + snapshotProcessor = apps.SnapshotProcessor{ + AppsPath: config.AppsPath, + TmpSnapshotPath: config.SnapshotsPath, + IndexLabel: config.SnapshotsIndexLabel, + + Driver: drivers.S3Driver{ + S3AccessKey: config.SnapshotsS3AccessKey, + S3SecretKey: config.SnapshotsS3SecretKey, + S3Endpoint: config.SnapshotsS3Endpoint, + S3SSL: config.SnapshotsS3SSL, + Bucket: config.SnapshotsS3Bucket, + }, + } } func main() {