tqwewe / kameo_es

Event sourcing library built on kameo
1 stars 0 forks source link

feat: add postgres support for event handlers #2

Open tqwewe opened 5 hours ago

tqwewe commented 5 hours ago

If you want to use postgres, you'll need to have a checkpoints table which looks like so:

CREATE TABLE checkpoints (
  projection_id TEXT NOT NULL,
  correlation_id UUID NOT NULL,
  last_event_id BIGINT NOT NULL,
  PRIMARY KEY (projection_id, correlation_id)
);

The primary key can be an arbitrary name of your projection. The postgres event handler runs your projection concurrently by correlation_id. So if you rely on ordering between some specific events, ensure they share the same correlation id.