mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:07:31 +00:00
feat: add debug events API (#8533)
# Which Problems Are Solved Add a debug API which allows pushing a set of events to be reduced in a dedicated projection. The events can carry a sleep duration which simulates a slow query during projection handling. # How the Problems Are Solved - `CreateDebugEvents` allows pushing multiple events which simulate the lifecycle of a resource. Each event has a `projectionSleep` field, which issues a `pg_sleep()` statement query in the projection handler : - Add - Change - Remove - `ListDebugEventsStates` list the current state of the projection, optionally with a Trigger - `GetDebugEventsStateByID` get the current state of the aggregate ID in the projection, optionally with a Trigger # Additional Changes - none # Additional Context - Allows reproduction of https://github.com/zitadel/zitadel/issues/8517
This commit is contained in:
@@ -338,6 +338,21 @@ func NewNoOpStatement(event eventstore.Event) *Statement {
|
||||
return NewStatement(event, nil)
|
||||
}
|
||||
|
||||
func NewSleepStatement(event eventstore.Event, d time.Duration, opts ...execOption) *Statement {
|
||||
return NewStatement(
|
||||
event,
|
||||
exec(
|
||||
execConfig{
|
||||
args: []any{float64(d) / float64(time.Second)},
|
||||
},
|
||||
func(_ execConfig) string {
|
||||
return "SELECT pg_sleep($1);"
|
||||
},
|
||||
opts,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func NewMultiStatement(event eventstore.Event, opts ...func(eventstore.Event) Exec) *Statement {
|
||||
if len(opts) == 0 {
|
||||
return NewNoOpStatement(event)
|
||||
@@ -385,6 +400,12 @@ func AddCopyStatement(conflict, from, to []Column, conditions []NamespacedCondit
|
||||
}
|
||||
}
|
||||
|
||||
func AddSleepStatement(d time.Duration, opts ...execOption) func(eventstore.Event) Exec {
|
||||
return func(event eventstore.Event) Exec {
|
||||
return NewSleepStatement(event, d, opts...).Execute
|
||||
}
|
||||
}
|
||||
|
||||
func NewArrayAppendCol(column string, value interface{}) Column {
|
||||
return Column{
|
||||
Name: column,
|
||||
|
Reference in New Issue
Block a user