Organisation of code
This commit is contained in:
parent
a3867016d1
commit
0b134ee666
5
src/database/access.go
Normal file
5
src/database/access.go
Normal file
@ -0,0 +1,5 @@
|
||||
package database
|
||||
|
||||
func PutMany(collection string, data []Service) bool {
|
||||
return false
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package main
|
||||
package database
|
||||
|
||||
import (
|
||||
"git.fjla.uk/owlboard/mq-client/helpers"
|
||||
|
||||
"context"
|
||||
"time"
|
||||
"fmt"
|
||||
@ -10,25 +12,19 @@ import (
|
||||
// "go.mongodb.org/mongo-driver/mongo/readpref"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
id string
|
||||
}
|
||||
|
||||
var client (*mongo.Client) = initDataAccess()
|
||||
// Provide the DB Connection to other functions
|
||||
var MongoClient (*mongo.Client) = initDataAccess()
|
||||
|
||||
// Initialise the DB Connection
|
||||
func initDataAccess() (*mongo.Client) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
client, err := mongo.Connect(ctx, options.Client().ApplyURI(dbUri))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
Log("Error connecting to database", 4)
|
||||
helpers.Log("Error connecting to database", 4)
|
||||
} else {
|
||||
Log("Connected to Database", 1)
|
||||
helpers.Log("Connected to Database", 1)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func PutMany(collection string, data []Service) bool {
|
||||
return false
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -8,7 +8,7 @@ import (
|
||||
// Version Constants
|
||||
const versionNum string = "2023.7.1"
|
||||
const versionSuffix string = "beta"
|
||||
const versionStr string = versionNum + "-" + versionSuffix
|
||||
const Version string = versionNum + "-" + versionSuffix
|
||||
|
||||
// Environment Variables
|
||||
var runtime string = getRuntime()
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,8 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.fjla.uk/owlboard/mq-client/helpers"
|
||||
)
|
||||
|
||||
func main() {
|
||||
Out("Initialised OwlBoard MQ Client " + versionStr, 0)
|
||||
helpers.Out("Initialised OwlBoard MQ Client " + helpers.Version, 0)
|
||||
}
|
5
src/types/service.go
Normal file
5
src/types/service.go
Normal file
@ -0,0 +1,5 @@
|
||||
package types
|
||||
|
||||
type Service struct {
|
||||
id string
|
||||
}
|
Loading…
Reference in New Issue
Block a user