-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtalk.slide
87 lines (61 loc) · 2.33 KB
/
talk.slide
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Event Sourcing In Go
5 May 2015
Charles Haynes
* What is event sourcing?
"all changes to application state are stored as a sequence of events"
-- Martin Fowler
* Why would you want it?
"[T]here are times when we don't just want to see where we are, we also want to know how we got there."
-- Martin Fowler
You're already using it. Your bank statement is an event store.
* How do you implement it in Go?
* Concretely: Social Food App
Check in meals
Location
Date
Get badges "Breakfast Club" "The Regular"
* Example: Restful JSON over HTTP
Nice adaptive web site with native Android and iOS apps for your front end
Talks to your back end using Restful JSON over HTTP
GET your current list of check-ins
GET your badges
POST a checkin
POST your login
* Client event request
These client events are sent as JSON strings
.code main.go /^type MSI/,/^}/
* Parsed into ClientMeal struct via map[string]interface{}
.code main.go /^func ParseMSI/,/^}/
* Parsed into ClientMeal struct directly
.code main.go /^func ParseClientMeal/,/^}/
* Validation
.code main.go /^type ClientEvent/,/^}/
.code main.go /^func \(cm ClientMeal\) Valid/,/^}/
* Converted into domain event
.code main.go /^type Meal/,/^}/
.code main.go /^func NewMeal/,/^}/
* Stored
.code main.go /^func WriteEvent/,/^}/
* Sent
.code main.go /^func EventHandler/,/^}/
* Handled
.code main.go /^func \(m Meal\) Handle/,/^}/
* Read Model
.code main.go /^type Client struct/,/var clients map/
* Get my badges
.code main.go /^func badges/,/^}/
* Get Badges Handler
.code main.go /func \(g GetBadges\) Handle/,/^}/
* Summary
Changes are stored as business domain events
Events store is append only and immutable
Front end validation format only, no read model
* References
[[http://martinfowler.com/eaaDev/EventSourcing.html][Martin Fowler]]
[[http://docs.geteventstore.com/introduction/event-sourcing-basics/][Geteventstore event sourcing basics]]
[[http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch][Object-relational impedance mismatch]]
[[https://msdn.microsoft.com/en-us/library/jj591559.aspx][Microsoft introducing event sourcing]]
[[https://msdn.microsoft.com/en-us/library/dn589792.aspx][Microsoft event sourcing pattern]]
[[https://msdn.microsoft.com/en-us/library/jj591577.aspx][Microsoft CQRS & ES deep dive]]
[[http://talks.golang.org/2015/json.slide][Parsing JSON in Go]]