rename config and adjust osc call

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
Lorenz Herzberger 2023-07-26 17:00:41 +02:00 committed by Julian Strobl
parent 238e68808b
commit b92758268d
No known key found for this signature in database
GPG Key ID: E0A8F9AD733499A7
6 changed files with 24 additions and 14 deletions

4
config/config.dev.json Normal file
View File

@ -0,0 +1,4 @@
{
"WATCHMEN_ENDPOINT": "localhost",
"WATCHMEN_PORT": 7401
}

View File

@ -1,14 +1,17 @@
package app
import (
"fmt"
"path"
"path/filepath"
"runtime"
"strings"
"github.com/tkanos/gonfig"
)
type Configuration struct {
WATCHMEN_ENDPOINT string
WATCHMEN_PORT uint32
WATCHMEN_PORT int
}
func GetConfig(params ...string) Configuration {
@ -19,8 +22,15 @@ func GetConfig(params ...string) Configuration {
env = params[0]
}
filename := fmt.Sprintf("./%s_config.json", env)
gonfig.GetConf(filename, &configuration)
filename := []string{"config.", env, ".json"}
_, dirname, _, _ := runtime.Caller(0)
filePath := path.Join(filepath.Dir(dirname), strings.Join(filename, ""))
err := gonfig.GetConf(filePath, &configuration)
if err != nil {
panic(err)
}
return configuration
}

4
config/config.prod.json Normal file
View File

@ -0,0 +1,4 @@
{
"WATCHMEN_ENDPOINT": "localhost",
"WATCHMEN_PORT": 7401
}

View File

@ -1,4 +0,0 @@
{
"WATCHMEN_ENDPOINT": "localhost",
"WATCHMEN_PORT": 7401
}

View File

@ -1,4 +0,0 @@
{
"WATCHMEN_ENDPOINT": "localhost",
"WATCHMEN_PORT": 7401
}

View File

@ -51,9 +51,9 @@ func (k msgServer) reissueMachine(machine *types.Machine) error {
msg.Append(machine.Name)
msg.Append(machine.Ticker)
msg.Append(machine.Domain)
msg.Append(machine.Amount)
msg.Append(int32(machine.Amount))
msg.Append("1")
msg.Append(machine.Precision)
msg.Append(int32(machine.Precision))
err := client.Send(msg)
return err
}