diff --git a/handlers_nats.go b/handlers_nats.go index c11a8f3..2a6d804 100644 --- a/handlers_nats.go +++ b/handlers_nats.go @@ -26,6 +26,25 @@ import ( "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) @@ -88,21 +107,6 @@ func _messageHandler(m *nats.Msg) error { return nil } -// Prepare snapshot processor -var snapshotProcessor apps.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, - }, -} - // Returns list of apps func listEventHandler(m *nats.Msg, message *RequestMessage) error { log.Println("> List")