mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 12:57:34 +00:00
chore: move the go code into a subfolder
This commit is contained in:
52
apps/api/internal/v2/system/mirror/failed.go
Normal file
52
apps/api/internal/v2/system/mirror/failed.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package mirror
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/v2/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type failedPayload struct {
|
||||
Cause string `json:"cause"`
|
||||
// Source is the name of the database data are mirrored to
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
const FailedType = eventTypePrefix + "failed"
|
||||
|
||||
type FailedEvent eventstore.Event[failedPayload]
|
||||
|
||||
var _ eventstore.TypeChecker = (*FailedEvent)(nil)
|
||||
|
||||
func (e *FailedEvent) ActionType() string {
|
||||
return FailedType
|
||||
}
|
||||
|
||||
func FailedEventFromStorage(event *eventstore.StorageEvent) (e *FailedEvent, _ error) {
|
||||
if event.Type != e.ActionType() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "MIRRO-bwB9l", "Errors.Invalid.Event.Type")
|
||||
}
|
||||
|
||||
payload, err := eventstore.UnmarshalPayload[failedPayload](event.Payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &FailedEvent{
|
||||
StorageEvent: event,
|
||||
Payload: payload,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewFailedCommand(source string, cause error) *eventstore.Command {
|
||||
return &eventstore.Command{
|
||||
Action: eventstore.Action[any]{
|
||||
Creator: Creator,
|
||||
Type: FailedType,
|
||||
Payload: failedPayload{
|
||||
Cause: cause.Error(),
|
||||
Source: source,
|
||||
},
|
||||
Revision: 1,
|
||||
},
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user