mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +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.
103 lines
2.7 KiB
Go
103 lines
2.7 KiB
Go
package org
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
var (
|
|
LockoutPolicyAddedEventType = orgEventTypePrefix + policy.LockoutPolicyAddedEventType
|
|
LockoutPolicyChangedEventType = orgEventTypePrefix + policy.LockoutPolicyChangedEventType
|
|
LockoutPolicyRemovedEventType = orgEventTypePrefix + policy.LockoutPolicyRemovedEventType
|
|
)
|
|
|
|
type LockoutPolicyAddedEvent struct {
|
|
policy.LockoutPolicyAddedEvent
|
|
}
|
|
|
|
func NewLockoutPolicyAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
maxAttempts uint64,
|
|
showLockoutFailure bool,
|
|
) *LockoutPolicyAddedEvent {
|
|
return &LockoutPolicyAddedEvent{
|
|
LockoutPolicyAddedEvent: *policy.NewLockoutPolicyAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LockoutPolicyAddedEventType),
|
|
maxAttempts,
|
|
showLockoutFailure),
|
|
}
|
|
}
|
|
|
|
func LockoutPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := policy.LockoutPolicyAddedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LockoutPolicyAddedEvent{LockoutPolicyAddedEvent: *e.(*policy.LockoutPolicyAddedEvent)}, nil
|
|
}
|
|
|
|
type LockoutPolicyChangedEvent struct {
|
|
policy.LockoutPolicyChangedEvent
|
|
}
|
|
|
|
func NewLockoutPolicyChangedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
changes []policy.LockoutPolicyChanges,
|
|
) (*LockoutPolicyChangedEvent, error) {
|
|
changedEvent, err := policy.NewLockoutPolicyChangedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LockoutPolicyChangedEventType),
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *changedEvent}, nil
|
|
}
|
|
|
|
func LockoutPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := policy.LockoutPolicyChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *e.(*policy.LockoutPolicyChangedEvent)}, nil
|
|
}
|
|
|
|
type LockoutPolicyRemovedEvent struct {
|
|
policy.LockoutPolicyRemovedEvent
|
|
}
|
|
|
|
func NewLockoutPolicyRemovedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
) *LockoutPolicyRemovedEvent {
|
|
return &LockoutPolicyRemovedEvent{
|
|
LockoutPolicyRemovedEvent: *policy.NewLockoutPolicyRemovedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LockoutPolicyRemovedEventType),
|
|
),
|
|
}
|
|
}
|
|
|
|
func LockoutPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := policy.LockoutPolicyRemovedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LockoutPolicyRemovedEvent{LockoutPolicyRemovedEvent: *e.(*policy.LockoutPolicyRemovedEvent)}, nil
|
|
}
|