Creates an event store on MySQL 8.0+ / Aurora MySQL 3. Run migrate(pool, { eventStore: true }) first.
An append locks the row of its stream in hermes_streams until the end of its transaction, checks the expected
version, stores the events with the next positions and updates the inline projections, all in one transaction:
its own, in READ COMMITTED, or the one of the application (tx). In the transaction of the application, the
append runs inside a savepoint, so a rejected append (e.g. a VersionConflictError) leaves nothing behind
and the transaction stays usable. Appends to different streams do not wait for each other, with one exception: an
inline projection whose document is fed by many streams (ofId) locks that document in every append that feeds it,
until the end of its transaction.
Every event gets a new eventId (a UUID); an id given by the caller is not used. For idempotent appends, use the
expected version.
Every projection has its own table, named after it (projectionTable) and created when it is missing (see
MySqlEventStore.init). It keeps the documents, and in a single-stream projection also the version of its
stream.
Its own transaction is tried again when MySQL picks it as the victim of a deadlock (e.g. when many instances create
the same stream at once). A deadlock in the transaction of the application rolls back the whole transaction, so it
is thrown to the application as it is.
Reads and appends use the pool, so point it at the writer of Aurora, not at a reader: the readers lag behind.
Creates an event store on MySQL 8.0+ / Aurora MySQL 3. Run
migrate(pool, { eventStore: true })first.An append locks the row of its stream in
hermes_streamsuntil the end of its transaction, checks the expected version, stores the events with the next positions and updates the inline projections, all in one transaction: its own, inREAD COMMITTED, or the one of the application (tx). In the transaction of the application, the append runs inside a savepoint, so a rejected append (e.g. a VersionConflictError) leaves nothing behind and the transaction stays usable. Appends to different streams do not wait for each other, with one exception: an inline projection whose document is fed by many streams (ofId) locks that document in every append that feeds it, until the end of its transaction.Every event gets a new
eventId(a UUID); an id given by the caller is not used. For idempotent appends, use the expected version.Every projection has its own table, named after it (projectionTable) and created when it is missing (see MySqlEventStore.init). It keeps the documents, and in a single-stream projection also the version of its stream.
Its own transaction is tried again when MySQL picks it as the victim of a deadlock (e.g. when many instances create the same stream at once). A deadlock in the transaction of the application rolls back the whole transaction, so it is thrown to the application as it is.
Reads and appends use the pool, so point it at the writer of Aurora, not at a reader: the readers lag behind.