Commit graph

83 commits

Author SHA1 Message Date
Alexander Strizhakov
1c57ef4498
default pool for tz_data client 2020-09-02 10:33:43 +03:00
Alexander Strizhakov
5e8adf91b4
don't overwrite passed pool option in http clients 2020-09-02 09:04:23 +03:00
Alexander Strizhakov
c17d83cd73
improvements and fixes for http requests
- fix for gun worker termination in some circumstances
- pool for http clients (ex_aws, tzdata)
- default pool timeouts for gun
- gun retries on gun_down messages
- s3 upload timeout if streaming enabled
2020-09-02 09:04:23 +03:00
Roman Chvanikov
4bf44b7d65 Don't override user-agent header if it's been set 2020-08-01 10:04:25 +03:00
href
4bac25e6f5 Don't enable Pleroma.HTTP.Middleware.FollowRedirects unless Gun is used 2020-07-18 13:17:38 +02:00
href
6d583bcc3b Set a default timeout for Gun adapter timeout 2020-07-15 15:26:35 +03:00
href
ce1a42bd04 Simplify TLS opts
- `verify_fun` is not useful now
- use `customize_check_hostname` (OTP 20+ so OK)
- `partial_chain` is useless as of OTP 21.1 (wasn't there, but hackney/..
uses it)
2020-07-15 15:26:35 +03:00
href
6a0f2bdf8c Ensure connections error get known by the caller 2020-07-15 15:26:35 +03:00
rinpatch
9b73c35ca8 Request limiter setup: consider {:error, :existing} a success
When the application restarts (which happens after certain config
changes), the limiters are not destroyed, so `ConcurrentLimiter.new`
will produce {:error, :existing}
2020-07-15 15:26:35 +03:00
rinpatch
37f1e781cb Gun adapter helper: fix wildcard cert issues on OTP 23
See https://bugs.erlang.org/browse/ERL-1260 for more info.

The ssl match function is basically copied from mint, except
that `:string.lowercase/1` was replaced by `:string.casefold`.
It was a TODO in mint's code, so might as well do it since we don't need
to support OTP <20.

Closes #1834
2020-07-15 15:26:35 +03:00
rinpatch
00926a63fb Adapter Helper: Use built-in ip address type 2020-07-15 15:26:35 +03:00
rinpatch
4128e3a84a HTTP: Implement max request limits 2020-07-15 15:26:35 +03:00
rinpatch
94c8f3cfaf Use a custom pool-aware FollowRedirects middleware 2020-07-15 15:26:35 +03:00
rinpatch
58a4f350a8 Refactor gun pooling and simplify adapter option insertion
This patch refactors gun pooling to use Elixir process registry and
simplifies adapter option insertion.

Having the pool use process registry instead of a GenServer has a number of advantages:
- Simpler code: the initial implementation adds about half the lines of code it deletes
- Concurrency: unlike a GenServer, ETS-based registry can handle multiple checkout/checkin
requests at the same time
- Precise and easy idle connection clousure: current proposal for closing idle connections in
the GenServer-based pool needs to filter through all connections once a minute and compare their
last active time with closing time. With Elixir process registry this can be done
by just using `Process.send_after`/`Process.cancel_timer` in the worker process.
- Lower memory footprint: In my tests `gun-memory-leak` branch uses about 290mb on peak load (250 connections)
and 235mb on idle (5-10 connections). Registry-based pool uses 210mb on idle and 240mb on peak load
2020-07-15 15:17:27 +03:00
Maksim Pechnikov
439a1a0218 added wrapper Pleroma.HTTP for ExAws.S3 2020-06-25 07:12:29 +03:00
Maksim Pechnikov
721fc7c554 added wrapper Pleroma.HTTP for Tzdata.HTTPClient 2020-06-24 09:12:32 +03:00
rinpatch
0cb7b0ea84 hackney adapter helper: support tlsv1.3 and remove custom opts
- partitial_chain is no longer exported, but it seems to be the default anyway.
- The bug that caused sni to not be sent automatically seems to be fixed -
https://github.com/benoitc/hackney/issues/612
2020-05-30 15:36:55 +03:00
Alexander Strizhakov
98ed0d1c4b
more clean up 2020-03-13 09:37:57 +03:00
Alexander Strizhakov
1306b92997
clean up 2020-03-12 18:29:07 +03:00
Alexander Strizhakov
f39e1b9eff
add verify tls_opts only when we open connection
for other requests tesla will add tls_opts
2020-03-10 15:54:11 +03:00
Alexander Strizhakov
78282dc983
little polishing 2020-03-06 21:24:19 +03:00
Alexander Strizhakov
c93c3096d5
little refactor 2020-03-06 21:04:18 +03:00
Alexander Strizhakov
f0753eed0f
removing try block in tesla request
added mocks for tests which fail with Tesla.Mock.Error
2020-03-05 17:31:06 +03:00
Alexander Strizhakov
d6bebd4f9c
moving some logic to tesla adapter
- checking original inside gun adapter
- flushing streams on max_body error
2020-03-04 18:13:24 +03:00
Mark Felder
d9c5ae7c09 Update Copyrights for gun related files 2020-03-03 17:16:24 -06:00
Mark Felder
4427161ca3 Merge branch 'develop' into gun 2020-03-03 17:15:49 -06:00
Mark Felder
05da5f5cca Update Copyrights 2020-03-03 16:44:49 -06:00
Alexander Strizhakov
f98ee730f0
adapter renaming to adapter_helper 2020-03-03 18:53:44 +03:00
Alexander Strizhakov
8854770fc4
retry and retry_timeout settings default change 2020-03-03 18:01:35 +03:00
Alexander Strizhakov
1ad34bfdba
no try block in checkout connection 2020-03-03 17:44:04 +03:00
Alexander Strizhakov
24bf5c4e89
remove try block from pool request 2020-03-03 17:27:56 +03:00
Alexander Strizhakov
aaa879ce75
proxy parsing errors 2020-03-03 17:27:22 +03:00
Alexander Strizhakov
6ebf389d6e
poolboy timeout fix 2020-03-03 16:51:49 +03:00
Alexander Strizhakov
e605e79df9
simplification of formatting host method
case for format_proxy method
2020-03-03 16:42:03 +03:00
Alexander Strizhakov
ee8071f0d5
removing unused method 2020-03-03 15:12:09 +03:00
Alexander Strizhakov
05429730e4
unnecessary with 2020-03-03 15:11:48 +03:00
Alexander Strizhakov
a21a66972f Apply suggestion to lib/pleroma/http/http.ex 2020-03-03 09:52:01 +00:00
Alexander Strizhakov
614e3934f9 Apply suggestion to lib/pleroma/http/http.ex 2020-03-03 09:50:42 +00:00
Alexander Strizhakov
d30ff35d94 Apply suggestion to lib/pleroma/http/request_builder.ex 2020-03-03 09:46:53 +00:00
Alexander Strizhakov
a3ad028973 Apply suggestion to lib/pleroma/http/adapter.ex 2020-03-03 09:34:36 +00:00
Alexander Strizhakov
8efae966b1
open conn in separate task 2020-02-24 19:56:27 +03:00
Alexander Strizhakov
d44f9e3b6c
fix for timeout clause 2020-02-21 16:56:55 +03:00
Alexander Strizhakov
f604f9e470
hackney pool timeout 2020-02-21 14:33:55 +03:00
Alexander Strizhakov
6806df80dd
don't log info ssl messages 2020-02-21 14:28:16 +03:00
Alexander Strizhakov
ad8f26c0a4
more info in Connections.checkin timout errors 2020-02-21 12:53:40 +03:00
Alexander Strizhakov
c9db0507f8
removing retry option and changing some logger messages levels 2020-02-19 12:26:57 +03:00
Mark Felder
7d73e7a09a Spelling 2020-02-18 09:18:09 -06:00
Alexander Strizhakov
514c899275
adding gun adapter 2020-02-18 08:19:01 +03:00
Sergey Suprunenko
02dc651828 Handle 303 redirects 2019-07-28 20:24:39 +00:00
rinpatch
b001b8891a Merge the default options with custom ones in ReverseProxy and
Pleroma.HTTP
2019-07-12 23:52:26 +03:00