Upgrading to v0.2
View Sourcev0.2.0 renames every module from Dowser.Opensearch.* to Dowser.OpenSearch.*,
following OpenSearch's own spelling. Nothing else changes: the functions, their
arguments and options, and their return values are the same as in v0.1.0.
What stays the same
The package and OTP application are still dowser_opensearch, so these are
untouched:
- the dependency name in
mix.exs; - the application environment —
config :dowser_opensearch, codec: ...,mappings: ...,mapping_failure: ...andmapping_cacher_opts: ...; - the
[:dowser_opensearch, :mapping, :failure]telemetry event.
1. Bump the dependency
def deps do
[
{:dowser_opensearch, "~> 0.2.0"}
]
endmix deps.update dowser_opensearch
2. Rename the modules in your code
Every reference to the old namespace has to change — aliases, calls, use,
@behaviour, defimpl, struct patterns and rescue clauses alike:
# Before
alias Dowser.Opensearch.Search
use Dowser.Opensearch.Repository, index: "posts"
@behaviour Dowser.Opensearch.Codec
rescue error in Dowser.Opensearch.Error -> ...
# After
alias Dowser.OpenSearch.Search
use Dowser.OpenSearch.Repository, index: "posts"
@behaviour Dowser.OpenSearch.Codec
rescue error in Dowser.OpenSearch.Error -> ...The rename is mechanical, so a search-and-replace covers it. From your project's root:
grep -rl 'Dowser\.Opensearch' lib test config \
| xargs perl -pi -e 's/Dowser\.Opensearch/Dowser.OpenSearch/g'
The pattern is case-sensitive and matches module names only, so it leaves the
:dowser_opensearch application name alone.
3. Check your configuration
The compiler warns about an undefined module in code, but not in a config file,
where a module name is just an atom. Look for the old namespace in config/
in particular — the step above covers it if you ran it there — such as a
context wiring the codec in:
config :dowser_client,
contexts: [
default: [
endpoint: "http://localhost:9200",
decoder: Dowser.OpenSearch.Codec,
encoder: Dowser.OpenSearch.Codec
]
]A config entry left on the old name compiles, then fails at runtime with an
UndefinedFunctionError on the first request that goes through it.
4. Rebuild from clean
On a case-insensitive file system (macOS's default), the compiled files of the old and new names collide, and anything still asking for an old module fails with an error such as:
Error loading module 'Elixir.Dowser.Opensearch.Search':
module name in object code is 'Elixir.Dowser.OpenSearch.Search'Throw away the dependency's previous build so it is compiled afresh:
mix deps.clean dowser_opensearch --build
mix compile
If the error persists, delete _build entirely, and restart your editor's
language server, which may still hold the old modules in memory.