Skip to content

Commit

Permalink
allow configuring backend on a per-request basis
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson committed Jul 12, 2021
1 parent 16419cd commit 57141e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/utilities/request.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
abstract type AbstractBackend end
struct HTTPBackend <: AbstractBackend end
struct DownloadsBackend <: AbstractBackend end

default_backend() = DownloadsBackend()

Base.@kwdef mutable struct Request
service::String
api_version::String
Expand All @@ -14,15 +20,10 @@ Base.@kwdef mutable struct Request
return_raw::Bool=false
response_dict_type::Type{<:AbstractDict}=LittleDict
downloader::Union{Nothing, Downloads.Downloader}=nothing
backend::AbstractBackend=default_backend()
end

abstract type AbstractBackend end
struct HTTPBackend <: AbstractBackend end
struct DownloadsBackend <: AbstractBackend end

default_backend() = DownloadsBackend()

submit_request(aws::AbstractAWSConfig, request::Request; return_headers::Bool=false) = submit_request(default_backend(), aws, request; return_headers)
submit_request(aws::AbstractAWSConfig, request::Request; return_headers::Bool=false) = submit_request(request.backend, aws, request; return_headers)

const AWS_DOWNLOADER = Ref{Union{Nothing, Downloader}}(nothing)
const AWS_DOWNLOAD_LOCK = ReentrantLock()
Expand Down
1 change: 1 addition & 0 deletions src/utilities/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function _extract_common_kw_args(service, args)
http_options=_pop!(args, "http_options", LittleDict{Symbol, String}()),
response_dict_type=_pop!(args, "response_dict_type", LittleDict),
downloader=_pop!(args, "downloader", nothing),
backend=_pop!(args, "backend", default_backend()),
)
end

Expand Down

0 comments on commit 57141e4

Please sign in to comment.