perf: query data AS OF SYSTEM TIME (#5231)

Queries the data in the storage layser at the timestamp when the call hit the API layer
This commit is contained in:
Silvan
2023-02-27 22:36:43 +01:00
committed by GitHub
parent 80003939ad
commit e38abdcdf3
170 changed files with 3101 additions and 3169 deletions

View File

@@ -9,6 +9,7 @@ import (
sq "github.com/Masterminds/squirrel"
"github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/api/call"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/query/projection"
@@ -73,7 +74,7 @@ func (q *Queries) NotificationProviderByIDAndType(ctx context.Context, aggID str
ctx, span := tracing.NewSpan(ctx)
defer func() { span.EndWithError(err) }()
query, scan := prepareDebugNotificationProviderQuery()
query, scan := prepareDebugNotificationProviderQuery(ctx, q.client)
stmt, args, err := query.Where(
sq.And{
sq.Eq{NotificationProviderColumnInstanceID.identifier(): authz.GetInstance(ctx).InstanceID()},
@@ -93,7 +94,7 @@ func (q *Queries) NotificationProviderByIDAndType(ctx context.Context, aggID str
return scan(row)
}
func prepareDebugNotificationProviderQuery() (sq.SelectBuilder, func(*sql.Row) (*DebugNotificationProvider, error)) {
func prepareDebugNotificationProviderQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilder, func(*sql.Row) (*DebugNotificationProvider, error)) {
return sq.Select(
NotificationProviderColumnAggID.identifier(),
NotificationProviderColumnCreationDate.identifier(),
@@ -103,7 +104,8 @@ func prepareDebugNotificationProviderQuery() (sq.SelectBuilder, func(*sql.Row) (
NotificationProviderColumnState.identifier(),
NotificationProviderColumnType.identifier(),
NotificationProviderColumnCompact.identifier(),
).From(notificationProviderTable.identifier()).PlaceholderFormat(sq.Dollar),
).From(notificationProviderTable.identifier() + db.Timetravel(call.Took(ctx))).
PlaceholderFormat(sq.Dollar),
func(row *sql.Row) (*DebugNotificationProvider, error) {
p := new(DebugNotificationProvider)
err := row.Scan(