11. The technical details
SELECT count(*) AS inSweden
FROM customer
WHERE email LIKE "%@jayway.se"
SELECT count(*) AS elsewhere
FROM customer
WHERE email LIKE "%@jayway.com"
total = inSweden + elsewhere
onsdag 16 oktober 13
27. Playing the game
Player A
Game 123
winner: Player B
loser: Player A
Server
Game 123
Player B: paper
Player A: rock
Player B
onsdag 16 oktober 13
28. Playing the game
GAME WON
other move
(victory)
CREATED
WAITING
any move
other move
(tie)
GAME TIED
Player A
Game 123
winner: Player B
loser: Player A
Server
Game 123
Player B: paper
Player A: rock
Player B
onsdag 16 oktober 13
34. Actions
Create game
POST /games
Make move
POST /games/123
move=rock
Get game result
GET /games/123
1. Form (make move)
2. Waiting
3. Game result
4. Error
onsdag 16 oktober 13
42. http://geteventstore.com
Runs on .NET and Mono
Free (store) or Commercial (HA)
API
€1500/year
Custom TCP (c#)
ATOM over HTTP (xml/json)
Features
Event streams, projections, generate new events (CEP)
onsdag 16 oktober 13
49. Current state?
GameCreatedEvent{:game 123, :creator "player-1", :time 1}
MoveMadeEvent{:game 123, :player "player-1", :move "rock", :time 2}
GAME WON
if victory
CREATED
WAITING
any move
other move
if tie
GAME TIED
onsdag 16 oktober 13
50. Current state?
GameCreatedEvent
GameCreatedEvent{:game 123, :creator "player-1", :time 1}
MoveMadeEvent{:game 123, :player "player-1", :move "rock", :time 2}
GAME WON
if victory
CREATED
WAITING
any move
other move
if tie
GAME TIED
onsdag 16 oktober 13
51. Current state?
GameCreatedEvent{:game 123, :creator "player-1", :time 1}
MoveMadeEvent
MoveMadeEvent{:game 123, :player "player-1", :move "rock", :time 2}
GAME WON
if victory
CREATED
WAITING
any move
other move
if tie
GAME TIED
onsdag 16 oktober 13
52. Aggregates
Scope of consistency when handling a command
Game
+ id
+ state
+ players
+ moves
+ winner
+ loser
onsdag 16 oktober 13
Move
Player
+ id
+ id
+ move
+ name
+ player
+ email
53. Aggregates as Event Streams
stream = game-1
version = 2
onsdag 16 oktober 13
event1 GameCreatedEvent{:game 1...}
event2 MoveMadeEvent{:game 1....}
54. Aggregates as Event Streams
stream = game-1
version = 2
event1 GameCreatedEvent{:game 1...}
event2 MoveMadeEvent{:game 1....}
stream = game-2
version = 4
event1
event2
event3
event4
onsdag 16 oktober 13
GameCreatedEvent{:game 2...}
MoveMadeEvent{:game 2....}
MoveMadeEvent{:game 2....}
GameWonEvent{:game 2....}
80. More info
Functional Programming with DDD
http://skillsmatter.com/podcast/design-architecture/ddd-functional-programming
A deep look into the Event Store
http://vimeo.com/53153270
onsdag 16 oktober 13
84. Fact
Something known to have happened or existed
2004-10-01 the email of Jan was ”jan.kronquist@jayway.se”
onsdag 16 oktober 13
85. Fact
Something known to have happened or existed
2004-10-01 the email of Jan was ”jan.kronquist@jayway.se”
2007-01-01 the email of Jan was ”jan.kronquist@jayway.com”
onsdag 16 oktober 13
104. System with Datomic
1.command
Peer A
3.transact
2.read and cache
Transactor
4.write
5.notify
Peer B
onsdag 16 oktober 13
Distributed
Storage
Service
114. Aggregates?
Only by convention
cas (compare and set)
isComponent on relation
Game
+ id
+ state
+ players
+ moves
+ winner
+ loser
onsdag 16 oktober 13
Move
+ id
+ move
+ player
115. Query language
What to find
Where clauses
[entity attribute value]
Implicit joins
Call arbitrary function
onsdag 16 oktober 13
116. Query example - basic
[:find ?email
:where
[_ :email ?email]]
onsdag 16 oktober 13
117. Query example - basic
[:find ?email
:where
[_ :email ?email]]
[["jan.kronquist@jayway.com]
["player-1@gmail.com"]
["player-2@gmail.com"]]
onsdag 16 oktober 13
118. Query example - aggregation
[:find ?state (?count game)
:where
[?game :state ?state]]
onsdag 16 oktober 13
131. EventStore Events
✓ Understandable by normal people
✓ Designed for integration
✓ Forces aggregate design (scalability)
✓ Capture intent
๏ Require design effort to get right
๏ Complect transaction and query
onsdag 16 oktober 13
132. Datomic Facts
✓ Support partial information
✓ Normalization support
✓ CRUD out of the box
๏ Static schema
onsdag 16 oktober 13
133. EventStore schema evolution
✓ New events
✓ New event attributes
✓ Event attributes rename (change deserialization)
✓ Projected state change (rebuild projection)
๏ Cross event refactoring
onsdag 16 oktober 13
134. Datomic schema evolution
✓ New or removed attributes
✓ New or removed entity types
✓ Move attributes between entities
๏ Fact attributes rename not possible
๏ Fact attribute type change not possible
onsdag 16 oktober 13