Fix of snapshotProcessor initiation
All checks were successful
continuous-integration/drone/push Build is passing

Second try
This commit is contained in:
Adam Štrauch 2021-11-01 01:17:35 +01:00
parent 801b082785
commit 66476275e4
Signed by: cx
GPG key ID: 018304FFA8988F8D
2 changed files with 17 additions and 20 deletions

View file

@ -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)

17
main.go
View file

@ -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() {