1 //==================================================================================
2 // Copyright (c) 2022 Samsung
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
16 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
17 // platform project (RICP).
18 //==================================================================================
27 "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/models"
28 "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/ricdms"
32 HEALTHY = "Service is running healthy"
35 type IHealthChecker interface {
36 GetStatus() *models.Status
37 GetxAppStatus(appName, namespace string) *models.Status
40 type HealthChecker struct {
43 func NewHealthChecker() IHealthChecker {
44 return &HealthChecker{}
46 func (h *HealthChecker) GetStatus() *models.Status {
47 return &models.Status{
52 func (h *HealthChecker) GetxAppStatus(appName, namespace string) *models.Status {
53 resp, err := http.Get(fmt.Sprintf(ricdms.Config.GETxAPPHealthURL, appName, namespace))
55 ricdms.Logger.Error("Received error while fetching health info: %v", err)
59 if resp.StatusCode != http.StatusOK {
60 ricdms.Logger.Error("xApp is not healthy (http status=%s)", resp.Status)
64 return &models.Status{