Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/thrift/binary/framed/protocol_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
Expand Down
8 changes: 6 additions & 2 deletions lib/thrift/binary/framed/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
"""
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,7 +87,7 @@ defmodule Thrift.Mixfile do

# Runtime
{:connection, "~> 1.0"},
{:ranch, "~> 1.6"},
{:ranch, ">= 2.1.0 and < 2.3.0"},
{:telemetry, "~> 1.0"}
]
end
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.1", "fc2bb0e800efbeab8ff82eb325450b9c08653b14c3f69e8b09bbea304973105d", [:make, :rebar3], [], "hexpm", "55f05cce20ec2da1d90de5d5981afb93dbfc01325fc7e933189aa5c62f037c24"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
Expand Down