Skip to content

Latest commit

 

History

History
44 lines (26 loc) · 1.56 KB

README.md

File metadata and controls

44 lines (26 loc) · 1.56 KB

Simple CQRS example (polyglot edition)

This project inspired by Greg Young's project https://github.com/gregoryyoung/m-r where he's expaining simplest possible objects to keep in mind then you serve CQRS solution.

Implementations

Currently this project implemented in:

Every new language will be in another next branch and include very similar solution to problem .

Solution

In this section I will try to describe in pseudo-code how each solution is represented:

app = Application.new #it's application (our working horse to serve every routine work)

id = Id.new

app.send createTask id: id, title: "new title", version: -1

wait_while app.read_by_id(id).version == 0 #we need this because event publishing is asynchronous and everything happens in a while

app.send renameTask id: id, title: "new title 1", version: 0

wait_while app.read_by_id(id).version == 1

app.send completeTask id: id, version: 1

wait_while app.read_by_id(id).version == 2

task = app.read_by_id id

print "Check out that everything is ok with our task #{task.title} #{task.completed}"