fixes for disk calculation issues
parent
81b19b6267
commit
2991ffb455
|
@ -13,17 +13,14 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// ConfigStruct the configuration struct
|
||||
type ConfigStruct struct {
|
||||
MongoDB string `json:"mongoURL"`
|
||||
}
|
||||
|
||||
// Config config
|
||||
var Config *ConfigStruct
|
||||
|
||||
// RedisClient the Redis client
|
||||
var RedisClient *redis.Client
|
||||
|
||||
// ConfigStruct the configuration struct
|
||||
type ConfigStruct struct {
|
||||
MongoDB string `json:"mongoURL"`
|
||||
}
|
||||
|
||||
// Account represents an user's account.
|
||||
type Account struct {
|
||||
Username string `json:"username"`
|
||||
|
@ -45,10 +42,10 @@ func HandleError(e error, serv int) {
|
|||
|
||||
func main() {
|
||||
var status bool
|
||||
Config := &ConfigStruct{}
|
||||
config := &ConfigStruct{}
|
||||
file, err := ioutil.ReadFile("../config.json")
|
||||
HandleError(err, 1)
|
||||
err = json.Unmarshal(file, &Config)
|
||||
err = json.Unmarshal(file, &config)
|
||||
|
||||
RedisClient = redis.NewClient(&redis.Options{
|
||||
Addr: "localhost:6379",
|
||||
|
@ -64,15 +61,15 @@ func main() {
|
|||
for {
|
||||
fmt.Printf("Calling handler func [GO]\n")
|
||||
if status == false {
|
||||
handler(&status)
|
||||
handler(&status, *config)
|
||||
time.Sleep(1000000 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handler(status* bool) {
|
||||
func handler(status *bool, config ConfigStruct) {
|
||||
*status = true
|
||||
mongoClient, err := mongo.NewClient(options.Client().ApplyURI(Config.MongoDB))
|
||||
mongoClient, err := mongo.NewClient(options.Client().ApplyURI(config.MongoDB))
|
||||
HandleError(err, 1)
|
||||
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
err = mongoClient.Connect(ctx)
|
||||
|
|
Loading…
Reference in New Issue