return name of performance

and don't send any empty performances
parent bef3e50a
......@@ -12,6 +12,7 @@ defmodule Grengine.Conductor do
|> Enum.map( fn perf ->
do_performance(perf)
end)
|> Enum.reject( fn val -> is_nil(val) end)
end
......@@ -24,7 +25,11 @@ defmodule Grengine.Conductor do
def do_performance(perf) do
[{_n, _l, {:performance, name}}, _pid, :undefined] = perf
Performance.get_values(name)
values = Performance.get_values(name)
case length( Map.keys(values)) do
0 -> nil
_ -> %{name => Performance.get_values(name)}
end
end
......
defmodule Grengine.Grain do
alias Grengine.{Grain, Parameter}
def start_link() do
......@@ -21,7 +20,7 @@ defmodule Grengine.Grain do
end
def to_string(grain) do
def to_string(_grain) do
"{}"
end
......
......@@ -3,7 +3,6 @@ defmodule Grengine.Performance do
use GenServer
alias Grengine.Performance
alias Grengine.Grain
def start_link(name) do
......@@ -28,7 +27,7 @@ defmodule Grengine.Performance do
# SERVER
def init(params) do
def init(_params) do
{:ok, grain} = Grain.start_link()
{:ok, grain}
end
......@@ -50,7 +49,7 @@ defmodule Grengine.Performance do
{:reply, Grain.get_values(grain), grain}
end
def to_string(performance) do
def to_string(_performance) do
"Performance"
end
......
......@@ -2,7 +2,7 @@ defmodule ConductorTest do
use ExUnit.Case, async: true
alias Grengine.{Conductor, PerformanceSupervisor}
alias Grengine.{Conductor, Performance, PerformanceSupervisor}
describe "finding all performances" do
......@@ -10,6 +10,7 @@ defmodule ConductorTest do
PerformanceSupervisor.start_link
PerformanceSupervisor.start_performance("foo")
PerformanceSupervisor.start_performance("bar")
Performance.set_values("foo", %{s1: 42})
:ok
end
......@@ -24,6 +25,7 @@ defmodule ConductorTest do
test "handle single performance" do
values = Conductor.perform()
assert is_list(values)
assert length(values) == 1
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment