Tim Möhlmann 3aba942162
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
2024-09-11 08:24:00 +00:00

48 lines
1.1 KiB
Go

package debug_events
import (
"google.golang.org/grpc"
"github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/api/grpc/server"
"github.com/zitadel/zitadel/internal/command"
"github.com/zitadel/zitadel/internal/query"
debug_events "github.com/zitadel/zitadel/pkg/grpc/resources/debug_events/v3alpha"
)
type Server struct {
debug_events.UnimplementedZITADELDebugEventsServer
command *command.Commands
query *query.Queries
}
func CreateServer(
command *command.Commands,
query *query.Queries,
) *Server {
return &Server{
command: command,
query: query,
}
}
func (s *Server) RegisterServer(grpcServer *grpc.Server) {
debug_events.RegisterZITADELDebugEventsServer(grpcServer, s)
}
func (s *Server) AppName() string {
return debug_events.ZITADELDebugEvents_ServiceDesc.ServiceName
}
func (s *Server) MethodPrefix() string {
return debug_events.ZITADELDebugEvents_ServiceDesc.ServiceName
}
func (s *Server) AuthMethods() authz.MethodMapping {
return debug_events.ZITADELDebugEvents_AuthMethods
}
func (s *Server) RegisterGateway() server.RegisterGatewayFunc {
return debug_events.RegisterZITADELDebugEventsHandler
}