Skip to content

Commit

Permalink
Renamed producer and consumers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalimaha committed Apr 4, 2018
1 parent 4ac0946 commit b787555
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/weather_station_manager.ex
Expand Up @@ -10,9 +10,9 @@ defmodule WeatherStationManager do
children = [
supervisor(WeatherStationManager.Repo, []),
supervisor(WeatherStationManager.Endpoint, []),
worker(UpdatesManager, []),
worker(UpdatesDBWorker, []),
worker(UpdatesTwitterWorker, [])
worker(UpdatesProducer, []),
worker(UpdatesDBConsumer, []),
worker(UpdatesTwitterConsumer, [])
]

# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/updates_controller_test.exs
Expand Up @@ -13,10 +13,10 @@ defmodule WeatherStationManager.UpdatesControllerTest do
end

test "the update is broadcasted to the workers", %{conn: conn} do
with_mock UpdatesManager, [broadcast_update: fn(_spam) -> :eggs end] do
with_mock UpdatesProducer, [broadcast_update: fn(_spam) -> :eggs end] do
post conn, "/api/updates", @update

assert called UpdatesManager.broadcast_update(@update)
assert called UpdatesProducer.broadcast_update(@update)
end
end
end
2 changes: 1 addition & 1 deletion web/controllers/updates_controller.ex
Expand Up @@ -2,7 +2,7 @@ defmodule WeatherStationManager.UpdatesController do
use WeatherStationManager.Web, :controller

def create(conn, params) do
UpdatesManager.broadcast_update(params)
UpdatesProducer.broadcast_update(params)

conn
|> put_status(201)
Expand Down
@@ -1,4 +1,4 @@
defmodule UpdatesDBWorker do
defmodule UpdatesDBConsumer do
use GenStage

require Logger
Expand All @@ -8,7 +8,7 @@ defmodule UpdatesDBWorker do
end

def init(:ok) do
{ :consumer, :ok, subscribe_to: [ UpdatesManager ] }
{ :consumer, :ok, subscribe_to: [ UpdatesProducer ] }
end

def handle_events(events, _from, state) do
Expand Down
@@ -1,4 +1,4 @@
defmodule UpdatesManager do
defmodule UpdatesProducer do
use GenStage

require Logger
Expand Down
@@ -1,4 +1,4 @@
defmodule UpdatesTwitterWorker do
defmodule UpdatesTwitterConsumer do
use GenStage

require Logger
Expand All @@ -8,7 +8,7 @@ defmodule UpdatesTwitterWorker do
end

def init(:ok) do
{ :consumer, :ok, subscribe_to: [ UpdatesManager ] }
{ :consumer, :ok, subscribe_to: [ UpdatesProducer ] }
end

def handle_events(events, _from, state) do
Expand Down

0 comments on commit b787555

Please sign in to comment.