Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
As time goes by…
Episode 2: technical challenges of bi-temporal Event Sourcing
@tpierrain
t
If you want
to win…
Tweet like hell on…
#newCrafts
REQUIREMENTS
—
REQUIREMENTS
—
Understand their former decisions
REQUIREMENTS
—
Understand their former decisions

Fix their perception of the world
retroactively
REQUIREMENTS
—
Understand their former decisions

Fix their perception of the world
retroactively

(Re)produce reports in ...
REQUIREMENTS
—
Understand their former decisions

Fix their perception of the world
retroactively

(Re)produce reports in ...
REQUIREMENTS
—
Understand their former decisions

Fix their perception of the world
retroactively

(Re)produce reports in ...
They needed a time machine
Event Sourcing baby!
Event Sourcing 101
Remember your banking account?
Event Sourcing
Event Sourcing
Final state of the world
All changes since 

the beginning
All changes since the beginning
=
A list of events
Event [ɪˈvent]

Describes a fact, something that have happened.
Usually expressed in a past-tense form.

(e.g.: TalkStarte...
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public string Name { get; private set; }
...
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public string Name { get; private set; }
...
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public string Name { get; private set; }
...
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public string Name { get; private set; }
...
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public string Name { get; private set; }
...
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public string Name { get; private set; }
...
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public string Name { get; private set; }
...
Event-Sourced business objects
public class Fund : EventSourcedAggregate
{
public Guid Id { get; private set; }
public str...
Projection [prəˈjekSHən]

Deriving a current state from a stream of events
Fund myFund = fundRepository.GetById(fundId, projectedAt);
Event-Sourcing in motion
Guid
timestamp
Fund myFund = fundRepository.GetById(fundId, projectedAt);
Now
b7f3ddfb-2cb5….
Event-Sourcing in motion
t
Fund
id:
Name:
Creation date:
Management Company:
Shares:
Event-Sourcing in motion
t
FundCreated

“super yield ”
Jan 1st

2016
Fund
id: b7f3ddfb -2cb5….
Name: super yield
Creation date: Jan 1st
2016
Manage...
t
Jan 1st

2016
ManagementCompanyAssigned

“BNP”
Jan 30th

2016
Fund
id: b7f3ddfb -2cb5….
Name: super yield
Creation date:...
t
Jan 1st

2016
Jan 30th

2016
FundRenamed

“Yield 2k22”
Apr 1st

2016
Fund
id: b7f3ddfb -2cb5….
Name: Yield 2k22
Creation...
t
Jan 1st

2016
Jan 30th

2016
Apr 1st

2016
ShareAdded

“Part D”
Jun 2nd

2016
Fund
id: b7f3ddfb -2cb5….
Name: Yield 2k22...
Fund
id: b7f3ddfb -2cb5….
Name: Yield 2k22
Creation date: Jan 1st
2016
Management Company:
BNP
Shares:
Part D
End of
Strea...
Projected at now
Ready to work
Fund
id: b7f3ddfb -2cb5….
Name: Yield 2k22
Creation date: Jan 1st
2016
Management Company:
...
The beauty of it
Pick the projection date you want ;-)
Project same Fund at Apr 1st 2016
(same stream of events)
Event-Sourcing in motion
t
Fund
id:
Name:
Creation date:
Management Company:
Shares:
Event-Sourcing in motion
t
FundCreated

“super yield ”
Jan 1st

2016
Fund
id: b7f3ddfb -2cb5….
Name: super yield
Creation date: Jan 1st
2016
Manage...
t
Jan 1st

2016
ManagementCompanyAssigned

“BNP”
Jan 30th

2016
Fund
id: b7f3ddfb -2cb5….
Name: super yield
Creation date:...
t
Jan 1st

2016
Jan 30th

2016
FundRenamed

“Yield 2k22”
Apr 1st

2016
Fund
id: b7f3ddfb -2cb5….
Name: Yield 2k22
Creation...
t
Jan 1st

2016
Jan 30th

2016
Apr 1st

2016
Fund
id: b7f3ddfb -2cb5….
Name: Yield 2k22
Creation date: Jan 1st
2016
Manage...
Command [kəˈmɑːnd]

Triggers an action. Modify the state of the system
e.g.: RenameFund
Commands are used to take decisions and to raise events.
Commands are used to take decisions and to raise events.
Command
(RenameFund)
Aggregate
(Fund X)
Commands are used to take decisions and to raise events.
Command
(RenameFund)
Events
(FundRenamed)
Events are used to rest...
so far so good?
😉
Specificities
of bi-temporal
event sourcing
& Challenges
Challenge #1
How to change what can’t be changed?

Challenge #1
- Events are immutable (facts)
- We save them in append-only streams (Event Store)
t
Q: How to retroactively ...
we don’t change events
we just add
more events
we don’t change events
we just add
more events
“One more thing…”
“One more thing…
All our events have…”
createdAt 


validFrom !-> when it applies
2 timestamps
createdAt 


validFrom !-> when it applies
2 timestamps
( bi-temporal)
Types of events
validFrom
createdAt
Classic event
Types of events
validFrom
createdAt
Classic event
validFrom createdAt
Retroactive event
Thus we can hide former events
Thus we can hide former events
t
Feb 1st

2016
Feb 3rd

2016
Feb 5th

2016
“new naaame”
“initial name”
Thus we can hide former events
t
Feb 1st

2016
Feb 3rd

2016
Feb 5th

2016
“new naaame”
“initial name”
“fixed name ;-)”
Thus we can hide former events
t
Feb 1st

