Skip to content
Snippets Groups Projects
Commit be08ea0e authored by Furkan Ayhan's avatar Furkan Ayhan :palm_tree:
Browse files

Use the one-ff strategy

parent 3731f0a5
No related branches found
No related tags found
No related merge requests found
......@@ -15,21 +15,19 @@ def initialize(params, context)
end
def preload_content
return super if ::Feature.disabled?(:ci_parallel_remote_includes, context.project)
# It starts fetching the remote content in a separate thread and returns a promise immediately.
@content_lazy_response = Gitlab::HTTP.get(location, async: true).execute
fetch_async_content
end
def content
strong_memoize(:content) do
next fetch_remote_content if ::Feature.disabled?(:ci_parallel_remote_includes, context.project)
fetch_with_error_handling do
@content_lazy_response.value
if fetch_async_content
fetch_async_content.value
else
fetch_sync_content
end
end
end
strong_memoize_attr :content
def metadata
super.merge(
......@@ -55,13 +53,19 @@ def validate_location!
private
def fetch_remote_content
fetch_with_error_handling do
def fetch_async_content
return if ::Feature.disabled?(:ci_parallel_remote_includes, context.project)
# It starts fetching the remote content in a separate thread and returns a promise immediately.
Gitlab::HTTP.get(location, async: true).execute
end
strong_memoize_attr :fetch_async_content
def fetch_sync_content
context.logger.instrument(:config_file_fetch_remote_content) do
Gitlab::HTTP.get(location)
end
end
end
def fetch_with_error_handling
begin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment