This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
127 changed files
with
5,823 additions
and
3,712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule Helix.Event.State.Supervisor do | ||
|
||
use Supervisor | ||
|
||
alias Helix.Event.State.Timer, as: EventTimer | ||
|
||
@doc false | ||
def start_link do | ||
Supervisor.start_link(__MODULE__, []) | ||
end | ||
|
||
@doc false | ||
def init(_) do | ||
children = [ | ||
worker(EventTimer, []) | ||
] | ||
|
||
supervise(children, strategy: :one_for_one) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
defmodule Helix.Event.State.Timer do | ||
@moduledoc """ | ||
`EventTimer` is responsible for handling events that were asked to be emitted | ||
sometime in the future. | ||
""" | ||
|
||
use GenServer | ||
|
||
alias Helix.Event | ||
|
||
@registry_name :event_timer | ||
|
||
# Client API | ||
|
||
def start_link, | ||
do: GenServer.start_link(__MODULE__, [], name: @registry_name) | ||
|
||
@spec emit_after(Event.t, interval :: float | non_neg_integer) :: | ||
term | ||
@doc """ | ||
Emits `event` after `interval` milliseconds have passed. | ||
Unit is in milliseconds! | ||
""" | ||
def emit_after(event, interval), | ||
do: GenServer.call(@registry_name, {:emit_after, event, interval}) | ||
|
||
# Callbacks | ||
|
||
def init(_), | ||
do: {:ok, []} | ||
|
||
def handle_call({:emit_after, event, interval}, _from, state) do | ||
Process.send_after(@registry_name, {:emit, event}, interval) | ||
|
||
{:reply, :ok, state} | ||
end | ||
|
||
def handle_info({:emit, event}, state) do | ||
Event.emit(event) | ||
|
||
{:noreply, state} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule Helix.Event.Supervisor do | ||
|
||
use Supervisor | ||
|
||
alias Helix.Event.State.Supervisor, as: StateSupervisor | ||
|
||
@doc false | ||
def start_link do | ||
Supervisor.start_link(__MODULE__, []) | ||
end | ||
|
||
@doc false | ||
def init(_) do | ||
children = [ | ||
supervisor(StateSupervisor, []) | ||
] | ||
|
||
supervise(children, strategy: :one_for_one) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule Helix.Process.Action.Flow.Process do | ||
|
||
import HELF.Flow | ||
|
||
alias Helix.Event | ||
alias Helix.Process.Model.Process | ||
alias Helix.Process.Action.Process, as: ProcessAction | ||
|
||
def signal(process = %Process{}, signal, params) do | ||
flowing do | ||
with {:ok, events} <- ProcessAction.signal(process, signal, params) do | ||
Event.emit(events) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.