2016
Feb 3rd

2016
Feb 5th

2016
“new naaame”
“initial name”
“fixed name ;-)”
Challenge #2
Forecasting “facts”?!?
Challenge #2
- Event Store stores “Events” ;-)
- Events are things that have already happened (facts)
t
Q: How to store th...
Let’s store ”a Command (X) has just been Scheduled” events
validFromcreatedAt
“Command Scheduled” event“Command Scheduled” event
RenameFund
(Cmd)
validFromcreatedAt
CommandScheduled<RenameFund> event
RenameFund
(Cmd)
3 Types of events
3 Types of events
validFrom
createdAt
Classic event
3 Types of events
validFrom
createdAt
Classic event
validFrom createdAt
Retroactive event
3 Types of events
validFrom
createdAt
Classic event
validFrom createdAt
Retroactive event
validFromcreatedAt
“Command Sche...
Our model
Challenge #3
How to project unsorted streams of
events?
Challenge #3
- With retroactive events, we have unsorted streams of events
- Some events may hide others
- Past may change...
Let’s review some options
1 Forward-only projections with filters
1 Forward-only projections with filters
2 Sort - then - Apply events
1 Forward-only projections with filters
2 Sort - then - Apply events
3 Rebased Timelines with branches
1 Forward-only projections with filters
2 Sort - then - Apply events
3 Rebased Timelines with branches
too complicated
1 Forward-only projections with filters
2 Sort - then - Apply events
3 Rebased Timelines with branches
too complicated
not ...
2 Sort - then - Apply events
3 Rebased Timelines with branches
too complicated
not compliant with bigstreams of events
1 F...
Challenge #4
How to provide multiple visions of the
same reality?

(operational - audit-trail)
Challenge #4
- 1 stream of events per aggregate instance
- We need to provide both an operational mode and an audit mode
t...
Thank you Greg!
2 projection modes
/ As AtAs Of "
/ As AtAs Of
As we should 

have known
"
/ As AtAs Of
As we should 

have known
Patches inside
"
/As Of
As we should 

have known
Patches inside
As At
As we knew
(at the time)
"
/ As At
As we knew
(at the time)
Audit trails
As Of
As we should 

have known
Patches inside
"
/ As At
As we knew
(at the time)
Audit trails
As Of
As we should 

have known
Patches inside
"
Since we have a model,
let’s find some exemples
Our main usages (patches included)
As Of - as we should have known
As Of - as we should have known
Imagine a stream of 3 events for a Fund
1.Let’s see how those events have been
saved over the time
As Of - as we should have known
t
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
As Of - as we should have known
t
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
As Of - as we should have known
t
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“pat...
2. Let’s do some As Of projections
event?
👎
Do NOT
Apply
👍
Apply
or
As Of - as we should have known
Name:

???
Projection date
Jun 1st 2017
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

???
Projection date
Jun 1...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“pat...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
???
Name:

Projecti...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
👍
Apply
Name:

“Fir...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“official name”“First name”
Proje...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
👍
Apply
Name:

“Official name”
-p...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“Official name”
-pending-
...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
👎
Do NOT
Apply
Name:

“Official n...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“pat...
Same events / another projection date
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

???
Projection date
Apr 1...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“pat...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
Name:

“First name”...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
👍
Apply
Name:

“Fir...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“First name”
-pending-
“o...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“First name”
-pending-
“o...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“patched name”
-pending-
...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“patched name”
-pending-
...
As Of - as we should have known
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“pat...
"
As At - as we knew (at the time) "
audit-trail use cases
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

