MyGit

phoenixframework/phoenix_pubsub

Fork: 123 Star: 649 (更新于 2024-11-11 08:20:15)

license: MIT

Language: Elixir .

Distributed PubSub and Presence platform for the Phoenix Framework

官方网址 GitHub网址

Phoenix.PubSub

Distributed PubSub and Presence platform for the Phoenix Framework

Build Status

Usage

Add phoenix_pubsub to your list of dependencies in mix.exs:

def deps do
  [{:phoenix_pubsub, "~> 2.0"}]
end

Then start your PubSub instance:

defmodule MyApp do
  use Application

  def start(_type, _args) do
    children = [
      {Phoenix.PubSub, name: MyApp.PubSub}
    ]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

Now broadcast and subscribe:

Phoenix.PubSub.subscribe(MyApp.PubSub, "user:123")
Phoenix.PubSub.broadcast(MyApp.PubSub, "user:123", :hello_world)

Testing

Testing by default spawns nodes internally for distributed tests. To run tests that do not require clustering, exclude the clustered tag:

$ mix test --exclude clustered

If you have issues running the clustered tests try running:

$ epmd -daemon

before running the tests.

最近版本更新:(数据更新于 2024-09-22 19:16:24)

phoenixframework/phoenix_pubsub同语言 Elixir最近更新仓库

2024-10-30 02:19:37 teslamate-org/teslamate

2024-09-07 03:11:29 firezone/firezone

2024-07-07 05:20:46 elixir-lang/elixir

2024-04-11 02:26:13 zoonk/archived-zoonk

2020-06-26 19:06:09 phoenixframework/phoenix

2020-06-04 03:23:12 phoenixframework/phoenix_live_dashboard