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:
parent
5fd38f098e
commit
707f798eaf
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue