From a6253f6cf5430eb007fc3cc71f0b8ce1411fde38 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 17 Jul 2023 12:48:36 +0100 Subject: [PATCH] Testing --- src/dbAccess/access.go | 18 ++++++++++++++++++ src/{mongo => dbAccess}/client.go | 4 ++-- src/go.mod | 1 + src/go.sum | 4 ++++ src/helpers/config.go | 2 +- src/main.go | 13 ++++++++++++- src/mongo/access.go | 10 ---------- src/types/service.go | 5 ----- 8 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 src/dbAccess/access.go rename src/{mongo => dbAccess}/client.go (95%) delete mode 100644 src/mongo/access.go delete mode 100644 src/types/service.go diff --git a/src/dbAccess/access.go b/src/dbAccess/access.go new file mode 100644 index 0000000..b23abb6 --- /dev/null +++ b/src/dbAccess/access.go @@ -0,0 +1,18 @@ +package dbAccess + +import ( + "git.fjla.uk/owlboard/go-types/pkg/database" + "fmt" +) + +func init() { + fmt.Println("dbAccess/access.init() Will be used to push the component version number to the database") +} + +func PutManyServices(collection string, data []database.Service) bool { + return false +} + +func PrintFromDbPackage() { + fmt.Println("hello from the dbAccess package") +} \ No newline at end of file diff --git a/src/mongo/client.go b/src/dbAccess/client.go similarity index 95% rename from src/mongo/client.go rename to src/dbAccess/client.go index 4a35823..7226ff0 100644 --- a/src/mongo/client.go +++ b/src/dbAccess/client.go @@ -1,4 +1,4 @@ -package database +package dbAccess import ( "git.fjla.uk/owlboard/mq-client/helpers" @@ -19,7 +19,7 @@ var MongoClient (*mongo.Client) = initDataAccess() func initDataAccess() (*mongo.Client) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - client, err := mongo.Connect(ctx, options.Client().ApplyURI(dbUri)) + client, err := mongo.Connect(ctx, options.Client().ApplyURI(helpers.DbUri)) if err != nil { fmt.Println(err) helpers.Log("Error connecting to database", 4) diff --git a/src/go.mod b/src/go.mod index aa8c99b..809d6aa 100644 --- a/src/go.mod +++ b/src/go.mod @@ -5,6 +5,7 @@ go 1.19 require go.mongodb.org/mongo-driver v1.12.0 require ( + git.fjla.uk/owlboard/go-types v0.0.0-20230717113641-a1216e6e5106 // indirect github.com/golang/snappy v0.0.1 // indirect github.com/klauspost/compress v1.13.6 // indirect github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect diff --git a/src/go.sum b/src/go.sum index 92bfcc2..a73a690 100644 --- a/src/go.sum +++ b/src/go.sum @@ -1,3 +1,7 @@ +git.fjla.uk/owlboard/go-types v0.0.0-20230717112031-d30d0275718d h1:wpU+R71igyQ8kedcnlVXGxhFXbL8N7VbdcSq2gfnf0g= +git.fjla.uk/owlboard/go-types v0.0.0-20230717112031-d30d0275718d/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= +git.fjla.uk/owlboard/go-types v0.0.0-20230717113641-a1216e6e5106 h1:1sPFYr4/gEdWGWJhB4/Y7jJYemBSZBXcWtBm7XiZqZk= +git.fjla.uk/owlboard/go-types v0.0.0-20230717113641-a1216e6e5106/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= diff --git a/src/helpers/config.go b/src/helpers/config.go index 316b166..a5dbb20 100644 --- a/src/helpers/config.go +++ b/src/helpers/config.go @@ -12,7 +12,7 @@ const Version string = versionNum + "-" + versionSuffix // Environment Variables var runtime string = getRuntime() -var dbUri string = getDbUri() +var DbUri string = getDbUri() var NrUser string = "nil" var NrPass string = "" diff --git a/src/main.go b/src/main.go index 0d18203..2fd97da 100644 --- a/src/main.go +++ b/src/main.go @@ -2,10 +2,21 @@ package main import ( "git.fjla.uk/owlboard/mq-client/helpers" + "git.fjla.uk/owlboard/mq-client/dbAccess" "git.fjla.uk/owlboard/go-types/pkg/database" + "fmt" ) func main() { helpers.Out("Initialised OwlBoard MQ Client " + helpers.Version, 0) - var stop := database.Stop + var test database.Stop = database.Stop{ + PublicDeparture: nil, + WttDeparture: nil, + PublicArrival: nil, + WttArrival: nil, + IsPublic: false, + Tiploc: "Testing", + } + fmt.Println(test) + dbAccess.PrintFromDbPackage() } \ No newline at end of file diff --git a/src/mongo/access.go b/src/mongo/access.go deleted file mode 100644 index bd7f253..0000000 --- a/src/mongo/access.go +++ /dev/null @@ -1,10 +0,0 @@ -package database - -import ( - "git.fjla.uk/owlboard/mq-client/helpers" - "git.fjla.uk/owlboard/mq-client/types" -) - -func PutMany(collection string, data []Service) bool { - return false -} \ No newline at end of file diff --git a/src/types/service.go b/src/types/service.go deleted file mode 100644 index a39edc1..0000000 --- a/src/types/service.go +++ /dev/null @@ -1,5 +0,0 @@ -package types - -type Service struct { - id string -} \ No newline at end of file