Add option to modify HTTP pool size develop
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Fri, 16 Dec 2022 18:33:00 +0000 (18:33 +0000)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Fri, 16 Dec 2022 18:33:00 +0000 (18:33 +0000)
CHANGELOG.md
config/config.exs
config/description.exs
lib/pleroma/application.ex
lib/pleroma/config/transfer_task.ex
lib/pleroma/http/adapter_helper.ex
test/instance_static/emoji/dump_pack/pack.json [deleted file]
test/pleroma/http/adapter_helper_test.exs

index c69eb4c82f96551d6cc8cccb712e06d370aab1d0..6dcbc4b14b8eee829e23d153988058053f3e4291 100644 (file)
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
 ### Added
 - Prometheus metrics exporting from `/api/v1/akkoma/metrics`
+- Ability to alter http pool size
 
 ### Removed
 - Non-finch HTTP adapters
index 4c39d52b35d4e801d73ebd585e3da7f674a1b30d..48290fb058d4753ddb8084793c4e17116df8c105 100644 (file)
@@ -179,6 +179,7 @@ config :pleroma, :http,
   receive_timeout: :timer.seconds(15),
   proxy_url: nil,
   user_agent: :default,
+  pool_size: 50,
   adapter: []
 
 config :pleroma, :instance,
index 1059039e7afaf77c050c0268563b2465ae9d6dd8..eb61c7218f83e0bef9c4190deedffbd38add67db 100644 (file)
@@ -2661,6 +2661,13 @@ config :pleroma, :config_description, [
           "What user agent to use. Must be a string or an atom `:default`. Default value is `:default`.",
         suggestions: ["Pleroma", :default]
       },
+      %{
+        key: :pool_size,
+        type: :integer,
+        description:
+          "Number of concurrent outbound HTTP requests to allow. Default 50.",
+        suggestions: [50]
+      },
       %{
         key: :adapter,
         type: :keyword,
index 02336d6d1f26acb957c8393c3e8e3e96f461ea24..26b500dc832eccd63241fcf5981b2aa84915f869 100644 (file)
@@ -259,10 +259,12 @@ defmodule Pleroma.Application do
   defp http_children do
     proxy_url = Config.get([:http, :proxy_url])
     proxy = Pleroma.HTTP.AdapterHelper.format_proxy(proxy_url)
+    pool_size = Config.get([:http, :pool_size])
 
     config =
       [:http, :adapter]
       |> Config.get([])
+      |> Pleroma.HTTP.AdapterHelper.add_pool_size(pool_size)
       |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy_pool(proxy)
       |> Keyword.put(:name, MyFinch)
 
index 2e4bcb0ee02b7a3c14643d7f4e63c5710ff57fd6..4fcaab4a59c0f96686c83030d44bb1758505f0ee 100644 (file)
@@ -25,7 +25,9 @@ defmodule Pleroma.Config.TransferTask do
     do: [
       {:pleroma, Pleroma.Captcha, [:seconds_valid]},
       {:pleroma, Pleroma.Upload, [:proxy_remote]},
-      {:pleroma, :instance, [:upload_limit]}
+      {:pleroma, :instance, [:upload_limit]},
+      {:pleroma, :http, [:pool_size]},
+      {:pleroma, :http, [:proxy_url]}
     ]
 
   def start_link(restart_pleroma? \\ true) do
index 77b854b5d0440437447b4125804a10bde673623a..e5da3ffa8f03e9578f18152b5f238b1a81db91ab 100644 (file)
@@ -47,6 +47,13 @@ defmodule Pleroma.HTTP.AdapterHelper do
     |> put_in([:pools, :default, :conn_opts, :proxy], proxy)
   end
 
+  def add_pool_size(opts, pool_size) do
+    opts
+    |> maybe_add_pools()
+    |> maybe_add_default_pool()
+    |> put_in([:pools, :default, :size], pool_size)
+  end
+
   defp maybe_add_pools(opts) do
     if Keyword.has_key?(opts, :pools) do
       opts
diff --git a/test/instance_static/emoji/dump_pack/pack.json b/test/instance_static/emoji/dump_pack/pack.json
deleted file mode 100644 (file)
index 3ca753b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-"files": { },
-"pack": {
-"description": "Dump pack", "homepage": "https://pleroma.social",
-"license": "Test license", "share-files": true
-}}
index ba09f3422ba07095994b3108c583cc9f53ce50a6..cd7491e9a42fc9480337d66fbb4759c675ee5ecf 100644 (file)
@@ -66,4 +66,11 @@ defmodule Pleroma.HTTP.AdapterHelperTest do
       assert options[:receive_timeout] == 20_000
     end
   end
+
+  describe "pool size settings" do
+    test "should get set" do
+      options = AdapterHelper.add_pool_size([], 50)
+      assert options[:pools][:default][:size] == 50
+    end
+  end
 end