Netflix / archaius

Library for configuration management API
Apache License 2.0
2.46k stars 485 forks source link

Add support for json based files which contains configurations. #563

Open agarwalsanchit1 opened 5 years ago

agarwalsanchit1 commented 5 years ago

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.

AnthonyClink commented 5 years ago

@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.
agarwalsanchit1 commented 5 years ago

@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.

gorzell commented 5 years ago

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.

agarwalsanchit1 commented 5 years ago

@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.

gorzell commented 5 years ago

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.

agarwalsanchit1 commented 5 years ago

@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 commented 5 years ago

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