mirror of
https://github.com/zitadel/zitadel.git
synced 2025-07-01 12:58:33 +00:00

# Eventstore fixes - `event.Position` used float64 before which can lead to [precision loss](https://github.com/golang/go/issues/47300). The type got replaced by [a type without precision loss](https://github.com/jackc/pgx-shopspring-decimal) - the handler reported the wrong error if the current state was updated and therefore took longer to retry failed events. # Mirror fixes - max age of auth requests can be configured to speed up copying data from `auth.auth_requests` table. Auth requests last updated before the set age will be ignored. Default is 1 month - notification projections are skipped because notifications should be sent by the source system. The projections are set to the latest position - ensure that mirror can be executed multiple times
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package mirror
|
|
|
|
import (
|
|
"github.com/shopspring/decimal"
|
|
|
|
"github.com/zitadel/zitadel/internal/v2/eventstore"
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
type succeededPayload struct {
|
|
// Source is the name of the database data are mirrored from
|
|
Source string `json:"source"`
|
|
// Position until data will be mirrored
|
|
Position decimal.Decimal `json:"position"`
|
|
}
|
|
|
|
const SucceededType = eventTypePrefix + "succeeded"
|
|
|
|
type SucceededEvent eventstore.Event[succeededPayload]
|
|
|
|
var _ eventstore.TypeChecker = (*SucceededEvent)(nil)
|
|
|
|
func (e *SucceededEvent) ActionType() string {
|
|
return SucceededType
|
|
}
|
|
|
|
func SucceededEventFromStorage(event *eventstore.StorageEvent) (e *SucceededEvent, _ error) {
|
|
if event.Type != e.ActionType() {
|
|
return nil, zerrors.ThrowInvalidArgument(nil, "MIRRO-xh5IW", "Errors.Invalid.Event.Type")
|
|
}
|
|
|
|
payload, err := eventstore.UnmarshalPayload[succeededPayload](event.Payload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &SucceededEvent{
|
|
StorageEvent: event,
|
|
Payload: payload,
|
|
}, nil
|
|
}
|
|
|
|
func NewSucceededCommand(source string, position decimal.Decimal) *eventstore.Command {
|
|
return &eventstore.Command{
|
|
Action: eventstore.Action[any]{
|
|
Creator: Creator,
|
|
Type: SucceededType,
|
|
Revision: 1,
|
|
Payload: succeededPayload{
|
|
Source: source,
|
|
Position: position,
|
|
},
|
|
},
|
|
}
|
|
}
|