???
Projection date
Apr 1st 2016
As At - as we knew (at t...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“patched name”
Name:

???
Projection...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
Name:

Projection date
Apr 1st 2016
As At - as we k...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
👍
Apply
Name:

“First name”
-pending-
Projection da...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“First name”
-pending-
“official name”“First name”
Project...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“First name”
-pending-
“official name”“First name”
👎
Do NO...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“official name”“First name”
Projection date
Apr 1st 2016
As At - ...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“official name”“First name”
Projection date
Apr 1st 2016
As At - ...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“patched name”
Name:

“First name”
P...
Same events / another projection date
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

???
Projection date
Jun 1st 2017
As At - as we knew (at t...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name” “official name”
“patched name”
Name:

???
As At - as...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
Name:

As At - as we knew (at the time) "
???
Proje...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“First name”
👍
Apply
Name:

“First name”
-pending-
As At - as we...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“First name”
-pending-
“official name”“First name”
As At -...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
Name:

“official name”
-pending-
“official name”“First name”
As At...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“official name”“First name”
As At - as we knew (at the time) "
“p...
t
Apr 1st

2016
Jan 1st

2016
Jan 1st

2017
Jun 1st

2017
“official name”“First name”
As At - as we knew (at the time) "
👎
...
As At - as we knew (at the time) "
Projection date
Jun 1st 2017
Name:

“official name”t
Apr 1st

2016
Jan 1st

2016
Jan 1st...
Still with me?
Challenge #5
How to produce a report for March 1st
like if we had made it June 1st?
Challenge #5
- We don’t want to suffer from hindsight bias
- We need to understand how we had perceived the world in the pa...
Q: How to produce a report for March 1st, like if we had
made it June 1st?
Name:

???
t
Q: How to produce a report for March 1st, like if we had
made it June 1st?
???
Feb 2nd

2016
Feb 1st

2016
Fe...
t
“name 1”
“name 2”
“name 5”
Feb 2nd

2016
Feb 1st

2016
Feb 28th

2016
March 1st

2016
Feb 3rd

2016
Jul 1st

2016
Jun 1s...
t
Feb 2nd

2016
Feb 1st

2016
Feb 28th

2016
March 1st

2016
“name 1”
“name 2”
“name 5”
Feb 3rd

2016
Jul 1st

2016
Jun 1s...
t
Feb 2nd

2016
Feb 1st

2016
Feb 28th

2016
March 1st

2016
“name 1”
“name 2”
“name 5”
Feb 3rd

2016
Jul 1st

2016
Jun 1s...
t
Feb 2nd

2016
Feb 1st

2016
Feb 28th

2016
March 1st

2016
“name 5”
Feb 3rd

2016
Jul 1st

2016
Jun 1st

2016
Q: How to ...
t
Feb 2nd

2016
Feb 1st

2016
Feb 28th

2016
March 1st

2016
“name 5”
Feb 3rd

2016
Jul 1st

2016
Jun 1st

2016
Q: How to ...
which bring us
2 new concepts
Viewpoint AsOfUntil

projection mode
Fund myFund = fundRepository.GetAsOUntil(fundId, projectedAt, viewPoint);
AsOf Until
Guid
March 1st

2016
June 1st

2016
In code we trust
?
Name1?
Name2?
Name5?
Challenge #6
Retroactive commands 

vs. Retroactive events?
Challenge #6
- Events are facts
- Commands are used to take decisions and to raise events
- Command may fail
t
Q: What sho...
a) Apply a retroactive command to a aggregate
projected in the past? (may fail)
a) Apply a retroactive command to a aggregate
projected in the past? (may fail)
b) Create an event in the past for an aggr...
a) Apply a retroactive command to a aggregate
projected in the past? (may fail)
b) Create an event in the past for an aggr...
c) There is no silver bullet
But we’ve mostly picked the option


a) Apply a retroactive command to a aggregate
projected in the past? (may fail)


so ...
Challenge #7
Is U.T.C. enough?
tChallenge #7
- We store instants in our Event Store (createdAt, validFrom timestamps)
- Some events are applied on an ent...
t
Q: Which timestamps should we pick to describe a “day”?
Challenge #7
- We store instants in our Event Store (createdAt, ...
t
Q: Which timestamps should we pick to describe a “day”?
Q: Is UTC enough to store all instants?
Challenge #7
- We store ...
UTC [Utéçé;-)]

Universal Time Coordinated is the primary time standard by which the world
regulates clocks and time. It d...
Instant [ˈÇaAriiiv]

Describes “when something happened”. Can then be interpreted in a
particular time zone and calendar s...
Istanbul (+03)
What does June 8th even mean?
What does June 8th even mean?
Paris (+02)
Istanbul (+03)
UTC (+00)
Paris (+02)
Istanbul (+03)
What does June 8th even mean?
UTC (+00)
Jun 8th 2018
00h (+ 03h)
Paris (+02)
Istanbul (+03)
Jun 8th 2018
23h59 (+ 03h)
What does June 8th even mean?
UTC (+00)
Jun 8th 2018
00h (+ 03h)
Jun 7th 2018
21h (+ 00h)
Paris (+02)
Istanbul (+03)
Jun 8th 2018
23h59 (+ 03h)
Jun 8th ...
UTC (+00)
Paris (+02)
Istanbul (+03)
Jun 8th 2018
00h (+ 02h)
Jun 8th 2018
23h59 (+ 02h)
Jun 8th 2018
23h59 (+ 03h)
Jun 8t...
UTC (+00)
Paris (+02)
Istanbul (+03)
Jun 8th 2018
00h (+ 02h)
Jun 7th 2018
22h (+ 00h)
Jun 8th 2018
23h59 (+ 02h)
Jun 8th ...
UTC (+00)
Paris (+02)
Istanbul (+03)
Jun 7th 2018
22h (+ 00h)
Jun 8th 2018
21h59 (+ 02h)
Jun 8th 2018
21h59 (+ 00h)
Jun 7t...
UTC (+00)
Paris (+02)
Istanbul (+03)
Jun 7th 2018
22h (+ 00h)
Jun 8th 2018
21h59 (+ 02h)
Jun 8th 2018
21h59 (+ 00h)
Jun 7t...
June 8th Paris !!= June 8th Istanbul
UTC (+00)
Paris (+02)
Istanbul (+03)
Jun 7th 2018
22h (+ 00h)
Jun 8th 2018
21h59 (+ 02h)
Jun 8th 2018
21h59 (+ 00h)
Jun 7t...
UTC Time is mandatory to store & compare events
UTC (+00)
Paris (+02)
Istanbul (+03)
Jun 7th 2018
22h (+ 00h)
Jun 8th 2018...
UTC is mandatory but not enough
UTC (+00)
Paris (+02)
Istanbul (+03)
Jun 7th 2018
22h (+ 00h)
Jun 8th 2018
21h59 (+
02h)
J...
We need UTC Time + time zone of the event
time zone of the event?
Time zone of the action
that originated the event?
time zone of the event?
Time zone of the action
that originated the event?
Time zone associated with
the topic (i.e. a Fund)?
time zone of the eve...
- Wrap up -
Discovering the unknown
Without concrete examples and a
model, you’re dead.
And more than ever…
y.a.g.n.i
you ain’t gonna need it
Would you
d a r e t o
destroy it?
OVER
ENGINEERING
is an embarrassment
to ourselves
Get prepared
to Design
BREAK
THROUGH
Thank you!
(White paper ongoing)

@tpierrain (use case driven)
Thank you!
And the
winner is…
?
7 SPEAKERS, 5 TALKS ORIGINAUX DE 15-20 MIN
EN QUOI NOUS INTÉRESSER AUX PROBLÈMES DU
MÉTIER NOUS A RENDU PLUS EFFICACE
LE M...
Appendix
As At #2
As At #2 - as we knew at the time
As At #2 - as we knew at the time
As At #2 - as we knew at the time
“Patched name” will be <<discarded>> by the
following FundRenamed event
As Of #2
As Of #2 - as we should have known
“Patched name” is not <<discarded>> by the
following FundRenamed event (“official name”)
As Of #2 - as we should have known
But then it is replaced by the new one
( “OfficialName”)
You want to be ahead of what is done in software?
You understand there are bigger issues than just coding
We are looking f...
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
As time goes by (episode 2)
Prochain SlideShare
Chargement dans…5
×

As time goes by (episode 2)

606 vues

Publié le



When building an Event Sourcing system, can we change the past? Can we also forecast “events” in the future?

If we want to provide various projections/visions of things that hapenned over the time, what are the consequences and trade-offs on our code?

All these questions will be answered during this talk. But moreover, I'll tell you our learning story about Bi-temporal Event Sourcing. Yet another illustration of the power of modeling, sketches and concrete examples when we need to understand each others.

Publié dans : Ingénierie
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici

