Skip to content

Commit

Permalink
object_storage: (fix) implemented switch from internal to public endp…
Browse files Browse the repository at this point in the history
…oint when internal is unavailable.
  • Loading branch information
andypf committed May 9, 2024
1 parent 92d42f4 commit cad7984
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
9 changes: 1 addition & 8 deletions app/controllers/os_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ def reverse_proxy
# byebug

# get api client for the given service name
service = services.os_api.service(service_name,interface: "internal")
# check if internal interface is available
begin
service.endpoint_url(interface: "internal")
rescue Elektron::Errors::ServiceEndpointUnavailable
service = services.os_api.service(service_name,interface: "public")
end

service = services.os_api.service(service_name)
# filter the relevant params for the api client
elektron_params = request.query_parameters

Expand Down
11 changes: 9 additions & 2 deletions app/services/service_layer/os_api_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
# Use case rever_proxy (see os_api_controller.rb)
module ServiceLayer
class OsApiService < Core::ServiceLayer::Service
def service(name,options={})
elektron.service(name,options)
def service(name)
begin
service = elektron.service(name,interface: "internal")
# check if internal interface is available
service.endpoint_url(interface: "internal")
rescue Elektron::Errors::ServiceEndpointUnavailable
service = elektron.service(name,interface: "public")
end
service
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
-# service_endpoint: is used by the app to determine the endpoint to use in api client
-# project_path: is used by the app to determine the project path to use in api client
-# resources_path: is used by the app to link to the resources app
= javascript_include_tag "object_storage_app_widget", data: { |
base_name: plugin('object_storage').service_path(@service_name), |
service_endpoint: services.os_api.service("#{@service_name}").endpoint_url, |
Expand Down

0 comments on commit cad7984

Please sign in to comment.