zitadel/internal/repository/instance/policy_mail_template.go
Silvan b5564572bc
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.
2023-10-19 12:19:10 +02:00

67 lines
1.8 KiB
Go

package instance
import (
"context"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/policy"
)
var (
MailTemplateAddedEventType = instanceEventTypePrefix + policy.MailTemplatePolicyAddedEventType
MailTemplateChangedEventType = instanceEventTypePrefix + policy.MailTemplatePolicyChangedEventType
)
type MailTemplateAddedEvent struct {
policy.MailTemplateAddedEvent
}
func NewMailTemplateAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
template []byte,
) *MailTemplateAddedEvent {
return &MailTemplateAddedEvent{
MailTemplateAddedEvent: *policy.NewMailTemplateAddedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateAddedEventType),
template),
}
}
func MailTemplateAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e, err := policy.MailTemplateAddedEventMapper(event)
if err != nil {
return nil, err
}
return &MailTemplateAddedEvent{MailTemplateAddedEvent: *e.(*policy.MailTemplateAddedEvent)}, nil
}
type MailTemplateChangedEvent struct {
policy.MailTemplateChangedEvent
}
func NewMailTemplateChangedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
changes []policy.MailTemplateChanges,
) (*MailTemplateChangedEvent, error) {
changedEvent, err := policy.NewMailTemplateChangedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateChangedEventType),
changes,
)
if err != nil {
return nil, err
}
return &MailTemplateChangedEvent{MailTemplateChangedEvent: *changedEvent}, nil
}
func MailTemplateChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e, err := policy.MailTemplateChangedEventMapper(event)
if err != nil {
return nil, err
}
return &MailTemplateChangedEvent{MailTemplateChangedEvent: *e.(*policy.MailTemplateChangedEvent)}, nil
}