feat(eventstore): increase parallel write capabilities (#5940)

This implementation increases parallel write capabilities of the eventstore.
Please have a look at the technical advisories: [05](https://zitadel.com/docs/support/advisory/a10005) and  [06](https://zitadel.com/docs/support/advisory/a10006).
The implementation of eventstore.push is rewritten and stored events are migrated to a new table `eventstore.events2`.
If you are using cockroach: make sure that the database user of ZITADEL has `VIEWACTIVITY` grant. This is used to query events.
This commit is contained in:
Silvan
2023-10-19 12:19:10 +02:00
committed by GitHub
parent 259faba3f0
commit b5564572bc
791 changed files with 30326 additions and 43202 deletions

View File

@@ -2,7 +2,7 @@ package eventstore
import "time"
//WriteModel is the minimum representation of a command side write model.
// WriteModel is the minimum representation of a command side write model.
// It implements a basic reducer
// it's purpose is to reduce events to create new ones
type WriteModel struct {
@@ -14,13 +14,13 @@ type WriteModel struct {
ChangeDate time.Time `json:"-"`
}
//AppendEvents adds all the events to the read model.
// AppendEvents adds all the events to the read model.
// The function doesn't compute the new state of the read model
func (rm *WriteModel) AppendEvents(events ...Event) {
rm.Events = append(rm.Events, events...)
}
//Reduce is the basic implementaion of reducer
// Reduce is the basic implementation of reducer
// If this function is extended the extending function should be the last step
func (wm *WriteModel) Reduce() error {
if len(wm.Events) == 0 {
@@ -38,7 +38,7 @@ func (wm *WriteModel) Reduce() error {
}
wm.ProcessedSequence = wm.Events[len(wm.Events)-1].Sequence()
wm.ChangeDate = wm.Events[len(wm.Events)-1].CreationDate()
wm.ChangeDate = wm.Events[len(wm.Events)-1].CreatedAt()
// all events processed and not needed anymore
wm.Events = nil