Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise on unknown conn opts when starting cluster #361

Merged
merged 1 commit into from
Mar 27, 2024
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
1 change: 1 addition & 0 deletions lib/xandra/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ defmodule Xandra.Cluster do
def start_link(options) when is_list(options) do
{cluster_opts, connection_opts} = Keyword.split(options, @start_link_opts_schema_keys)
cluster_opts = NimbleOptions.validate!(cluster_opts, @start_link_opts_schema)
connection_opts = NimbleOptions.validate!(connection_opts, Xandra.start_link_opts_schema())
Pool.start_link(cluster_opts, connection_opts)
end

Expand Down
6 changes: 6 additions & 0 deletions test/xandra/cluster_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ defmodule Xandra.ClusterTest do
Xandra.Cluster.start_link(nodes: ["example.com:9042"], name: "something something")
end
end

test "raises with an option that is not valid for the cluster and for the conn" do
assert_raise NimbleOptions.ValidationError, ~r"unknown options \[:port\]", fn ->
Xandra.Cluster.start_link(port: 9042)
end
end
end

describe "start_link/1" do
Expand Down
4 changes: 2 additions & 2 deletions test/xandra_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ defmodule XandraTest do
end)
|> Enum.map(fn {:ok, result} -> result end)

# The first and second calls succeeds, but the third call fails because it goes over
# The first call succeeds, but the second call fails because it goes over
# the max concurrent conns.
assert [
{1, {:ok, %Xandra.Page{}}},
{2, {:error, %ConnectionError{reason: :too_many_concurrent_requests} = error}}
] = results
] = Enum.sort_by(results, &elem(&1, 0))

assert Exception.message(error) =~ "this connection has too many requests in flight"
end
Expand Down
Loading