summaryrefslogtreecommitdiffstats
path: root/src/dkv/api/initialise.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/dkv/api/initialise.go')
-rw-r--r--src/dkv/api/initialise.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/dkv/api/initialise.go b/src/dkv/api/initialise.go
new file mode 100644
index 0000000..f85c146
--- /dev/null
+++ b/src/dkv/api/initialise.go
@@ -0,0 +1,27 @@
+package api
+
+import (
+ "errors"
+ "os"
+)
+
+func Initialise() error {
+ if os.Getenv("CONSUL_IP") == "" {
+ return errors.New("CONSUL_IP environment variable not set.")
+ }
+
+ Consul = &ConsulStruct{}
+ KeyValues = &KeyValuesStruct{kvs: make(map[string]string)}
+
+ err := Consul.InitializeConsulClient()
+ if err != nil {
+ return err
+ }
+
+ err = Consul.CheckConsulHealth()
+ if err != nil {
+ return err
+ }
+
+ return nil
+}