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

Implement Mongo.Repo.child_spec/1 #240

Merged
merged 1 commit into from
Aug 29, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,12 @@ config :my_app, MyApp.Repo,
queue_target: 5_000
```

Finally, we can add the `Mongo` instance to our application supervision tree:
Finally, we can add the `Mongo.Repo` instance to our application supervision tree:

```elixir
children = [
# ...
{Mongo, MyApp.Repo.config()},
MyApp.Repo,
# ...
]
```
Expand Down
8 changes: 6 additions & 2 deletions lib/mongo/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ defmodule Mongo.Repo do

For a complete list of configuration options take a look at `Mongo`.

Finally we can add the `Mongo` instance to our application supervision tree
Finally we can add the `Mongo.Repo` instance to our application supervision tree

children = [
# ...
{Mongo, MyApp.Repo.config()},
MyApp.Repo,
# ...
]

Expand Down Expand Up @@ -60,6 +60,10 @@ defmodule Mongo.Repo do
|> Keyword.put_new(:name, @topology)
end

def child_spec(_opts) do
Mongo.child_spec(config())
end

unless @read_only do
def insert(%{__struct__: module} = doc, opts \\ []) do
collection = module.__collection__(:collection)
Expand Down
2 changes: 1 addition & 1 deletion test/mongo/repo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Mongo.RepoTest do
end

setup do
assert {:ok, pid} = start_supervised({Mongo, MyRepo.config()})
assert {:ok, pid} = start_supervised(MyRepo)
Mongo.drop_database(pid, nil, w: 3)
{:ok, [pid: pid]}
end
Expand Down
Loading