mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-25 07:34:30 +00:00

# 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
52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
package debug_events
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
resource_object "github.com/zitadel/zitadel/internal/api/grpc/resources/object/v3alpha"
|
|
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
|
object "github.com/zitadel/zitadel/pkg/grpc/object/v3alpha"
|
|
debug_events "github.com/zitadel/zitadel/pkg/grpc/resources/debug_events/v3alpha"
|
|
)
|
|
|
|
func (s *Server) CreateDebugEvents(ctx context.Context, req *debug_events.CreateDebugEventsRequest) (_ *debug_events.CreateDebugEventsResponse, err error) {
|
|
ctx, span := tracing.NewSpan(ctx)
|
|
defer func() { span.EndWithError(err) }()
|
|
|
|
details, err := s.command.CreateDebugEvents(ctx, debugEventsFromRequest(req))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &debug_events.CreateDebugEventsResponse{
|
|
Details: resource_object.DomainToDetailsPb(details, object.OwnerType_OWNER_TYPE_INSTANCE, authz.GetInstance(ctx).InstanceID()),
|
|
}, nil
|
|
}
|
|
|
|
func (s *Server) GetDebugEventsStateById(ctx context.Context, req *debug_events.GetDebugEventsStateByIdRequest) (_ *debug_events.GetDebugEventsStateByIdResponse, err error) {
|
|
ctx, span := tracing.NewSpan(ctx)
|
|
defer func() { span.EndWithError(err) }()
|
|
|
|
state, err := s.query.GetDebugEventsStateByID(ctx, req.GetId(), req.GetTriggerBulk())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &debug_events.GetDebugEventsStateByIdResponse{
|
|
State: eventsStateToPB(state),
|
|
}, nil
|
|
}
|
|
func (s *Server) ListDebugEventsStates(ctx context.Context, req *debug_events.ListDebugEventsStatesRequest) (_ *debug_events.ListDebugEventsStatesResponse, err error) {
|
|
ctx, span := tracing.NewSpan(ctx)
|
|
defer func() { span.EndWithError(err) }()
|
|
|
|
states, err := s.query.ListDebugEventsStates(ctx, req.GetTriggerBulk())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &debug_events.ListDebugEventsStatesResponse{
|
|
States: eventStatesToPB(states),
|
|
}, nil
|
|
}
|