
uhef
Within chapter 4 an aggregator is implemented. The aggregator handler is written so that it is idempotent (i.e. it doesn’t matter if the handler is called once or N times with same parameters).
The way this is achieved is that view data tracks the global position of an event. In another words if event 5 is delivered multiple times the view data is updated only once.
However, the code cannot survive out-of-order delivery of events. In another words if message store delivers first event 5 followed by event 3 the videosWatched
parameter should be updated twice (i.e. once for event 3 and once for event 5). In this case, however, the aggregator will increment the counter only once resulting in wrong state.
Perhaps message store can guarantee in-order delivery of events, but I suppose this would be a good thing to mention.
Otherwise there are probably multiple ways to fix this. One that comes to mind is to track a list of events (global position indices) processed by aggregator in the database and increment the counter if aggregator receives an event it has not yet processed.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /flutter
- /c-plus-plus
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /vuejs
- /nim
- /emacs
- /nerves
- /elm