allow configuring the default service tree for consul

Change-Id: Ic14fd4cf7326a88e5199e4ee1c0fb71a7d7598d0
Reviewed-on: https://gerrit.instructure.com/165386
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2018-09-21 10:37:43 -06:00
parent 5fd38f098e
commit 707f798eaf
2 changed files with 6 additions and 3 deletions

View File

@ -50,9 +50,11 @@ module Canvas
@environment = conf_hash['environment']
@kv_client = Imperium::KV.default_client
@data_center = conf_hash.fetch('global_dc', nil)
@default_service = conf_hash.fetch('service', :canvas)
else
@environment = nil
@kv_client = nil
@default_service = :canvas
end
end
@ -90,11 +92,12 @@ module Canvas
# @param data_center [String] location of the data_center the proxy is pointing to
def find( prefix = nil,
tree: :config,
service: :canvas,
service: nil,
cluster: nil,
default_ttl: DynamicSettings::PrefixProxy::DEFAULT_TTL,
data_center: nil
)
service ||= @default_service || :canvas
if kv_client
PrefixProxy.new(
prefix,

View File

@ -55,10 +55,10 @@ describe ConsulInitializer do
describe "just from loading" do
it "clears the DynamicSettings cache on reload" do
Canvas::DynamicSettings.reset_cache!
Canvas::DynamicSettings::Cache.insert('key', 'value')
Canvas::DynamicSettings::Cache.insert('service/key', 'value')
imperium = double('imperium', get: nil)
allow(Canvas::DynamicSettings).to receive(:kv_client).and_return(imperium)
expect(Canvas::DynamicSettings.find(tree: nil, service: nil)['key']).to eq("value")
expect(Canvas::DynamicSettings.find(tree: nil, service: 'service')['key']).to eq("value")
Canvas::Reloader.reload!
expect(Canvas::DynamicSettings::Cache.store).to eq({})
end