ConfigServerAgent
This is a client for the Config Server project. It allows you to retrieve configuration for your Ruby project.
The first time get_config
is called, ConfigServerAgent
will request your config pack from the configured Config Server. This will be cached and returned on subsequent calls to get_config
, without further requests being made to the Config Server.
Call clear
to clear the cache. The next call to get_config
will cause the Config Server to be contacted again.
It is thread safe.
Installation
Add this line to your application's Gemfile:
gem 'config_server_agent'
And then execute:
$ bundle
Or install it yourself as:
$ gem install config_server_agent
Usage
ConfigServerAgent
requires six parameters to operate correctly. These parameters can either be explicitly provided to the constructor, or they will be pulled from environment variables. An ArgumentError
will be raised if the parameters are not available from either source. Parameters supplied to the constructor will take precedence over environment variables.
client = ConfigServerAgent.new(
auth0_client_id: '4F4l7leKKigMN8CziKpgjvXGKrihih1F',
auth0_client_secret: '3SrKmNAdKNzFBA3Lb6fgnTDyyFOQLt7hREWSlcU9QGc1SMKNKRL9DqmxyXQerS0E',
auth0_host: 'yourdomain.au.auth0.com',
config_server_audience: 'https://yourdomain.com',
config_server_api_key: 'Rd5N9hQlbkK7pYxMZGGsQAv...snip...C2OpRq9hEIGtp4Aw6OpEOsec5==',
config_server_host: 'https://your.config.server.com'
)
client = ConfigServerAgent.new
client.get_config
Development
After checking out the repo, run bundle install
to install dependencies. Then, run rake test
to run the tests. You can also run rake console
for an interactive prompt that will allow you to experiment.
Contributing
To experiment with the code, run rake console
for an interactive prompt.
License
The gem is available as open source under the terms of the MIT License.