X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=icsversion%2Fmain.go;fp=icsversion%2Fmain.go;h=b9e9afc39c555488be4aa5199eb04df3ad26cce1;hb=16f26ec9bec7e406398340473de228706f75e97f;hp=0000000000000000000000000000000000000000;hpb=456fa341c3bd404b5bedbbfad5b5f1e14f809fe1;p=nonrtric%2Frapp%2Fransliceassurance.git diff --git a/icsversion/main.go b/icsversion/main.go new file mode 100644 index 0000000..b9e9afc --- /dev/null +++ b/icsversion/main.go @@ -0,0 +1,71 @@ +// - +// ========================LICENSE_START================================= +// O-RAN-SC +// %% +// Copyright (C) 2022: 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" + "os" + "os/signal" + "syscall" + + log "github.com/sirupsen/logrus" + "oransc.org/usecase/oduclosedloop/icsversion/internal/config" + sliceassurance "oransc.org/usecase/oduclosedloop/icsversion/internal/odusliceassurance" +) + +var configuration *config.Configuration +var a sliceassurance.App + +const TOPIC string = "/events/unauthenticated.VES_O_RAN_SC_HELLO_WORLD_PM_STREAMING_OUTPUT/myG/C1" + +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.StartServer() + keepConsumerAlive() +} + +func validateConfiguration(configuration *config.Configuration) error { + if configuration.ConsumerHost == "" || configuration.ConsumerPort == 0 { + return fmt.Errorf("consumer host and port must be provided") + } + return nil +} + +func keepConsumerAlive() { + exitSignal := make(chan os.Signal, 1) + signal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM) + <-exitSignal + + a.Teardown() +}