event_sourced_record
and other things
Hi
I’m Garrow
I’m Post-Post-Technical
Fashion
fameandpartners.com
Problem
“We want to tell customers when their Order is finished.”
Add finished_date to Order.
...sometime later
“We want to tell the customer the state of their Order”
Add state to Order, and update it when changes happen.
… “per Item on the Order”
OK
Add `state` to each Item
Update each Item’s state when changes occur.
… a long time later
“We want a report
Solution
?
Time Travel!
Event Sourcing
“Time-based immutable events”
“every change to the state of an object is recorded as an immutable event in a replayable sequence”
http://fhwang.net/2015/01/29/Event-Sourcing-with-Rails-A-Case-Study
http://martinfowler.com/eaaDev/EventSourcing.html
event_sourced_record
Francis Hwang
github.com/fhwang/event_sourced_record
Go watch the presentation!
Concepts
Benefits
Shampoo Bottle Subscription
Events describe a change to number of bottles on the subscription.
Calculator adjusts the Subscription by amount
Subscription bottles_remaining is the cached value.
Our use cases
Dresses, manufactured on demand
Fabrication
Order Returns
Fabrication Events
* really should be split up
Fabrication
DEMO TIME
(uh oh)
Issues & Problems
What now?
Go watch Francis’ presentation
Try out event_sourced_record
Presentation.events
.start_talking
.create!(
prepared: false
)
Links
FIN