tolerance All system nodes needs to manipulate exactly the same data at the same time Requests must succeed Node failure must not create a complete system failure A distributed system can only guarantee 2 constraints at the same time, not 3…
by Greg Young • Command Query Responsibility Segregation • Read != Write (different needs) Query A read operation Command Validation Business logic Persistence CQRS suit perfectly well with Event Sourcing!
NOT NULL, "createdAt" VARCHAR NOT NULL, "type" VARCHAR NOT NULL, "version" INTEGER NOT NULL, "payload" JSONB, PRIMARY KEY ("streamId", "createdAt", "version") ); CREATE INDEX ON "EVENT_STREAM" ("streamId");
$$ BEGIN RAISE EXCEPTION 'Event Stream can not be updated'; END; $$ LANGUAGE plpgsql VOLATILE; CREATE RULE "PREVENT_DELETE_ON_EVENT_STREAM" AS ON DELETE TO "EVENT_STREAM" DO INSTEAD SELECT THROW_WHEN_TYRING_TO_UPDATE_EVENT_STREAM(); CREATE RULE "PREVENT_UPDATE_ON_EVENT_STREAM" AS ON UPDATE TO "EVENT_STREAM" DO INSTEAD SELECT THROW_WHEN_TYRING_TO_UPDATE_EVENT_STREAM();