Class: Grafana::ProxyService
- Inherits:
-
BaseService
- Object
- BaseService
- Grafana::ProxyService
- Includes:
- ReactiveCaching
- Defined in:
- app/services/grafana/proxy_service.rb
Constant Summary
Constants included from ReactiveCaching
ReactiveCaching::ExceededReactiveCacheLimit, ReactiveCaching::InvalidateReactiveCache, ReactiveCaching::WORK_TYPE
Instance Attribute Summary collapse
-
#datasource_id ⇒ Object
Returns the value of attribute datasource_id.
-
#project ⇒ Object
Returns the value of attribute project.
-
#proxy_path ⇒ Object
Returns the value of attribute proxy_path.
-
#query_params ⇒ Object
Returns the value of attribute query_params.
Attributes inherited from BaseService
Class Method Summary collapse
-
.from_cache(project_id, datasource_id, proxy_path, query_params) ⇒ Object
See #initialize for other parameters.
Instance Method Summary collapse
- #cache_key ⇒ Object
- #calculate_reactive_cache ⇒ Object
- #execute ⇒ Object
-
#id ⇒ Object
Required for ReactiveCaching; Usage overridden by self.reactive_cache_worker_finder.
-
#initialize(project, datasource_id, proxy_path, query_params) ⇒ ProxyService
constructor
A new instance of ProxyService.
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(project, datasource_id, proxy_path, query_params) ⇒ ProxyService
Returns a new instance of ProxyService.
33 34 35 36 37 38 |
# File 'app/services/grafana/proxy_service.rb', line 33 def initialize(project, datasource_id, proxy_path, query_params) @project = project @datasource_id = datasource_id @proxy_path = proxy_path @query_params = query_params end |
Instance Attribute Details
#datasource_id ⇒ Object
Returns the value of attribute datasource_id.
18 19 20 |
# File 'app/services/grafana/proxy_service.rb', line 18 def datasource_id @datasource_id end |
#project ⇒ Object
Returns the value of attribute project.
18 19 20 |
# File 'app/services/grafana/proxy_service.rb', line 18 def project @project end |
#proxy_path ⇒ Object
Returns the value of attribute proxy_path.
18 19 20 |
# File 'app/services/grafana/proxy_service.rb', line 18 def proxy_path @proxy_path end |
#query_params ⇒ Object
Returns the value of attribute query_params.
18 19 20 |
# File 'app/services/grafana/proxy_service.rb', line 18 def query_params @query_params end |
Class Method Details
.from_cache(project_id, datasource_id, proxy_path, query_params) ⇒ Object
See #initialize for other parameters.
23 24 25 26 27 |
# File 'app/services/grafana/proxy_service.rb', line 23 def self.from_cache(project_id, datasource_id, proxy_path, query_params) project = Project.find(project_id) new(project, datasource_id, proxy_path, query_params) end |
Instance Method Details
#cache_key ⇒ Object
66 67 68 |
# File 'app/services/grafana/proxy_service.rb', line 66 def cache_key [project.id, datasource_id, proxy_path, query_params] end |
#calculate_reactive_cache ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/services/grafana/proxy_service.rb', line 46 def calculate_reactive_cache(*) return cannot_proxy_response unless client response = client.proxy_datasource( datasource_id: datasource_id, proxy_path: proxy_path, query: query_params ) success(http_status: response.code, body: response.body) rescue ::Grafana::Client::Error => error service_unavailable_response(error) end |
#execute ⇒ Object
40 41 42 43 44 |
# File 'app/services/grafana/proxy_service.rb', line 40 def execute return cannot_proxy_response unless client with_reactive_cache(*cache_key) { |result| result } end |
#id ⇒ Object
Required for ReactiveCaching; Usage overridden by self.reactive_cache_worker_finder
62 63 64 |
# File 'app/services/grafana/proxy_service.rb', line 62 def id nil end |