From b522537b6be81046d4ce8f62d78b7ea19902d635 Mon Sep 17 00:00:00 2001 From: Nathan Monteleone Date: Thu, 8 Oct 2026 17:58:14 -0500 Subject: [PATCH 1/3] Update ranch --- .github/workflows/ci.yml | 1 + mix.exs | 4 ++-- mix.lock | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98b7a989..81b5c8d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ on: branches: - master - 2.0.0-dev.2 + - 2.0.0-dev.3 pull_request: branches: - master diff --git a/mix.exs b/mix.exs index 48fdaaa2..3a7b928b 100644 --- a/mix.exs +++ b/mix.exs @@ -11,7 +11,7 @@ defmodule Thrift.Mixfile do Forked by Simpli.fi for internal versioning """ - @version "2.0.0-dev.2" + @version "2.0.0-dev.3" @project_url "https://github.com/simplifi/elixir-thrift" def project do @@ -87,7 +87,7 @@ defmodule Thrift.Mixfile do # Runtime {:connection, "~> 1.0"}, - {:ranch, "~> 1.6"}, + {:ranch, "~> 2.1"}, {:telemetry, "~> 1.0"} ] end diff --git a/mix.lock b/mix.lock index 423762a6..e1050d40 100644 --- a/mix.lock +++ b/mix.lock @@ -19,7 +19,7 @@ "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, - "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, + "ranch": {:hex, :ranch, "2.3.0", "7de7b041a9a6a5091a3aa5898d66c0564be671d87db4f9d63b1b5ee775b097df", [:make, :rebar3], [], "hexpm", "6168ec49409d982f7cfbd83dd083144f6cbe67caa4036551d2f0a3ad67c9d023"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, From 969ec44df115610023b4498050d02d3d9c7acd9e Mon Sep 17 00:00:00 2001 From: Nathan Monteleone Date: Wed, 14 Oct 2026 16:44:09 -0500 Subject: [PATCH 2/3] update for new ranch syntax --- lib/thrift/binary/framed/protocol_handler.ex | 12 +++++------- lib/thrift/binary/framed/server.ex | 8 ++++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/thrift/binary/framed/protocol_handler.ex b/lib/thrift/binary/framed/protocol_handler.ex index 839485bd..d2d75601 100644 --- a/lib/thrift/binary/framed/protocol_handler.ex +++ b/lib/thrift/binary/framed/protocol_handler.ex @@ -28,18 +28,16 @@ defmodule Thrift.Binary.Framed.ProtocolHandler do :recv_timeout ] - @spec start_link(reference, port, transport, {module, module, transport_opts, [SSL.option()]}) :: + @spec start_link(reference, transport, {module, module, transport_opts, [SSL.option()]}) :: GenServer.on_start() def start_link( ref, - socket, transport, {server_module, handler_module, on_connect, transport_opts, ssl_opts} ) do pid = spawn_link(__MODULE__, :init, [ ref, - socket, transport, server_module, handler_module, @@ -51,13 +49,13 @@ defmodule Thrift.Binary.Framed.ProtocolHandler do {:ok, pid} end - @dialyzer {:nowarn_function, init: 8} - @spec init(reference, port, :ranch_tcp, module, module, function, :ranch_tcp.opts(), [ + @dialyzer {:nowarn_function, init: 7} + @spec init(reference, :ranch_tcp, module, module, function, :ranch_tcp.opts(), [ SSL.option() ]) :: :ok | no_return - def init(ref, socket, :ranch_tcp, server_module, handler_module, on_connect, tcp_opts, ssl_opts) do - :ok = :ranch.accept_ack(ref) + def init(ref, :ranch_tcp, server_module, handler_module, on_connect, tcp_opts, ssl_opts) do + {:ok, socket} = :ranch.handshake(ref) {recv_timeout, tcp_opts} = Keyword.pop(tcp_opts, :recv_timeout, @default_timeout) :ok = :inet.setopts(socket, Keyword.put(tcp_opts, :packet, 4)) diff --git a/lib/thrift/binary/framed/server.ex b/lib/thrift/binary/framed/server.ex index 7195276d..2ce54745 100644 --- a/lib/thrift/binary/framed/server.ex +++ b/lib/thrift/binary/framed/server.ex @@ -53,15 +53,15 @@ defmodule Thrift.Binary.Framed.Server do transport_opts = opts - |> Keyword.get(:transport_opts, []) + |> Keyword.get(:transport_opts, %{}) |> add_port_to_transport_opts(port) + |> add_num_acceptors(worker_count) validate_ssl_configuration!(ssl_opts) listener = :ranch.child_spec( name, - worker_count, :ranch_tcp, transport_opts, Thrift.Binary.Framed.ProtocolHandler, @@ -87,6 +87,10 @@ defmodule Thrift.Binary.Framed.Server do Map.update(transport_opts, :socket_opts, [port: port], &Keyword.put(&1, :port, port)) end + defp add_num_acceptors(transport_opts, num_acceptors) when is_map(transport_opts) do + Map.put_new(transport_opts, :num_acceptors, num_acceptors) + end + @doc """ Stops the server. """ From bbf1bd022683ca66f6c2da0dc71d7706a084a12e Mon Sep 17 00:00:00 2001 From: Nathan Monteleone Date: Wed, 14 Oct 2026 17:03:27 -0500 Subject: [PATCH 3/3] constrain ranch to 2.1 or 2.2. 2.3 adds incompatibilities with older elixir --- mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 3a7b928b..f0b05a6e 100644 --- a/mix.exs +++ b/mix.exs @@ -87,7 +87,7 @@ defmodule Thrift.Mixfile do # Runtime {:connection, "~> 1.0"}, - {:ranch, "~> 2.1"}, + {:ranch, ">= 2.1.0 and < 2.3.0"}, {:telemetry, "~> 1.0"} ] end diff --git a/mix.lock b/mix.lock index e1050d40..d491fbe9 100644 --- a/mix.lock +++ b/mix.lock @@ -19,7 +19,7 @@ "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, - "ranch": {:hex, :ranch, "2.3.0", "7de7b041a9a6a5091a3aa5898d66c0564be671d87db4f9d63b1b5ee775b097df", [:make, :rebar3], [], "hexpm", "6168ec49409d982f7cfbd83dd083144f6cbe67caa4036551d2f0a3ad67c9d023"}, + "ranch": {:hex, :ranch, "2.2.1", "fc2bb0e800efbeab8ff82eb325450b9c08653b14c3f69e8b09bbea304973105d", [:make, :rebar3], [], "hexpm", "55f05cce20ec2da1d90de5d5981afb93dbfc01325fc7e933189aa5c62f037c24"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},