fix(query): show views and failed events (#3743)

* fix(system): show views and failed events

* fix: set correct database on failed events and views
This commit is contained in:
Silvan
2022-05-31 16:33:50 +02:00
committed by GitHub
parent e3e0207318
commit ed36680ea1
11 changed files with 31 additions and 29 deletions

View File

@@ -18,14 +18,13 @@ func (s *Server) ListFailedEvents(ctx context.Context, req *admin_pb.ListFailedE
if err != nil {
return nil, err
}
convertedNew := FailedEventsToPb(failedEvents)
convertedOld = append(convertedOld, convertedNew...)
return &admin_pb.ListFailedEventsResponse{Result: convertedOld}, nil
convertedNew := FailedEventsToPb(s.database, failedEvents)
return &admin_pb.ListFailedEventsResponse{Result: append(convertedOld, convertedNew...)}, nil
}
func (s *Server) RemoveFailedEvent(ctx context.Context, req *admin_pb.RemoveFailedEventRequest) (*admin_pb.RemoveFailedEventResponse, error) {
var err error
if req.Database != "zitadel" {
if req.Database != s.database {
err = s.administrator.RemoveFailedEvent(ctx, RemoveFailedEventRequestToModel(req))
} else {
err = s.query.RemoveFailedEvent(ctx, req.ViewName, req.FailedSequence)

View File

@@ -24,17 +24,17 @@ func FailedEventViewToPb(failedEvent *model.FailedEvent) *admin_pb.FailedEvent {
}
}
func FailedEventsToPb(failedEvents *query.FailedEvents) []*admin_pb.FailedEvent {
func FailedEventsToPb(database string, failedEvents *query.FailedEvents) []*admin_pb.FailedEvent {
events := make([]*admin_pb.FailedEvent, len(failedEvents.FailedEvents))
for i, failedEvent := range failedEvents.FailedEvents {
events[i] = FailedEventToPb(failedEvent)
events[i] = FailedEventToPb(database, failedEvent)
}
return events
}
func FailedEventToPb(failedEvent *query.FailedEvent) *admin_pb.FailedEvent {
func FailedEventToPb(database string, failedEvent *query.FailedEvent) *admin_pb.FailedEvent {
return &admin_pb.FailedEvent{
Database: "zitadel",
Database: database,
ViewName: failedEvent.ProjectionName,
FailedSequence: failedEvent.FailedSequence,
FailureCount: failedEvent.FailureCount,

View File

@@ -24,6 +24,7 @@ var _ admin.AdminServiceServer = (*Server)(nil)
type Server struct {
admin.UnimplementedAdminServiceServer
database string
command *command.Commands
query *query.Queries
administrator repository.AdministratorRepository
@@ -35,13 +36,16 @@ type Config struct {
Repository eventsourcing.Config
}
func CreateServer(command *command.Commands,
func CreateServer(
database string,
command *command.Commands,
query *query.Queries,
repo repository.Repository,
externalSecure bool,
userCodeAlg crypto.EncryptionAlgorithm,
) *Server {
return &Server{
database: database,
command: command,
query: query,
administrator: repo,

View File

@@ -12,7 +12,7 @@ func (s *Server) ListViews(ctx context.Context, _ *admin_pb.ListViewsRequest) (*
if err != nil {
return nil, err
}
convertedCurrentSequences := CurrentSequencesToPb(currentSequences)
convertedCurrentSequences := CurrentSequencesToPb(s.database, currentSequences)
views, err := s.administrator.GetViews()
if err != nil {
return nil, err

View File

@@ -25,17 +25,17 @@ func ViewToPb(view *model.View) *admin_pb.View {
}
}
func CurrentSequencesToPb(currentSequences *query.CurrentSequences) []*admin_pb.View {
func CurrentSequencesToPb(database string, currentSequences *query.CurrentSequences) []*admin_pb.View {
v := make([]*admin_pb.View, len(currentSequences.CurrentSequences))
for i, currentSequence := range currentSequences.CurrentSequences {
v[i] = CurrentSequenceToPb(currentSequence)
v[i] = CurrentSequenceToPb(database, currentSequence)
}
return v
}
func CurrentSequenceToPb(currentSequence *query.CurrentSequence) *admin_pb.View {
func CurrentSequenceToPb(database string, currentSequence *query.CurrentSequence) *admin_pb.View {
return &admin_pb.View{
Database: "zitadel",
Database: database,
ViewName: currentSequence.ProjectionName,
ProcessedSequence: currentSequence.CurrentSequence,
EventTimestamp: timestamppb.New(currentSequence.Timestamp),