Skip to content

Commit a7546d5

Browse files
committed
fix(cache): explain how to fix a missing Nebulex.Adapter.CompositeKV
1 parent a95b0b4 commit a7546d5

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎lib/nebulex/cache/options.ex‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ defmodule Nebulex.Cache.Options do
461461
behaviour ->
462462
msg =
463463
"#{target} expects the option value #{inspect(value)} " <>
464-
"to list #{inspect(behaviour)} as a behaviour"
464+
"to list #{inspect(behaviour)} as a behaviour" <> behaviour_hint(behaviour)
465465

466466
{:error, msg}
467467
end
@@ -472,6 +472,17 @@ defmodule Nebulex.Cache.Options do
472472
{:error, "expected a module, got: #{inspect(value)}"}
473473
end
474474

475+
# Nebulex v3.1 made Nebulex.Adapter.CompositeKV mandatory, so an adapter
476+
# built for v3.0 fails here; tell the user how to fix it
477+
defp behaviour_hint(Nebulex.Adapter.CompositeKV) do
478+
". Add `use Nebulex.Adapter.CompositeKV` to the adapter, " <>
479+
"or upgrade it to a version built for Nebulex v3.1 or later"
480+
end
481+
482+
defp behaviour_hint(_behaviour) do
483+
""
484+
end
485+
475486
## Extras
476487

477488
@doc """

‎test/nebulex/cache/supervisor_test.exs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ defmodule Nebulex.Cache.SupervisorTest do
8686
msg =
8787
"invalid value for :adapter option: Nebulex.Cache expects the option value " <>
8888
"Nebulex.Cache.SupervisorTest.NoCompositeKVAdapter to list " <>
89-
"Nebulex.Adapter.CompositeKV as a behaviour"
89+
"Nebulex.Adapter.CompositeKV as a behaviour. Add " <>
90+
"`use Nebulex.Adapter.CompositeKV` to the adapter, or upgrade it to " <>
91+
"a version built for Nebulex v3.1 or later"
9092

9193
assert_raise NimbleOptions.ValidationError, msg, fn ->
9294
defmodule NoCompositeKVAdapter do

0 commit comments

Comments
 (0)