archaius icon indicating copy to clipboard operation
archaius copied to clipboard

Add support for json based files which contains configurations.

Open agarwalsanchit1 opened this issue 6 years ago • 7 comments

I am looking for a feature within the netflix archius which would enable to load json based configuration file instantly once the changes have been made to the same.

agarwalsanchit1 avatar Nov 05 '18 17:11 agarwalsanchit1

@agarwalsanchit1 how would you handle json object arrays?

{"people": [
 {"firstName": "Anthony", "lastName": "Clink"},
 {"firstName": "Tony", "lastName": "Blink"}
]}



would you want people[0].firstName
would you want people[1].lastName?


How would you represent this?

Remember that json is an object graph not a flat key value store.

AnthonyClink avatar Nov 05 '18 21:11 AnthonyClink

@AnthonyClink It's achievable. In the case, I would consider each attribute of the index location as a single attribute.

I would share the implementation within a week.

agarwalsanchit1 avatar Nov 06 '18 15:11 agarwalsanchit1

Have you considered using the typesafe/lightbend module and underlying library? It should support reading configuration from JSON more or less out of the box.

gorzell avatar Nov 07 '18 16:11 gorzell

@gorzell Thanks for suggesting it. I worked on your approach and it did not suit our requirements.

Our project is based on the JSON-based configuration management system. We require a functionality to reload all the configurations if any changes have been made. There are lots of configurations files and all of them are onto S3 to support externalization.

agarwalsanchit1 avatar Nov 09 '18 14:11 agarwalsanchit1

I am not sure if you are using a 1.x or 2.x version of Archaius. But I would also encourage you to keep the parsing and loading logic separate.

A 1.x example of loading configuration from S3 can be found in: https://github.com/Netflix/archaius/blob/master/archaius-jclouds/src/main/java/com/netflix/config/sources/BlobStoreConfigurationSource.java and the related interface is https://github.com/Netflix/archaius/blob/master/archaius-core/src/main/java/com/netflix/config/PolledConfigurationSource.java.

I believe https://github.com/Netflix/archaius/blob/2.x/archaius2-core/src/main/java/com/netflix/archaius/readers/URLConfigReader.java is the relevant example in 2.x.

gorzell avatar Nov 09 '18 15:11 gorzell

@gorzell We are using 2.0 version of Archaius. All the configuration files are placed inside the jar file and some of them are placed individually onto S3 and within the project itself.

Following are the features to be implemented within the Netflix Archaius to support our project requirements:-

  1. To read JSON and properties based configuration files from JAR file.
  2. To read individual JSON config file from S3 and within the project.

I will share the code within a week for reviewing purpose. Is it Okay :)

agarwalsanchit1 avatar Nov 12 '18 14:11 agarwalsanchit1

I will fork 2.0 version of the Archaius branch and will commit the added code over there.

agarwalsanchit1 avatar Nov 14 '18 15:11 agarwalsanchit1