2 ==================================================================================
3 Copyright (c) 2023 Samsung
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
17 This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 platform project (RICP).
19 ==================================================================================
26 "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/a1"
27 "github.com/spf13/viper"
30 type Configuration struct {
41 func ParseConfiguration() *Configuration {
42 viper.SetConfigType("yaml")
43 viper.SetConfigName("configuration")
44 configFile := os.Getenv("A1_CONFIG_FILE")
45 viper.SetConfigFile(configFile)
46 err := viper.ReadInConfig()
48 a1.Logger.Info("#configuration.ParseConfiguration - failed to read configuration file: %s\n", err)
51 config := Configuration{}
52 config.LogLevel = viper.GetString("log-level")
53 viper.SetDefault("log-level", "info")
54 config.Name = viper.GetString("NAME")
55 viper.SetDefault("NAME", "")
56 config.MaxSize = viper.GetInt("MAX_SIZE")
57 viper.SetDefault("MAX_SIZE", 65534)
58 config.ThreadType = viper.GetInt("THREAD_TYPE")
59 viper.SetDefault("THREAD_TYPE", 0)
60 config.LowLatency = viper.GetBool("LOW_LATENCY")
61 viper.SetDefault("LOW_LATENCY", false)
62 config.FastAck = viper.GetBool("FAST_ACK")
63 viper.SetDefault("FAST_ACK", false)
64 config.MaxRetryOnFailure = viper.GetInt("MAX_RETRY_ON_FAILURE")
65 viper.SetDefault("MAX_RETRY_ON_FAILURE", 1)
66 config.Port = viper.GetInt("PORT")
67 viper.SetDefault("PORT", 4562)