MyGit

phoenixframework/phoenix_pubsub

Fork: 124 Star: 653 (更新于 2024-12-04 03:05:46)

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-12-21 00:09:00 anoma/anoma

2024-12-11 03:53:15 electric-sql/electric

2024-11-23 19:38:53 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/zoonk