francescm / chat

elixir registry from Brian Storti blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chat

A registry/supervisor setup copied from Brian Storti's blog.

Installation

If available in Hex, the package can be installed by adding chat to your list of dependencies in mix.exs:

def deps do
  [
    {:chat, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/chat.

Test it in iex

Chat.Supervisor.start_link
Chat.Supervisor.start_room("room1")
Chat.Supervisor.start_room("room2")
Chat.Server.add_message("room1", "first message")
Chat.Server.add_message("room2", "second message")
Chat.Server.get_messages("room1")
Chat.Server.get_messages("room2")
Registry.whereis_name({:room_registry, "room1"}) |> Process.exit(:kill)
Chat.Server.add_message("room1", "message2")
Chat.Server.get_messages("room1")

About

elixir registry from Brian Storti blog


Languages

Language:Elixir 100.0%