Compare commits
No commits in common. "ea03dccf53bb7e9dac9e6c8d3aafef1df84874a3" and "8951df42824420cae2464e77f17c63a7651f2d96" have entirely different histories.
ea03dccf53
...
8951df4282
7 changed files with 8 additions and 65 deletions
|
|
@ -11,13 +11,11 @@ defmodule Scopes.CSys.Application do
|
|||
def start(type, args) do
|
||||
IO.puts("Hello CSys")
|
||||
Logger.info(Util.show [type, args])
|
||||
# input_neurons = Environ.create_input
|
||||
IO.inspect Scopes.CSys.Server.Endpoint.child_spec(input: %{[:csys, :s01] => "dummy"})
|
||||
children = [
|
||||
#Scopes.CSys.Server.Endpoint
|
||||
{Scopes.CSys.Server.Endpoint, input: %{[:csys, :s01] => "dummy"}}
|
||||
#Scopes.Web.Server.Endpoint
|
||||
Scopes.CSys.Server.Endpoint
|
||||
]
|
||||
opts = [strategy: :one_for_one, name: Scopes.CSys.Supervisor]
|
||||
opts = [strategy: :one_for_one, name: Scopes.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
defmodule Scopes.CSys.Server.Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :scopes_csys
|
||||
|
||||
def init(arg) do
|
||||
IO.inspect(arg)
|
||||
IO.inspect(Process.get())
|
||||
:ignore
|
||||
end
|
||||
|
||||
plug Plug.Static,
|
||||
at: "/",
|
||||
from: :scopes_csys,
|
||||
|
|
@ -21,6 +15,5 @@ defmodule Scopes.CSys.Server.Endpoint do
|
|||
pass: ["*/*"],
|
||||
json_decoder: Phoenix.json_library()
|
||||
|
||||
plug Scopes.CSys.Server.Router
|
||||
#input_neurons: @input
|
||||
plug Scopes.Web.Server.Router
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
defmodule Scopes.CSys.Server.Router do
|
||||
use Scopes.Web.Server, :router
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/api", Scopes.CSys.Server do
|
||||
pipe_through :api
|
||||
match :*, "/csys/:action/s01/:item", Controller, :index
|
||||
end
|
||||
end
|
||||
|
||||
defmodule Scopes.CSys.Server.Controller do
|
||||
use Scopes.Web.Server, :controller
|
||||
|
||||
def index(conn, params) do
|
||||
# input_neuron = Environ.get_input(:csys, :s01)
|
||||
json(conn, params)
|
||||
#render(conn, :index, message: "Hello CSys")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -10,9 +10,6 @@ defmodule Scopes.Core.Actor do
|
|||
bhv.(msg)
|
||||
loop(bhv)
|
||||
{:become, bhv_n} -> loop(bhv_n)
|
||||
{:register, reg, name, value} ->
|
||||
Registry.register(reg, name, value)
|
||||
loop(bhv)
|
||||
{:quit} -> nil
|
||||
end
|
||||
end
|
||||
|
|
@ -22,12 +19,6 @@ defmodule Scopes.Core.Actor do
|
|||
spawn_link(fn -> loop(bhv) end)
|
||||
end
|
||||
|
||||
def create(bhv, reg, name, value \\ []) do
|
||||
spawn_link(fn ->
|
||||
Registry.register(reg, name, value)
|
||||
loop(bhv) end)
|
||||
end
|
||||
|
||||
def send(ac, msg, delay \\ 0) do
|
||||
if msg do
|
||||
Process.sleep(delay)
|
||||
|
|
@ -39,10 +30,6 @@ defmodule Scopes.Core.Actor do
|
|||
Kernel.send(ac, {:become, bhv})
|
||||
end
|
||||
|
||||
def register(ac, reg, name, value \\ []) do
|
||||
Kernel.send(ac, {:register, reg, name, value})
|
||||
end
|
||||
|
||||
def stop(ac) do
|
||||
Kernel.send(ac, {:quit})
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ defmodule Scopes.Web.Server.ErrorJSON do
|
|||
# By default, Phoenix returns the status message from
|
||||
# the template name. For example, "404.json" becomes
|
||||
# "Not Found".
|
||||
def render(template, resp) do
|
||||
message = resp.reason.message
|
||||
def render(template, assigns) do
|
||||
message = assigns.reason.message
|
||||
Logger.warning(Util.show [message])
|
||||
%{errors: %{detail: Phoenix.Controller.status_message_from_template(template)}}
|
||||
end
|
||||
|
|
|
|||
7
mix.exs
7
mix.exs
|
|
@ -17,11 +17,8 @@ defmodule Scopes.MixProject do
|
|||
# Run "mix help compile.app" to learn about applications.
|
||||
def application do
|
||||
[
|
||||
mod: {Scopes.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools],
|
||||
env: [
|
||||
serve_endpoints: false
|
||||
]
|
||||
#mod: {Scopes.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools]
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,19 +4,10 @@ defmodule Scopes.CoreActorTest do
|
|||
|
||||
describe "actors:" do
|
||||
test "basic-life-cycle" do
|
||||
Registry.start_link(keys: :unique, name: Actors)
|
||||
this = self()
|
||||
|
||||
ac = Actor.create(fn msg -> send(this, msg) end)
|
||||
Actor.register(ac, Actors, :demo, [])
|
||||
# or: ac = Actor.create(fn msg -> send(this, msg) end, Actors, :demo)
|
||||
|
||||
Actor.send(ac, "Hello Actor!")
|
||||
assert_receive "Hello Actor!"
|
||||
|
||||
[{pid, _value}] = Registry.lookup(Actors, :demo)
|
||||
assert pid == ac
|
||||
|
||||
Actor.become(ac, fn _msg -> send(this, "Goodbye") end)
|
||||
Actor.send(ac, "Hello Actor!")
|
||||
Actor.stop(ac)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue