Skip to content

Conversation

@porbas
Copy link
Collaborator

@porbas porbas commented Apr 10, 2025

  • enhance given test_helper
  • add shipment_process tests
  • extract Infra::ProcessManager
  • change the way we subscribe ProcessManager in the event store
  • refactor ShipmentProcess and ProcessManager
  • rearange the code

porbas added 6 commits April 10, 2025 13:21
if optional `process` kwarg provided - call process with each event
The idea is to extract the code that is repeated in all processes.
* initialization
* subscriptions
* loading/building state
* acting

The acting part is generate/call commands based on the current state

The current state always reflects all events passed to the process
manager so far (including the event passed to current call).

ProcessManager class, which includes module should:
* define State class
* pass it to include directive, e.g.:
  `include Infra::ProcessManager.with_state(ProcessState)`
* define `process_id(event)` method. It should extract process
  identifier from event payload
* define `act` method. It's responsibility it to generate
  and call commands based on the current state
get the list of subscribed events from the ProcessManager class.
It's available because of the new `subscribes_to` API
Let's try to use simple Data.define as process state - make it unmutable.

The process should now define `apply(event)` method, which have to return
new state based on the current state and passed event.

I also tried to utilize pattern matching in `act`. Is it easier to read now?"
* put the business logic at the beginning
* send the technical methods to the very bottom
@netlify
Copy link

netlify bot commented Apr 10, 2025

Deploy Preview for ecommerce-events failed.

Name Link
🔨 Latest commit 819b29c
🔍 Latest deploy log https://app.netlify.com/sites/ecommerce-events/deploys/67f8e84684f4f30008527eaa

@porbas porbas force-pushed the introduce-process-manager branch from da65802 to ce3abd5 Compare April 11, 2025 07:18
@porbas porbas merged commit cd461ed into master Apr 11, 2025
27 of 31 checks passed
@porbas porbas deleted the introduce-process-manager branch April 11, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants