Current section
40 Versions
Jump to
Current section
40 Versions
Compare versions
10
files changed
+113
additions
-24
deletions
| @@ -1,5 +1,12 @@ | |
| 1 1 | # Changelog |
| 2 2 | |
| 3 | + ## v0.11.0 (2022-03-28) |
| 4 | + |
| 5 | + - Add `:pool_max_idle_time` option to enable termination of idle HTTP/1 pools. |
| 6 | + - Add `:conn_max_idle_time` and deprecate `:max_idle_time` to make the distinction from |
| 7 | + `:pool_max_idle_time` more obvious. |
| 8 | + - Add headers and status code to Telemetry events. |
| 9 | + |
| 3 10 | ## v0.10.2 (2022-01-12) |
| 4 11 | |
| 5 12 | - Complete the typespec for Finch.Request.t() |
| @@ -54,8 +54,8 @@ children = [ | |
| 54 54 | |
| 55 55 | Pools will be started for each configured `{scheme, host, port}` when Finch is started. |
| 56 56 | For any unconfigured `{scheme, host, port}`, the pool will be started the first time |
| 57 | - it is requested. Note pools are not automatically terminated if they are unused, so |
| 58 | - Finch is best suited when you are requesting a known list of static hosts. |
| 57 | + it is requested. Note pools are not automatically terminated by default, if you need to |
| 58 | + terminate them after some idle time, use the `pool_max_idle_time` option (available only for HTTP1 pools). |
| 59 59 | |
| 60 60 | ## Telemetry |
| 61 61 | |
| @@ -104,7 +104,7 @@ The package can be installed by adding `finch` to your list of dependencies in ` | |
| 104 104 | ```elixir |
| 105 105 | def deps do |
| 106 106 | [ |
| 107 | - {:finch, "~> 0.10"} |
| 107 | + {:finch, "~> 0.11"} |
| 108 108 | ] |
| 109 109 | end |
| 110 110 | ``` |
| @@ -4,12 +4,12 @@ | |
| 4 4 | {<<"elixir">>,<<"~> 1.7">>}. |
| 5 5 | {<<"files">>, |
| 6 6 | [<<"lib">>,<<"lib/finch">>,<<"lib/finch/error.ex">>,<<"lib/finch/http1">>, |
| 7 | - <<"lib/finch/http1/conn.ex">>,<<"lib/finch/http1/pool.ex">>, |
| 8 | - <<"lib/finch/http2">>,<<"lib/finch/http2/pool.ex">>, |
| 9 | - <<"lib/finch/http2/request_stream.ex">>,<<"lib/finch/pool.ex">>, |
| 7 | + <<"lib/finch/http1/pool.ex">>,<<"lib/finch/http1/conn.ex">>, |
| 8 | + <<"lib/finch/http2">>,<<"lib/finch/http2/request_stream.ex">>, |
| 9 | + <<"lib/finch/http2/pool.ex">>,<<"lib/finch/pool.ex">>, |
| 10 10 | <<"lib/finch/response.ex">>,<<"lib/finch/ssl.ex">>, |
| 11 | - <<"lib/finch/telemetry.ex">>,<<"lib/finch/pool_manager.ex">>, |
| 12 | - <<"lib/finch/request.ex">>,<<"lib/finch.ex">>,<<".formatter.exs">>, |
| 11 | + <<"lib/finch/request.ex">>,<<"lib/finch/pool_manager.ex">>, |
| 12 | + <<"lib/finch/telemetry.ex">>,<<"lib/finch.ex">>,<<".formatter.exs">>, |
| 13 13 | <<"mix.exs">>,<<"README.md">>,<<"LICENSE.md">>,<<"CHANGELOG.md">>]}. |
| 14 14 | {<<"licenses">>,[<<"MIT">>]}. |
| 15 15 | {<<"links">>,[{<<"GitHub">>,<<"https://github.com/sneako/finch">>}]}. |
| @@ -29,7 +29,7 @@ | |
| 29 29 | {<<"name">>,<<"nimble_pool">>}, |
| 30 30 | {<<"optional">>,false}, |
| 31 31 | {<<"repository">>,<<"hexpm">>}, |
| 32 | - {<<"requirement">>,<<"~> 0.2">>}], |
| 32 | + {<<"requirement">>,<<"~> 0.2.6">>}], |
| 33 33 | [{<<"app">>,<<"nimble_options">>}, |
| 34 34 | {<<"name">>,<<"nimble_options">>}, |
| 35 35 | {<<"optional">>,false}, |
| @@ -40,4 +40,4 @@ | |
| 40 40 | {<<"optional">>,false}, |
| 41 41 | {<<"repository">>,<<"hexpm">>}, |
| 42 42 | {<<"requirement">>,<<"~> 0.4 or ~> 1.0">>}]]}. |
| 43 | - {<<"version">>,<<"0.10.2">>}. |
| 43 | + {<<"version">>,<<"0.11.0">>}. |
| @@ -47,7 +47,7 @@ defmodule Finch do | |
| 47 47 | The maximum number of milliseconds an HTTP1 connection is allowed to be idle \ |
| 48 48 | before being closed during a checkout attempt. |
| 49 49 | """, |
| 50 | - default: :infinity |
| 50 | + deprecated: "Use :conn_max_idle_time instead." |
| 51 51 | ], |
| 52 52 | conn_opts: [ |
| 53 53 | type: :keyword_list, |
| @@ -57,6 +57,24 @@ defmodule Finch do | |
| 57 57 | used to configure proxying, https settings, or connect timeouts. |
| 58 58 | """, |
| 59 59 | default: [] |
| 60 | + ], |
| 61 | + pool_max_idle_time: [ |
| 62 | + type: :timeout, |
| 63 | + doc: """ |
| 64 | + The maximum number of milliseconds that a pool can be idle before being terminated, used only by HTTP1 pools. \ |
| 65 | + This options is forwarded to NimblePool and it starts and idle verification cycle that may impact \ |
| 66 | + performance if misused. For instance setting a very low timeout may lead to pool restarts. \ |
| 67 | + For more information see NimblePool's `handle_ping/2` documentation. |
| 68 | + """, |
| 69 | + default: :infinity |
| 70 | + ], |
| 71 | + conn_max_idle_time: [ |
| 72 | + type: :timeout, |
| 73 | + doc: """ |
| 74 | + The maximum number of milliseconds an HTTP1 connection is allowed to be idle \ |
| 75 | + before being closed during a checkout attempt. |
| 76 | + """, |
| 77 | + default: :infinity |
| 60 78 | ] |
| 61 79 | ] |
| 62 80 | |
| @@ -183,7 +201,8 @@ defmodule Finch do | |
| 183 201 | count: valid[:count], |
| 184 202 | conn_opts: conn_opts, |
| 185 203 | protocol: valid[:protocol], |
| 186 | - max_idle_time: to_native(valid[:max_idle_time]) |
| 204 | + conn_max_idle_time: to_native(valid[:max_idle_time] || valid[:conn_max_idle_time]), |
| 205 | + pool_max_idle_time: valid[:pool_max_idle_time] |
| 187 206 | } |
| 188 207 | end |
| @@ -13,7 +13,7 @@ defmodule Finch.Conn do | |
| 13 13 | opts: opts.conn_opts, |
| 14 14 | parent: parent, |
| 15 15 | last_checkin: System.monotonic_time(), |
| 16 | - max_idle_time: opts.max_idle_time, |
| 16 | + max_idle_time: opts.conn_max_idle_time, |
| 17 17 | mint: nil |
| 18 18 | } |
| 19 19 | end |
| @@ -103,7 +103,8 @@ defmodule Finch.Conn do | |
| 103 103 | host: conn.host, |
| 104 104 | port: conn.port, |
| 105 105 | path: full_path, |
| 106 | - method: req.method |
| 106 | + method: req.method, |
| 107 | + headers: req.headers |
| 107 108 | } |
| 108 109 | |
| 109 110 | extra_measurements = %{idle_time: idle_time} |
| @@ -175,7 +176,8 @@ defmodule Finch.Conn do | |
| 175 176 | |
| 176 177 | defp handle_response(response, conn, metadata, start_time, extra_measurements) do |
| 177 178 | case response do |
| 178 | - {:ok, mint, acc} -> |
| 179 | + {:ok, mint, {status, headers, _} = acc} -> |
| 180 | + metadata = Map.merge(metadata, %{status: status, headers: headers}) |
| 179 181 | Telemetry.stop(:response, start_time, metadata, extra_measurements) |
| 180 182 | {:ok, %{conn | mint: mint}, acc} |
Loading more files…