fix(eventstore): revert precise decimal (#8527) (#8679)

This commit is contained in:
Tim Möhlmann
2024-09-24 19:43:29 +03:00
committed by GitHub
parent eb97be6fdf
commit aeb379e7de
47 changed files with 215 additions and 319 deletions

View File

@@ -6,7 +6,6 @@ import (
"time"
"github.com/go-jose/go-jose/v4"
"github.com/shopspring/decimal"
"github.com/zitadel/logging"
"github.com/zitadel/saml/pkg/provider/key"
@@ -77,7 +76,7 @@ func (p *Storage) getCertificateAndKey(ctx context.Context, usage crypto.KeyUsag
return p.certificateToCertificateAndKey(selectCertificate(certs.Certificates))
}
var position decimal.Decimal
var position float64
if certs.State != nil {
position = certs.State.Position
}
@@ -88,7 +87,7 @@ func (p *Storage) getCertificateAndKey(ctx context.Context, usage crypto.KeyUsag
func (p *Storage) refreshCertificate(
ctx context.Context,
usage crypto.KeyUsage,
position decimal.Decimal,
position float64,
) error {
ok, err := p.ensureIsLatestCertificate(ctx, position)
if err != nil {
@@ -104,12 +103,12 @@ func (p *Storage) refreshCertificate(
return nil
}
func (p *Storage) ensureIsLatestCertificate(ctx context.Context, position decimal.Decimal) (bool, error) {
func (p *Storage) ensureIsLatestCertificate(ctx context.Context, position float64) (bool, error) {
maxSequence, err := p.getMaxKeySequence(ctx)
if err != nil {
return false, fmt.Errorf("error retrieving new events: %w", err)
}
return position.GreaterThanOrEqual(maxSequence), nil
return position >= maxSequence, nil
}
func (p *Storage) lockAndGenerateCertificateAndKey(ctx context.Context, usage crypto.KeyUsage) error {
@@ -152,9 +151,9 @@ func (p *Storage) lockAndGenerateCertificateAndKey(ctx context.Context, usage cr
}
}
func (p *Storage) getMaxKeySequence(ctx context.Context) (decimal.Decimal, error) {
return p.eventstore.LatestPosition(ctx,
eventstore.NewSearchQueryBuilder(eventstore.ColumnsMaxPosition).
func (p *Storage) getMaxKeySequence(ctx context.Context) (float64, error) {
return p.eventstore.LatestSequence(ctx,
eventstore.NewSearchQueryBuilder(eventstore.ColumnsMaxSequence).
ResourceOwner(authz.GetInstance(ctx).InstanceID()).
AwaitOpenTransactions().
AddQuery().