@@ -104,8 +104,10 @@ func (ch *ConfigurationHandler) loadData() {
104104 log .Info (messages .ReadPersistentCache , path )
105105 ch .persistentData = utils .ReadFiles (path )
106106 if ! bytes .Equal (ch .persistentData , []byte (`{}` )) {
107- configurations := models .ExtractConfigurationsFromPersistentCache (ch .persistentData )
108- if configurations != nil {
107+ configurations , err := models .ExtractConfigurations (ch .persistentData , ch .environmentID , ch .collectionID )
108+ if err != nil {
109+ log .Error ("Error occurred while reading persistent cache configurations - " , err .Error ())
110+ } else {
109111 ch .saveInCache (configurations )
110112 persistentCacheRead = true
111113 }
@@ -116,17 +118,22 @@ func (ch *ConfigurationHandler) loadData() {
116118 if len (ch .persistentCacheDirectory ) > 0 {
117119 if ! persistentCacheRead {
118120 bootstrapFileData := utils .ReadFiles (path )
119- bootstrapConfigurations := models .ExtractConfigurationsFromBootstrapJson (bootstrapFileData , ch .collectionID , ch .environmentID )
120- if bootstrapConfigurations != nil {
121+ bootstrapConfigurations , err := models .ExtractConfigurations (bootstrapFileData , ch .environmentID , ch .collectionID )
122+ if err != nil {
123+ log .Error ("Error occurred while reading bootstrap configurations - " , err .Error ())
124+ } else {
121125 ch .saveInCache (bootstrapConfigurations )
122- go utils .StoreFiles (string (models .FormatConfig (bootstrapConfigurations , ch .environmentID )), ch .persistentCacheDirectory )
126+ go utils .StoreFiles (string (models .FormatConfig (bootstrapConfigurations , ch .environmentID , ch .collectionID )), ch .persistentCacheDirectory )
127+
123128 }
124129 }
125130 } else {
126131 log .Info (messages .ReadBootstrapConfigurations , path )
127132 bootstrapFileData := utils .ReadFiles (path )
128- bootstrapConfigurations := models .ExtractConfigurationsFromBootstrapJson (bootstrapFileData , ch .collectionID , ch .environmentID )
129- if bootstrapConfigurations != nil {
133+ bootstrapConfigurations , err := models .ExtractConfigurations (bootstrapFileData , ch .environmentID , ch .collectionID )
134+ if err != nil {
135+ log .Error ("Error occurred while reading bootstrap configurations - " , err .Error ())
136+ } else {
130137 ch .saveInCache (bootstrapConfigurations )
131138 }
132139 }
@@ -147,7 +154,7 @@ func (ch *ConfigurationHandler) FetchConfigurationData() {
147154func (ch * ConfigurationHandler ) saveInCache (data []byte ) {
148155 ch .mu .Lock ()
149156 defer ch .mu .Unlock ()
150- configurations := models.Configurations {}
157+ configurations := models.CacheConfig {}
151158 err := json .Unmarshal (data , & configurations )
152159 if err != nil {
153160 log .Error (messages .UnmarshalJSONErr , err )
@@ -156,12 +163,12 @@ func (ch *ConfigurationHandler) saveInCache(data []byte) {
156163 log .Debug (configurations )
157164 featureMap := make (map [string ]models.Feature )
158165 for _ , feature := range configurations .Features {
159- featureMap [feature .GetFeatureID ()] = feature
166+ featureMap [feature .GetFeatureID ()] = feature . Feature
160167 }
161168
162169 propertyMap := make (map [string ]models.Property )
163170 for _ , property := range configurations .Properties {
164- propertyMap [property .GetPropertyID ()] = property
171+ propertyMap [property .GetPropertyID ()] = property . Property
165172 }
166173
167174 segmentMap := make (map [string ]models.Segment )
@@ -230,8 +237,9 @@ func (ch *ConfigurationHandler) fetchFromAPI() {
230237 if response != nil && response .StatusCode == 200 {
231238 log .Info (messages .FetchAPISuccessful )
232239 jsonData , _ := json .Marshal (response .Result )
233- configurations := models .ExtractConfigurationsFromAPIResponse (jsonData )
234- if configurations == nil {
240+ configurations , err := models .ExtractConfigurations (jsonData , ch .environmentID , ch .collectionID )
241+ if err != nil {
242+ log .Error ("Error occurred while reading fetched configurations - " , err .Error ())
235243 return
236244 }
237245 // asynchronously write the response to persistent volume, if enabled
0 commit comments