mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
b5564572bc
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.
88 lines
2.1 KiB
Go
88 lines
2.1 KiB
Go
package org
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/repository/metadata"
|
|
)
|
|
|
|
const (
|
|
MetadataSetType = orgEventTypePrefix + metadata.SetEventType
|
|
MetadataRemovedType = orgEventTypePrefix + metadata.RemovedEventType
|
|
MetadataRemovedAllType = orgEventTypePrefix + metadata.RemovedAllEventType
|
|
)
|
|
|
|
type MetadataSetEvent struct {
|
|
metadata.SetEvent
|
|
}
|
|
|
|
func NewMetadataSetEvent(ctx context.Context, aggregate *eventstore.Aggregate, key string, value []byte) *MetadataSetEvent {
|
|
return &MetadataSetEvent{
|
|
SetEvent: *metadata.NewSetEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
MetadataSetType),
|
|
key,
|
|
value),
|
|
}
|
|
}
|
|
|
|
func MetadataSetEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := metadata.SetEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MetadataSetEvent{SetEvent: *e.(*metadata.SetEvent)}, nil
|
|
}
|
|
|
|
type MetadataRemovedEvent struct {
|
|
metadata.RemovedEvent
|
|
}
|
|
|
|
func NewMetadataRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, key string) *MetadataRemovedEvent {
|
|
return &MetadataRemovedEvent{
|
|
RemovedEvent: *metadata.NewRemovedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
MetadataRemovedType),
|
|
key),
|
|
}
|
|
}
|
|
|
|
func MetadataRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := metadata.RemovedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MetadataRemovedEvent{RemovedEvent: *e.(*metadata.RemovedEvent)}, nil
|
|
}
|
|
|
|
type MetadataRemovedAllEvent struct {
|
|
metadata.RemovedAllEvent
|
|
}
|
|
|
|
func NewMetadataRemovedAllEvent(ctx context.Context, aggregate *eventstore.Aggregate) *MetadataRemovedAllEvent {
|
|
return &MetadataRemovedAllEvent{
|
|
RemovedAllEvent: *metadata.NewRemovedAllEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
MetadataRemovedAllType),
|
|
),
|
|
}
|
|
}
|
|
|
|
func MetadataRemovedAllEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := metadata.RemovedAllEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MetadataRemovedAllEvent{RemovedAllEvent: *e.(*metadata.RemovedAllEvent)}, nil
|
|
}
|