Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process Manager Instance doesn't die after reaching the final state #24

Closed
henry-hz opened this issue Nov 2, 2016 · 2 comments
Closed

Comments

@henry-hz
Copy link

henry-hz commented Nov 2, 2016

When manually sending TransferMoney commands, like the one below, and checking it's creation in the Observer, I noted that after the process is finished, it continues there pending. After reaching the final state, the process could suicide, and a TTL also would be suitable for high loading, and cache only what is in real use. Please, let me ask you to comment how commanded is in production, some benchmarks.
thanks :)

:ok = Bank.Router.dispatch(%TransferMoney{source_account: "ACC333", target_account: "ACC123", amount: 5})

@slashdotdash
Copy link
Member

slashdotdash commented Nov 2, 2016

Commanded is not used in production right now. I'm building a web app that uses it and am hoping to have it deployed before the end of the year and it has been deployed.

Extending process managers to allow an instance to signal that it has finished is a useful feature to have. It could be done by extended interested? to support :start, :continue, and :stop. Example with the possible change taken from the README below.

defmodule TransferMoneyProcessManager do
  # ...

  def interested?(%MoneyTransferRequested{transfer_uuid: transfer_uuid}), do: {:start, transfer_uuid}
  def interested?(%MoneyWithdrawn{transfer_uuid: transfer_uuid}), do: {:continue, transfer_uuid}
  def interested?(%MoneyDeposited{transfer_uuid: transfer_uuid}), do: {:continue, transfer_uuid}
  def interested?(%MoneyTransferCompleted{transfer_uuid: transfer_uuid}), do: {:stop, transfer_uuid}
  def interested?(_event), do: false

 # ...
end

A second feature of stopping process manager instance processes that have been running idle for a period of time is another useful feature to add. This also applies to aggregate instances.

@slashdotdash
Copy link
Member

A process manager instance should also remove its snapshot data from storage once it has ended. Before the process terminates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants