X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=nonrtric%2Frapp%2Fransliceassurance.git;a=blobdiff_plain;f=smoversion%2Fmain.go;fp=smoversion%2Fmain.go;h=337e4e02b5ee050c93c6b346bd78f71bfc278ee0;hp=0000000000000000000000000000000000000000;hb=5542d26d709c996977d3992c58b273ce83e21e16;hpb=71e113b81dbc68694aec281c85c4472640dc8095 diff --git a/smoversion/main.go b/smoversion/main.go new file mode 100644 index 0000000..337e4e0 --- /dev/null +++ b/smoversion/main.go @@ -0,0 +1,66 @@ +// - +// ========================LICENSE_START================================= +// O-RAN-SC +// %% +// Copyright (C) 2021: Nordix Foundation +// %% +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ========================LICENSE_END=================================== +// + +package main + +import ( + "fmt" + "net/http" + + log "github.com/sirupsen/logrus" + "oransc.org/usecase/oduclosedloop/internal/config" + "oransc.org/usecase/oduclosedloop/internal/sliceassurance" +) + +const TOPIC string = "/events/unauthenticated.VES_O_RAN_SC_HELLO_WORLD_PM_STREAMING_OUTPUT/myG/C1" + +var configuration *config.Config + +func main() { + configuration = config.New() + + log.SetLevel(configuration.LogLevel) + log.SetFormatter(&log.JSONFormatter{}) + + log.Debug("Using configuration: ", configuration) + + if err := validateConfiguration(configuration); err != nil { + log.Fatalf("Unable to start consumer due to configuration error: %v", err) + } + + a := sliceassurance.App{} + a.Initialize(configuration) + go a.Run(TOPIC, configuration.Polltime) + + http.HandleFunc("/status", statusHandler) + + log.Fatal(http.ListenAndServe(":40936", nil)) +} + +func validateConfiguration(configuration *config.Config) error { + if configuration.MRHost == "" || configuration.MRPort == "" { + return fmt.Errorf("message router host and port must be provided") + } + return nil +} + +func statusHandler(w http.ResponseWriter, r *http.Request) { + // Just respond OK to show the service is alive for now. Might be extended later. +}