mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 01:01:30 -05:00
✨ Spawn vthread on s3 internal io completion
Instead of using platform threads
This commit is contained in:
parent
746d898245
commit
471fd78174
1 changed files with 26 additions and 23 deletions
|
@ -39,6 +39,7 @@
|
||||||
software.amazon.awssdk.core.async.AsyncRequestBody
|
software.amazon.awssdk.core.async.AsyncRequestBody
|
||||||
software.amazon.awssdk.core.async.AsyncResponseTransformer
|
software.amazon.awssdk.core.async.AsyncResponseTransformer
|
||||||
software.amazon.awssdk.core.client.config.ClientAsyncConfiguration
|
software.amazon.awssdk.core.client.config.ClientAsyncConfiguration
|
||||||
|
software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption
|
||||||
software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient
|
software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient
|
||||||
software.amazon.awssdk.http.nio.netty.SdkEventLoopGroup
|
software.amazon.awssdk.http.nio.netty.SdkEventLoopGroup
|
||||||
software.amazon.awssdk.regions.Region
|
software.amazon.awssdk.regions.Region
|
||||||
|
@ -169,32 +170,34 @@
|
||||||
|
|
||||||
(defn- build-s3-client
|
(defn- build-s3-client
|
||||||
[{:keys [::region ::endpoint ::io-threads]}]
|
[{:keys [::region ::endpoint ::io-threads]}]
|
||||||
(let [aconfig (-> (ClientAsyncConfiguration/builder)
|
(let [executor (px/resolve-executor :virtual)
|
||||||
(.build))
|
aconfig (-> (ClientAsyncConfiguration/builder)
|
||||||
|
(.advancedOption SdkAdvancedAsyncClientOption/FUTURE_COMPLETION_EXECUTOR executor)
|
||||||
|
(.build))
|
||||||
|
|
||||||
sconfig (-> (S3Configuration/builder)
|
sconfig (-> (S3Configuration/builder)
|
||||||
(cond-> (some? endpoint) (.pathStyleAccessEnabled true))
|
(cond-> (some? endpoint) (.pathStyleAccessEnabled true))
|
||||||
(.build))
|
(.build))
|
||||||
|
|
||||||
thr-num (or io-threads (min 16 (px/get-available-processors)))
|
thr-num (or io-threads (min 16 (px/get-available-processors)))
|
||||||
hclient (-> (NettyNioAsyncHttpClient/builder)
|
hclient (-> (NettyNioAsyncHttpClient/builder)
|
||||||
(.eventLoopGroupBuilder (-> (SdkEventLoopGroup/builder)
|
(.eventLoopGroupBuilder (-> (SdkEventLoopGroup/builder)
|
||||||
(.numberOfThreads (int thr-num))))
|
(.numberOfThreads (int thr-num))))
|
||||||
(.connectionAcquisitionTimeout default-timeout)
|
(.connectionAcquisitionTimeout default-timeout)
|
||||||
(.connectionTimeout default-timeout)
|
(.connectionTimeout default-timeout)
|
||||||
(.readTimeout default-timeout)
|
(.readTimeout default-timeout)
|
||||||
(.writeTimeout default-timeout)
|
(.writeTimeout default-timeout)
|
||||||
(.build))
|
(.build))
|
||||||
|
|
||||||
client (let [builder (S3AsyncClient/builder)
|
client (let [builder (S3AsyncClient/builder)
|
||||||
builder (.serviceConfiguration ^S3AsyncClientBuilder builder ^S3Configuration sconfig)
|
builder (.serviceConfiguration ^S3AsyncClientBuilder builder ^S3Configuration sconfig)
|
||||||
builder (.asyncConfiguration ^S3AsyncClientBuilder builder ^ClientAsyncConfiguration aconfig)
|
builder (.asyncConfiguration ^S3AsyncClientBuilder builder ^ClientAsyncConfiguration aconfig)
|
||||||
builder (.httpClient ^S3AsyncClientBuilder builder ^NettyNioAsyncHttpClient hclient)
|
builder (.httpClient ^S3AsyncClientBuilder builder ^NettyNioAsyncHttpClient hclient)
|
||||||
builder (.region ^S3AsyncClientBuilder builder (lookup-region region))
|
builder (.region ^S3AsyncClientBuilder builder (lookup-region region))
|
||||||
builder (cond-> ^S3AsyncClientBuilder builder
|
builder (cond-> ^S3AsyncClientBuilder builder
|
||||||
(some? endpoint)
|
(some? endpoint)
|
||||||
(.endpointOverride (URI. endpoint)))]
|
(.endpointOverride (URI. endpoint)))]
|
||||||
(.build ^S3AsyncClientBuilder builder))]
|
(.build ^S3AsyncClientBuilder builder))]
|
||||||
|
|
||||||
(reify
|
(reify
|
||||||
clojure.lang.IDeref
|
clojure.lang.IDeref
|
||||||
|
|
Loading…
Add table
Reference in a new issue