File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ defmodule BookStore.Application do
1313 BookStoreWeb.Telemetry ,
1414 # Start the PubSub system
1515 { Phoenix.PubSub , name: BookStore.PubSub } ,
16+ # Start the Book Store Registry
17+ BookStore.BookRegistry . child_spec ( ) ,
1618 # Start the Endpoint (http/https)
1719 BookStoreWeb.Endpoint
1820 # Start a worker by calling: BookStore.Worker.start_link(arg)
Original file line number Diff line number Diff line change 1+ defmodule BookStore.BookRegistry do
2+ def child_spec do
3+ Registry . child_spec (
4+ keys: :unique ,
5+ name: __MODULE__ ,
6+ partitions: System . schedulers_online ( )
7+ )
8+ end
9+
10+ def lookup_book ( book_id ) do
11+ case Registry . lookup ( __MODULE__ , book_id ) do
12+ [ { book_pid , _ } ] ->
13+ { :ok , book_pid }
14+
15+ [ ] ->
16+ { :error , :not_found }
17+ end
18+ end
19+ end
You can’t perform that action at this time.
0 commit comments