mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
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:
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,11 +25,11 @@ type MachineKeyAddedEvent struct {
|
||||
PublicKey []byte `json:"publicKey,omitempty"`
|
||||
}
|
||||
|
||||
func (e *MachineKeyAddedEvent) Data() interface{} {
|
||||
func (e *MachineKeyAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *MachineKeyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *MachineKeyAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -55,11 +54,11 @@ func NewMachineKeyAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func MachineKeyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func MachineKeyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
machineKeyAdded := &MachineKeyAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, machineKeyAdded)
|
||||
err := event.Unmarshal(machineKeyAdded)
|
||||
if err != nil {
|
||||
//first events had wrong payload.
|
||||
// the keys were removed later, that's why we ignore them here.
|
||||
@@ -78,11 +77,11 @@ type MachineKeyRemovedEvent struct {
|
||||
KeyID string `json:"keyId,omitempty"`
|
||||
}
|
||||
|
||||
func (e *MachineKeyRemovedEvent) Data() interface{} {
|
||||
func (e *MachineKeyRemovedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *MachineKeyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *MachineKeyRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -101,11 +100,11 @@ func NewMachineKeyRemovedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func MachineKeyRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func MachineKeyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
machineRemoved := &MachineKeyRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, machineRemoved)
|
||||
err := event.Unmarshal(machineRemoved)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-5Gm9s", "unable to unmarshal machine key removed")
|
||||
}
|
||||
|
Reference in New Issue
Block a user