forked from commanded/commanded
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request commanded#334 from commanded/feature/process-manag…
…er-uuid Process manager `indentity/0` function
- Loading branch information
Showing
5 changed files
with
115 additions
and
17 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
32 changes: 32 additions & 0 deletions
32
test/process_managers/support/identity/identity_process_manager.ex
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,32 @@ | ||
defmodule Commanded.ProcessManagers.IdentityProcessManager do | ||
@moduledoc false | ||
|
||
alias Commanded.DefaultApp | ||
alias Commanded.ProcessManagers.IdentityProcessManager | ||
alias Commanded.ProcessManagers.ProcessManager | ||
|
||
use Commanded.ProcessManagers.ProcessManager, | ||
application: DefaultApp, | ||
name: __MODULE__ | ||
|
||
@derive Jason.Encoder | ||
defstruct [:uuid] | ||
|
||
defmodule AnEvent do | ||
defstruct [:uuids, :reply_to] | ||
end | ||
|
||
def interested?(%AnEvent{uuids: uuids}), do: {:start, uuids} | ||
|
||
def handle(%IdentityProcessManager{}, %AnEvent{} = event) do | ||
%AnEvent{reply_to: reply_to} = event | ||
|
||
uuid = ProcessManager.identity() | ||
|
||
send(reply_to, {:identity, uuid, self()}) | ||
|
||
[] | ||
end | ||
|
||
def apply(%IdentityProcessManager{} = state, _event), do: state | ||
end |