Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Use EventId in PersistOnEventRequests #387

Merged
merged 1 commit into from
Mar 30, 2017

Conversation

volkerstampa
Copy link
Contributor

Instead of using the in case of disaster recovery potentially
unstable sequence number as id for persist on event requests use a
stable EventId that is composed of the sequence number of the emitter
of the event and the corresponding process id.

Closes #385

Copy link
Contributor

@krasserm krasserm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work @volkerstampa, only had some minor comments.

@@ -56,15 +73,16 @@ case class DurableEvent(
localLogId: String = DurableEvent.UndefinedLogId,
localSequenceNr: Long = DurableEvent.UndefinedSequenceNr,
deliveryId: Option[String] = None,
persistOnEventSequenceNr: Option[Long] = None) {
persistOnEventSequenceNr: Option[Long] = None,
persistOnEventEventId: Option[EventId] = None) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to persistOnEventId (the type anyway tells that the id is an EventId and it is somewhat easier to read and pronounce).

* of old [[com.rbmhtechnology.eventuate.PersistOnEvent.PersistOnEventRequest]]s from
* a snapshot that do not have [[com.rbmhtechnology.eventuate.PersistOnEvent.PersistOnEventRequest.eventId]]
* set.
* @param persistOnEventEventId event id of the event that caused the emission of this event in an event handler.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event id of the event ... -> id of the event ... (i.e. omit first event)

* @param processId the id of the event log the initially wrote the event
* @param sequenceNr the initial sequence number in this log. Even if in case of disaster recovery the
* event ends up at a different sequence number in this log the `sequenceNr` of the
* `EventId` remains stable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't describe the special use case in the generic context here. Mentioning the id stability should be enough IMO.

def id: VectorTime =
vectorTimestamp
val id: EventId =
EventId(processId, vectorTimestamp.localTime(processId))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this as a breaking change to the release notes.

*/
case class PersistOnEventRequest(persistOnEventSequenceNr: Long, invocations: Vector[PersistOnEventInvocation], instanceId: Int)
case class PersistOnEventRequest(sequenceNr: Long, eventId: Option[EventId], invocations: Vector[PersistOnEventInvocation], instanceId: Int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency reasons, either

  • persistOnEventSequenceNr and persistOnEventId or
  • eventSequenceNr and eventId or
  • sequenceNr and id.

I'd prefer the first option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use EventId instead of Option[EventId] as persistOnEventId type because in the new implementation the persistOnEventId is never optional. For missing persistOnEventIds for backwards-compatibility reason we could use null and make a special check in the handlers. This keeps the interface clean and makes backwards-compatibility an implementation detail.

OTOH this proposal is rather error prone for later extensions and PersistOnEventRequest is an internal message anyway. Should we make the request private[eventuate] and add a documentation to its persistOnEventId parameter explaining why it is optional?

WDYT?

Instead of using the in case of disaster recovery potentially
unstable sequence number as id for persist on event requests use a
stable EventId that is composed of the sequence number of the emitter
of the event and the corresponding process id.

Closes #385
@volkerstampa volkerstampa force-pushed the fix-385-dr-with-persist-on-event branch from dff43d8 to 5d045c0 Compare March 30, 2017 08:34
@volkerstampa volkerstampa merged commit 6495478 into master Mar 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants