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:
@@ -2,11 +2,9 @@ package instance
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -21,11 +19,11 @@ type InstanceAddedEvent struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (e *InstanceAddedEvent) Data() interface{} {
|
||||
func (e *InstanceAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *InstanceAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *InstanceAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -40,11 +38,11 @@ func NewInstanceAddedEvent(ctx context.Context, aggregate *eventstore.Aggregate,
|
||||
}
|
||||
}
|
||||
|
||||
func InstanceAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func InstanceAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
instanceAdded := &InstanceAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, instanceAdded)
|
||||
err := event.Unmarshal(instanceAdded)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "INSTANCE-s9l3F", "unable to unmarshal instance added")
|
||||
}
|
||||
@@ -58,11 +56,11 @@ type InstanceChangedEvent struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (e *InstanceChangedEvent) Data() interface{} {
|
||||
func (e *InstanceChangedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *InstanceChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *InstanceChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -77,11 +75,11 @@ func NewInstanceChangedEvent(ctx context.Context, aggregate *eventstore.Aggregat
|
||||
}
|
||||
}
|
||||
|
||||
func InstanceChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func InstanceChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
instanceChanged := &InstanceChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, instanceChanged)
|
||||
err := event.Unmarshal(instanceChanged)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "INSTANCE-3hfo8", "unable to unmarshal instance changed")
|
||||
}
|
||||
@@ -95,12 +93,12 @@ type InstanceRemovedEvent struct {
|
||||
domains []string
|
||||
}
|
||||
|
||||
func (e *InstanceRemovedEvent) Data() interface{} {
|
||||
func (e *InstanceRemovedEvent) Payload() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *InstanceRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
constraints := make([]*eventstore.EventUniqueConstraint, len(e.domains)+1)
|
||||
func (e *InstanceRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
constraints := make([]*eventstore.UniqueConstraint, len(e.domains)+1)
|
||||
for i, domain := range e.domains {
|
||||
constraints[i] = NewRemoveInstanceDomainUniqueConstraint(domain)
|
||||
}
|
||||
@@ -120,7 +118,7 @@ func NewInstanceRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregat
|
||||
}
|
||||
}
|
||||
|
||||
func InstanceRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func InstanceRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
return &InstanceRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
|
Reference in New Issue
Block a user