As time goes by (episode 2)

  1. 1. As time goes by… Episode 2: technical challenges of bi-temporal Event Sourcing @tpierrain t
  2. 2. If you want to win… Tweet like hell on… #newCrafts
  3. 3. REQUIREMENTS —
  4. 4. REQUIREMENTS — Understand their former decisions
  5. 5. REQUIREMENTS — Understand their former decisions Fix their perception of the world retroactively
  6. 6. REQUIREMENTS — Understand their former decisions Fix their perception of the world retroactively (Re)produce reports in and from the past
  7. 7. REQUIREMENTS — Understand their former decisions Fix their perception of the world retroactively (Re)produce reports in and from the past Forecast ”events” in the future

  8. 8. REQUIREMENTS — Understand their former decisions Fix their perception of the world retroactively (Re)produce reports in and from the past Forecast ”events” in the future
 Strong audit trail
  9. 9. They needed a time machine
  10. 10. Event Sourcing baby!
  11. 11. Event Sourcing 101
  12. 12. Remember your banking account? Event Sourcing
  13. 13. Event Sourcing
  14. 14. Final state of the world All changes since 
 the beginning
  15. 15. All changes since the beginning = A list of events
  16. 16. Event [ɪˈvent] Describes a fact, something that have happened. Usually expressed in a past-tense form.
 (e.g.: TalkStarted)
  17. 17. public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Event-Sourced business objects
  18. 18. public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Properties / Members Event-Sourced business objects
  19. 19. public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Evolution functions Change state Event-Sourced business objects
  20. 20. public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Constructor Change state Event-Sourced business objects
  21. 21. public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Decision functions Don’t change state Event-Sourced business objects
  22. 22. public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Event-Sourced business objects
  23. 23. public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Decision functions Don’t change state Event-Sourced business objects
  24. 24. Event-Sourced business objects public class Fund : EventSourcedAggregate { public Guid Id { get; private set; } public string Name { get; private set; } public Fund(IEnumerable<Event> events) { foreach(var evt in events) { Apply(evt); } } private Apply(FundRenamed event) { this.Name = event.FundNewName; } public IEnumerable<Event> Rename(string newName) { !// business logic and invariants checks HERE !// Raise event(s) return new[] { new FundRenamed(this.Id, newName) }; } } Decision functions Don’t change state Evolution functions Change state
  25. 25. Projection [prəˈjekSHən] Deriving a current state from a stream of events
  26. 26. Fund myFund = fundRepository.GetById(fundId, projectedAt); Event-Sourcing in motion Guid timestamp
  27. 27. Fund myFund = fundRepository.GetById(fundId, projectedAt); Now b7f3ddfb-2cb5…. Event-Sourcing in motion
  28. 28. t Fund id: Name: Creation date: Management Company: Shares: Event-Sourcing in motion
  29. 29. t FundCreated
 “super yield ” Jan 1st
 2016 Fund id: b7f3ddfb -2cb5…. Name: super yield Creation date: Jan 1st 2016 Management Company: Shares: Event-Sourcing in motion
  30. 30. t Jan 1st
 2016 ManagementCompanyAssigned
 “BNP” Jan 30th
 2016 Fund id: b7f3ddfb -2cb5…. Name: super yield Creation date: Jan 1st 2016 Management Company: BNP Shares: Event-Sourcing in motion
  31. 31. t Jan 1st
 2016 Jan 30th
 2016 FundRenamed
 “Yield 2k22” Apr 1st
 2016 Fund id: b7f3ddfb -2cb5…. Name: Yield 2k22 Creation date: Jan 1st 2016 Management Company: BNP Shares: Event-Sourcing in motion
  32. 32. t Jan 1st
 2016 Jan 30th
 2016 Apr 1st
 2016 ShareAdded
 “Part D” Jun 2nd
 2016 Fund id: b7f3ddfb -2cb5…. Name: Yield 2k22 Creation date: Jan 1st 2016 Management Company: BNP Shares: Part D Event-Sourcing in motion
  33. 33. Fund id: b7f3ddfb -2cb5…. Name: Yield 2k22 Creation date: Jan 1st 2016 Management Company: BNP Shares: Part D End of Stream >> <<t Jan 1st
 2016 Jan 30th
 2016 Apr 1st
 2016 Jun 2nd
 2016 Event-Sourcing in motion
  34. 34. Projected at now Ready to work Fund id: b7f3ddfb -2cb5…. Name: Yield 2k22 Creation date: Jan 1st 2016 Management Company: BNP Shares: Part D
  35. 35. The beauty of it Pick the projection date you want ;-)
  36. 36. Project same Fund at Apr 1st 2016 (same stream of events) Event-Sourcing in motion
  37. 37. t Fund id: Name: Creation date: Management Company: Shares: Event-Sourcing in motion
  38. 38. t FundCreated
 “super yield ” Jan 1st
 2016 Fund id: b7f3ddfb -2cb5…. Name: super yield Creation date: Jan 1st 2016 Management Company: Shares: Event-Sourcing in motion
  39. 39. t Jan 1st
 2016 ManagementCompanyAssigned
 “BNP” Jan 30th
 2016 Fund id: b7f3ddfb -2cb5…. Name: super yield Creation date: Jan 1st 2016 Management Company: BNP Shares: Event-Sourcing in motion
  40. 40. t Jan 1st
 2016 Jan 30th
 2016 FundRenamed
 “Yield 2k22” Apr 1st
 2016 Fund id: b7f3ddfb -2cb5…. Name: Yield 2k22 Creation date: Jan 1st 2016 Management Company: BNP Shares: Event-Sourcing in motion
  41. 41. t Jan 1st
 2016 Jan 30th
 2016 Apr 1st
 2016 Fund id: b7f3ddfb -2cb5…. Name: Yield 2k22 Creation date: Jan 1st 2016 Management Company: BNP Shares: We’re done here ;-) >> << Event-Sourcing in motion
  42. 42. Command [kəˈmɑːnd] Triggers an action. Modify the state of the system e.g.: RenameFund
  43. 43. Commands are used to take decisions and to raise events.
  44. 44. Commands are used to take decisions and to raise events. Command (RenameFund) Aggregate (Fund X)
  45. 45. Commands are used to take decisions and to raise events. Command (RenameFund) Events (FundRenamed) Events are used to restore/change the state of our aggregates. Aggregate (Fund X)
  46. 46. so far so good? 😉
  47. 47. Specificities of bi-temporal event sourcing & Challenges
  48. 48. Challenge #1 How to change what can’t be changed?

  49. 49. Challenge #1 - Events are immutable (facts) - We save them in append-only streams (Event Store) t Q: How to retroactively change former mistaken events? Q: How to insert forgotten events in the past (in the middle of a stream)?
  50. 50. we don’t change events we just add more events
  51. 51. we don’t change events we just add more events
  52. 52. “One more thing…”
  53. 53. “One more thing… All our events have…”
  54. 54. createdAt 

 validFrom !-> when it applies 2 timestamps
  55. 55. createdAt 

 validFrom !-> when it applies 2 timestamps ( bi-temporal)
  56. 56. Types of events validFrom createdAt Classic event
  57. 57. Types of events validFrom createdAt Classic event validFrom createdAt Retroactive event
  58. 58. Thus we can hide former events
  59. 59. Thus we can hide former events t Feb 1st
 2016 Feb 3rd
 2016 Feb 5th
 2016 “new naaame” “initial name”
  60. 60. Thus we can hide former events t Feb 1st
 2016 Feb 3rd
 2016 Feb 5th
 2016 “new naaame” “initial name” “fixed name ;-)”
  61. 61. Thus we can hide former events t Feb 1st
 2016 Feb 3rd
 2016 Feb 5th
 2016 “new naaame” “initial name” “fixed name ;-)”
  62. 62. Challenge #2 Forecasting “facts”?!?
  63. 63. Challenge #2 - Event Store stores “Events” ;-) - Events are things that have already happened (facts) t Q: How to store things that have to happen in an Event Store?
  64. 64. Let’s store ”a Command (X) has just been Scheduled” events
  65. 65. validFromcreatedAt “Command Scheduled” event“Command Scheduled” event RenameFund (Cmd)
  66. 66. validFromcreatedAt CommandScheduled<RenameFund> event RenameFund (Cmd)
  67. 67. 3 Types of events
  68. 68. 3 Types of events validFrom createdAt Classic event
  69. 69. 3 Types of events validFrom createdAt Classic event validFrom createdAt Retroactive event
  70. 70. 3 Types of events validFrom createdAt Classic event validFrom createdAt Retroactive event validFromcreatedAt “Command Scheduled” event C
  71. 71. Our model
  72. 72. Challenge #3 How to project unsorted streams of events?
  73. 73. Challenge #3 - With retroactive events, we have unsorted streams of events - Some events may hide others - Past may change at any time. Future too t Q: How to implement projections in such environment?
  74. 74. Let’s review some options
  75. 75. 1 Forward-only projections with filters
  76. 76. 1 Forward-only projections with filters 2 Sort - then - Apply events
  77. 77. 1 Forward-only projections with filters 2 Sort - then - Apply events 3 Rebased Timelines with branches
  78. 78. 1 Forward-only projections with filters 2 Sort - then - Apply events 3 Rebased Timelines with branches too complicated
  79. 79. 1 Forward-only projections with filters 2 Sort - then - Apply events 3 Rebased Timelines with branches too complicated not compliant with bigstreams of events
  80. 80. 2 Sort - then - Apply events 3 Rebased Timelines with branches too complicated not compliant with bigstreams of events 1 Forward-only projections with filters
  81. 81. Challenge #4 How to provide multiple visions of the same reality?
 (operational - audit-trail)
  82. 82. Challenge #4 - 1 stream of events per aggregate instance - We need to provide both an operational mode and an audit mode t Q: How to provide various points of view in our reality?
  83. 83. Thank you Greg!
  84. 84. 2 projection modes
  85. 85. / As AtAs Of "
  86. 86. / As AtAs Of As we should 
 have known "
  87. 87. / As AtAs Of As we should 
 have known Patches inside "
  88. 88. /As Of As we should 
 have known Patches inside As At As we knew (at the time) "
  89. 89. / As At As we knew (at the time) Audit trails As Of As we should 
 have known Patches inside "
  90. 90. / As At As we knew (at the time) Audit trails As Of As we should 
 have known Patches inside "
  91. 91. Since we have a model, let’s find some exemples
  92. 92. Our main usages (patches included) As Of - as we should have known
  93. 93. As Of - as we should have known Imagine a stream of 3 events for a Fund
  94. 94. 1.Let’s see how those events have been saved over the time
  95. 95. As Of - as we should have known t Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017
  96. 96. As Of - as we should have known t Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name”
  97. 97. As Of - as we should have known t Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name”
  98. 98. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name”
  99. 99. 2. Let’s do some As Of projections
  100. 100. event? 👎 Do NOT Apply 👍 Apply or
  101. 101. As Of - as we should have known Name:
 ??? Projection date Jun 1st 2017
  102. 102. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 ??? Projection date Jun 1st 2017
  103. 103. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name” Name:
 ??? Projection date Jun 1st 2017
  104. 104. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” ??? Name:
 Projection date Jun 1st 2017
  105. 105. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” 👍 Apply Name:
 “First name” -pending- Projection date Jun 1st 2017
  106. 106. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “official name”“First name” Projection date Jun 1st 2017 ??? Name:
 “First name” -pending-
  107. 107. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 👍 Apply Name:
 “Official name” -pending- “official name”“First name” Projection date Jun 1st 2017
  108. 108. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “Official name” -pending- “official name”“First name” “patched name” Projection date Jun 1st 2017 ???
  109. 109. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 👎 Do NOT Apply Name:
 “Official name” -pending- “official name”“First name” “patched name” Projection date Jun 1st 2017
  110. 110. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name” Name:
 “official name” Projection date Jun 1st 2017
  111. 111. Same events / another projection date
  112. 112. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 ??? Projection date Apr 1st 2016
  113. 113. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name” Name:
 ??? Projection date Apr 1st 2016
  114. 114. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” Name:
 “First name” -pending- Projection date Apr 1st 2016 ???
  115. 115. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” 👍 Apply Name:
 “First name” -pending- Projection date Apr 1st 2016
  116. 116. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “First name” -pending- “official name”“First name” Projection date Apr 1st 2016 ???
  117. 117. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “First name” -pending- “official name”“First name” 👎 Do NOT Apply Projection date Apr 1st 2016
  118. 118. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “patched name” -pending- “official name”“First name” “patched name” Projection date Apr 1st 2016 ???
  119. 119. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “patched name” -pending- “official name”“First name” “patched name” 👍 Apply Projection date Apr 1st 2016
  120. 120. As Of - as we should have known t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name” Name:
 “patched name” Projection date Apr 1st 2016
  121. 121. "
  122. 122. As At - as we knew (at the time) " audit-trail use cases
  123. 123. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 ??? Projection date Apr 1st 2016 As At - as we knew (at the time) "
  124. 124. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name” Name:
 ??? Projection date Apr 1st 2016 As At - as we knew (at the time) "
  125. 125. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” Name:
 Projection date Apr 1st 2016 As At - as we knew (at the time) " ???
  126. 126. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” 👍 Apply Name:
 “First name” -pending- Projection date Apr 1st 2016 As At - as we knew (at the time) "
  127. 127. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “First name” -pending- “official name”“First name” Projection date Apr 1st 2016 As At - as we knew (at the time) " ???
  128. 128. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “First name” -pending- “official name”“First name” 👎 Do NOT Apply Projection date Apr 1st 2016 As At - as we knew (at the time) "
  129. 129. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “official name”“First name” Projection date Apr 1st 2016 As At - as we knew (at the time) " “patched name” Name:
 “First name” -pending- ???
  130. 130. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “official name”“First name” Projection date Apr 1st 2016 As At - as we knew (at the time) " 👎 Do NOT Apply “patched name” Name:
 “First name” -pending-
  131. 131. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name” Name:
 “First name” Projection date Apr 1st 2016 As At - as we knew (at the time) "
  132. 132. Same events / another projection date
  133. 133. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 ??? Projection date Jun 1st 2017 As At - as we knew (at the time) "
  134. 134. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name” Name:
 ??? As At - as we knew (at the time) " Projection date Jun 1st 2017
  135. 135. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” Name:
 As At - as we knew (at the time) " ??? Projection date Jun 1st 2017
  136. 136. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” 👍 Apply Name:
 “First name” -pending- As At - as we knew (at the time) " Projection date Jun 1st 2017
  137. 137. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “First name” -pending- “official name”“First name” As At - as we knew (at the time) " ??? Projection date Jun 1st 2017
  138. 138. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 Name:
 “official name” -pending- “official name”“First name” As At - as we knew (at the time) " Projection date Jun 1st 2017 👍 Apply
  139. 139. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “official name”“First name” As At - as we knew (at the time) " “patched name” ??? Projection date Jun 1st 2017 Name:
 “official name” -pending-
  140. 140. t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “official name”“First name” As At - as we knew (at the time) " 👎 Do NOT Apply “patched name” Projection date Jun 1st 2017 Name:
 “official name” -pending-
  141. 141. As At - as we knew (at the time) " Projection date Jun 1st 2017 Name:
 “official name”t Apr 1st
 2016 Jan 1st
 2016 Jan 1st
 2017 Jun 1st
 2017 “First name” “official name” “patched name”
  142. 142. Still with me?
  143. 143. Challenge #5 How to produce a report for March 1st like if we had made it June 1st?
  144. 144. Challenge #5 - We don’t want to suffer from hindsight bias - We need to understand how we had perceived the world in the past - We should not see some events that happened after a viewpoint t
  145. 145. Q: How to produce a report for March 1st, like if we had made it June 1st?
  146. 146. Name:
 ??? t Q: How to produce a report for March 1st, like if we had made it June 1st? ??? Feb 2nd
 2016 Feb 1st
 2016 Feb 28th
 2016 March 1st
 2016 Feb 3rd
 2016 Jul 1st
 2016 Jun 1st
 2016
  147. 147. t “name 1” “name 2” “name 5” Feb 2nd
 2016 Feb 1st
 2016 Feb 28th
 2016 March 1st
 2016 Feb 3rd
 2016 Jul 1st
 2016 Jun 1st
 2016 Q: How to produce a report for March 1st, like if we had made it June 1st? Name:
 ??? ???
  148. 148. t Feb 2nd
 2016 Feb 1st
 2016 Feb 28th
 2016 March 1st
 2016 “name 1” “name 2” “name 5” Feb 3rd
 2016 Jul 1st
 2016 Jun 1st
 2016 Q: How to produce a report for March 1st, like if we had made it June 1st? Name:
 ??? Date of the report Report target date
  149. 149. t Feb 2nd
 2016 Feb 1st
 2016 Feb 28th
 2016 March 1st
 2016 “name 1” “name 2” “name 5” Feb 3rd
 2016 Jul 1st
 2016 Jun 1st
 2016 Q: How to produce a report for March 1st, like if we had made it June 1st? Date of the report Report target date Apply all events created before June 1st (viewPoint) Don’t apply events created after June 1st (viewPoint)
  150. 150. t Feb 2nd
 2016 Feb 1st
 2016 Feb 28th
 2016 March 1st
 2016 “name 5” Feb 3rd
 2016 Jul 1st
 2016 Jun 1st
 2016 Q: How to produce a report for March 1st, like if we had made it June 1st? Date of the report Report target date Apply all events created before June 1st (viewPoint) “name 1” “name 2” Don’t apply events created after June 1st (viewPoint)
  151. 151. t Feb 2nd
 2016 Feb 1st
 2016 Feb 28th
 2016 March 1st
 2016 “name 5” Feb 3rd
 2016 Jul 1st
 2016 Jun 1st
 2016 Q: How to produce a report for March 1st, like if we had made it June 1st? Date of the report Report target date Apply all events created before June 1st (viewPoint) “name 1” “name 2” Don’t apply events created after June 1st (viewPoint)
  152. 152. which bring us 2 new concepts
  153. 153. Viewpoint AsOfUntil projection mode
  154. 154. Fund myFund = fundRepository.GetAsOUntil(fundId, projectedAt, viewPoint); AsOf Until Guid March 1st 2016 June 1st 2016
  155. 155. In code we trust
  156. 156. ? Name1? Name2? Name5?
  157. 157. Challenge #6 Retroactive commands 
 vs. Retroactive events?
  158. 158. Challenge #6 - Events are facts - Commands are used to take decisions and to raise events - Command may fail t Q: What should we do with ’retroactive’?
  159. 159. a) Apply a retroactive command to a aggregate projected in the past? (may fail)
  160. 160. a) Apply a retroactive command to a aggregate projected in the past? (may fail) b) Create an event in the past for an aggregate?
  161. 161. a) Apply a retroactive command to a aggregate projected in the past? (may fail) b) Create an event in the past for an aggregate? c) The answer C
  162. 162. c) There is no silver bullet
  163. 163. But we’ve mostly picked the option 
 a) Apply a retroactive command to a aggregate projected in the past? (may fail) 
 so far
  164. 164. Challenge #7 Is U.T.C. enough?
  165. 165. tChallenge #7 - We store instants in our Event Store (createdAt, validFrom timestamps) - Some events are applied on an entire “day” (e.g. June 8th)
  166. 166. t Q: Which timestamps should we pick to describe a “day”? Challenge #7 - We store instants in our Event Store (createdAt, validFrom timestamps) - Some events are applied on an entire “day” (e.g. June 8th)
  167. 167. t Q: Which timestamps should we pick to describe a “day”? Q: Is UTC enough to store all instants? Challenge #7 - We store instants in our Event Store (createdAt, validFrom timestamps) - Some events are applied on an entire “day” (e.g. June 8th)
  168. 168. UTC [Utéçé;-)] Universal Time Coordinated is the primary time standard by which the world regulates clocks and time. It does not observe daylight saving time.
  169. 169. Instant [ˈÇaAriiiv] Describes “when something happened”. Can then be interpreted in a particular time zone and calendar system. e.g.: 2018-05-18T16:40:35Z (Z means UTC, i.e. +00h)
  170. 170. Istanbul (+03) What does June 8th even mean?
  171. 171. What does June 8th even mean? Paris (+02) Istanbul (+03)
  172. 172. UTC (+00) Paris (+02) Istanbul (+03) What does June 8th even mean?
  173. 173. UTC (+00) Jun 8th 2018 00h (+ 03h) Paris (+02) Istanbul (+03) Jun 8th 2018 23h59 (+ 03h) What does June 8th even mean?
  174. 174. UTC (+00) Jun 8th 2018 00h (+ 03h) Jun 7th 2018 21h (+ 00h) Paris (+02) Istanbul (+03) Jun 8th 2018 23h59 (+ 03h) Jun 8th 2018 21h59 (+ 00h) What does June 8th even mean?
  175. 175. UTC (+00) Paris (+02) Istanbul (+03) Jun 8th 2018 00h (+ 02h) Jun 8th 2018 23h59 (+ 02h) Jun 8th 2018 23h59 (+ 03h) Jun 8th 2018 21h59 (+ 00h) Jun 8th 2018 00h (+ 03h) Jun 7th 2018 21h (+ 00h) What does June 8th even mean?
  176. 176. UTC (+00) Paris (+02) Istanbul (+03) Jun 8th 2018 00h (+ 02h) Jun 7th 2018 22h (+ 00h) Jun 8th 2018 23h59 (+ 02h) Jun 8th 2018 21h59 (+ 02h) Jun 8th 2018 23h59 (+ 03h) Jun 8th 2018 21h59 (+ 00h) Jun 8th 2018 00h (+ 03h) Jun 7th 2018 21h (+ 00h) What does June 8th even mean?
  177. 177. UTC (+00) Paris (+02) Istanbul (+03) Jun 7th 2018 22h (+ 00h) Jun 8th 2018 21h59 (+ 02h) Jun 8th 2018 21h59 (+ 00h) Jun 7th 2018 21h (+ 00h) Event 1 ? Should event 1 be involved in a June 8th projection?
  178. 178. UTC (+00) Paris (+02) Istanbul (+03) Jun 7th 2018 22h (+ 00h) Jun 8th 2018 21h59 (+ 02h) Jun 8th 2018 21h59 (+ 00h) Jun 7th 2018 21h (+ 00h) Event 1? only if it’s June 8th - Paris time
  179. 179. June 8th Paris !!= June 8th Istanbul
  180. 180. UTC (+00) Paris (+02) Istanbul (+03) Jun 7th 2018 22h (+ 00h) Jun 8th 2018 21h59 (+ 02h) Jun 8th 2018 21h59 (+ 00h) Jun 7th 2018 21h (+ 00h) June 8th Paris time !!= June 8th Istanbul time
  181. 181. UTC Time is mandatory to store & compare events UTC (+00) Paris (+02) Istanbul (+03) Jun 7th 2018 22h (+ 00h) Jun 8th 2018 21h59 (+ 02h) Jun 8th 2018 21h59 (+ 00h) Jun 7th 2018 21h (+ 00h)
  182. 182. UTC is mandatory but not enough UTC (+00) Paris (+02) Istanbul (+03) Jun 7th 2018 22h (+ 00h) Jun 8th 2018 21h59 (+ 02h) Jun 8th 2018 21h59 (+ 00h) Jun 7th 2018 21h (+ 00h)
  183. 183. We need UTC Time + time zone of the event
  184. 184. time zone of the event?
  185. 185. Time zone of the action that originated the event? time zone of the event?
  186. 186. Time zone of the action that originated the event? Time zone associated with the topic (i.e. a Fund)? time zone of the event?
  187. 187. - Wrap up -
  188. 188. Discovering the unknown
  189. 189. Without concrete examples and a model, you’re dead.
  190. 190. And more than ever…
  191. 191. y.a.g.n.i you ain’t gonna need it
  192. 192. Would you d a r e t o destroy it?
  193. 193. OVER ENGINEERING is an embarrassment to ourselves
  194. 194. Get prepared to Design BREAK THROUGH
  195. 195. Thank you!
  196. 196. (White paper ongoing)
 @tpierrain (use case driven) Thank you!
  197. 197. And the winner is…
  198. 198. ?
  199. 199. 7 SPEAKERS, 5 TALKS ORIGINAUX DE 15-20 MIN EN QUOI NOUS INTÉRESSER AUX PROBLÈMES DU MÉTIER NOUS A RENDU PLUS EFFICACE LE MARDI 26 JUIN, CHEZ DOMAIN FROM THE TRENCHES
  200. 200. Appendix
  201. 201. As At #2
  202. 202. As At #2 - as we knew at the time
  203. 203. As At #2 - as we knew at the time
  204. 204. As At #2 - as we knew at the time “Patched name” will be <<discarded>> by the following FundRenamed event
  205. 205. As Of #2
  206. 206. As Of #2 - as we should have known “Patched name” is not <<discarded>> by the following FundRenamed event (“official name”)
  207. 207. As Of #2 - as we should have known But then it is replaced by the new one ( “OfficialName”)
  208. 208. You want to be ahead of what is done in software? You understand there are bigger issues than just coding We are looking for people who are daring, curious, sharing, but who especially like team work recruits

×