Commit 5dd6e752 authored by rpereira2's avatar rpereira2 Committed by Peter Leitzen

Some code improvements

- Use strong_memoize for prometheus_adapter since it can be nil in some
cases.
- Do not phrase spec descriptions with 'should'.
parent 833206ab
......@@ -3,6 +3,7 @@
module Prometheus
class ProxyService < BaseService
include ReactiveCaching
include Gitlab::Utils::StrongMemoize
self.reactive_cache_key = ->(service) { service.cache_key }
self.reactive_cache_lease_timeout = 30.seconds
......@@ -91,7 +92,9 @@ module Prometheus
end
def prometheus_adapter
@prometheus_adapter ||= @proxyable.prometheus_adapter
strong_memoize(:prometheus_adapter) do
@proxyable.prometheus_adapter
end
end
def prometheus_client_wrapper
......
......@@ -48,7 +48,7 @@ describe Prometheus::ProxyService do
allow(environment).to receive(:prometheus_adapter).and_return(nil)
end
it 'should return error' do
it 'returns error' do
expect(subject.execute).to eq(
status: :error,
message: 'No prometheus server found',
......@@ -63,7 +63,7 @@ describe Prometheus::ProxyService do
allow(prometheus_adapter).to receive(:can_query?).and_return(false)
end
it 'should return error' do
it 'returns error' do
expect(subject.execute).to eq(
status: :error,
message: 'No prometheus server found',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment