From e89c70a9bd7f28000446a2da8105d44fb3f0aa5f Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 30 Aug 2024 10:44:47 +0200 Subject: [PATCH] latest oclib for glory + comments --- controllers/status.go | 8 +++----- go.mod | 2 +- go.sum | 2 ++ main.go | 7 +++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/controllers/status.go b/controllers/status.go index 2e1252c..ed82bf1 100644 --- a/controllers/status.go +++ b/controllers/status.go @@ -2,7 +2,6 @@ package controllers import ( "encoding/json" - "fmt" "cloud.o-forge.io/core/oc-lib/tools" beego "github.com/beego/beego/v2/server/web" @@ -34,19 +33,18 @@ type StatusController struct { func (o *StatusController) Status() { var address map[string]string json.Unmarshal(o.Ctx.Input.CopyBody(10000), &address) - fmt.Println(len(address)) if len(address) == 0 { // default if nothing is send in body - for _, host := range []string{"oc-datacenter", "oc-workflow", "oc-workspace", "oc-shared"} { + for _, host := range []string{"oc-datacenter", "oc-workflow", "oc-workspace", "oc-shared", "oc-workspace"} { address[host] = "http://" + host + ":8080/oc" } } api := tools.API{} - state, services, err := api.CheckRemoteAPIs(address) + state, services, err := api.CheckRemoteAPIs(address) // check if the services are alive errSTR := "" if err != nil { errSTR = err.Error() } - o.Data["json"] = map[string]interface{}{ + o.Data["json"] = map[string]interface{}{ // return the status "data": map[string]interface{}{ "state": state.String(), "code": state.EnumIndex(), diff --git a/go.mod b/go.mod index b3fe08f..fa9f3ef 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( ) require ( - cloud.o-forge.io/core/oc-lib v0.0.0-20240823091301-5b3779e4cb21 // indirect + cloud.o-forge.io/core/oc-lib v0.0.0-20240830071403-db78c70dc349 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/beego/bee/v2 v2.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/go.sum b/go.sum index 69cccac..e98e383 100644 --- a/go.sum +++ b/go.sum @@ -174,6 +174,8 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240823082553-98fa1f6ca807 h1:BqqCAnV2pbrX0 cloud.o-forge.io/core/oc-lib v0.0.0-20240823082553-98fa1f6ca807/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU= cloud.o-forge.io/core/oc-lib v0.0.0-20240823091301-5b3779e4cb21 h1:OzsSJVL2jaLewUWfW4C30SVrY4y20+mxI3rbOGLCPyo= cloud.o-forge.io/core/oc-lib v0.0.0-20240823091301-5b3779e4cb21/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU= +cloud.o-forge.io/core/oc-lib v0.0.0-20240830071403-db78c70dc349 h1:bEIY1lCsA78/mJqFE0gV6likAv5ZifH3RMnLJxiSk3o= +cloud.o-forge.io/core/oc-lib v0.0.0-20240830071403-db78c70dc349/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= diff --git a/main.go b/main.go index 1540c26..ace60cd 100644 --- a/main.go +++ b/main.go @@ -29,9 +29,12 @@ func main() { o.GetStringDefault("MONGO_DATABASE", "DC_myDC"), o.GetStringDefault("NATS_URL", "nats://localhost:4222"), ) - + // Init OC with hostname and port for discovery purpose oclib.Init("oc-peers", o.GetStringDefault("HOSTNAME", "localhost"), o.GetStringDefault("PORT", "8093")) - + /* PATHS ARE REFERENCE FOR INNER SERVICE OF DISTANT OC + * PATHS ARE USED TO CALL OTHER OC SERVICES + * NAMES ARE CANONICAL NAMES OF THE SERVICES + */ oclib.AddPath(oclib.LibDataEnum(oclib.BOOKING), o.GetStringDefault("BOOKING_URL", ":8092")) oclib.AddPath(oclib.LibDataEnum(oclib.WORKFLOW), o.GetStringDefault("WORKFLOW_URL", ":8088")) oclib.AddPath(oclib.LibDataEnum(oclib.WORKSPACE), o.GetStringDefault("WORKSPACE_URL", ":8089"))