Skip to content

Composable event sourcing #65

@SemanticBeeng

Description

@SemanticBeeng

This is a design exploration of composability / orchestration patterns.

Resources as context

  1. "COMPOSABLE EVENT SOURCING WITH MONADS"
    http://www.lambdadays.org/static/upload/media/1519724460390566danielkrzywickieventsourcing.pdf

  2. https://stackoverflow.com/questions/51160457/event-sourcing-without-cqrs

  3. https://microservices.io/patterns/data/saga.html

  4. "The Application of Petri Nets to Workflow Management"
    http://wwwis.win.tue.nl/~wvdaalst/publications/p53.pdf

"State-based instead of event-based In contrast with many other process modeling techniques, the state of case can be modeled explicitly in a Petri net. Process modeling techniques ranging from informal techniques such as dataflow diagrams to formal techniques such as process algebra’s are event-based, i.e., transitions are modeled explicitly and the states between subsequent transitions are modeled implicitly. Today’s workflow management systems are typically event-based, i.e., tasks
are modeled explicitly and states between subsequent tasks are suppressed. The distinction between an event-based and a state-based description seems to be very subtle, but examples in this paper (e.g. Figure 16) show that this is of the utmost importance for workflow modeling. For example, in most
workflow management systems which abstract from states it is not possible to use the implicit OR-split."

Questions.

  1. Are event sourcing and CQRS welded together in Aecor or can they be used separately?

  2. Can Aecor be used to implement all use cases from "COMPOSABLE EVENT SOURCING WITH MONADS" ? (please skim through presentation to offer an initial assessment if any show stoppers exist before going deeper to prove)

  3. How to implement checkpointing rolling snapshots with Aecor (could be thought of related to composability). (see https://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf for definition)

In the banking app example the assumption of all account transactions being held in memory is not realistic. Thinking that if in a real implementation the transactions would be stored in another persistent repository and the aggregate would keep the transactions not yet checkpointed. If so, then these methods would need to be implemented differently

if (account.hasProcessedTransaction(transactionId)) {
().pure[F]
} else {
if (account.hasFunds(amount)) {
append(AccountDebited(transactionId, amount))
.

If this line of thinking is agreeable with you then please share some thoughts on techniques to achieve this. Maybe to suspend the ~ rolling snapshots in a separate effect ?

update 2018/01/06 : Found "Scaling Event-Sourcing at Jet" very useful.

I have a number of real applications with non trivial such business logic it seems it would be warranted to encapsulate in separate effects (could use the other effects like Sync and MoandError for example).

Disclaimer: I know this is rough, sorry, and still working through how composition / orchestration is done in https://github.com/vpavkin/ticket-booking-aecor/blob/master/booking/src/main/scala/ru/pavkin/booking/ProcessWirings.scala (seems CQRS based).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions