fix: set quotas (#6597)

* feat: set quotas

* fix: start new period on younger anchor

* cleanup e2e config

* fix set notifications

* lint

* test: fix quota projection tests

* fix add quota tests

* make quota fields nullable

* enable amount 0

* fix initial setup

* create a prerelease

* avoid success comments

* fix quota projection primary key

* Revert "fix quota projection primary key"

This reverts commit e72f4d7fa1.

* simplify write model

* fix aggregate id

* avoid push without changes

* test set quota lifecycle

* test set quota mutations

* fix quota unit test

* fix: quotas

* test quota.set event projection

* use SetQuota in integration tests

* fix: release quotas 3

* reset releaserc

* fix comment

* test notification order doesn't matter

* test notification order doesn't matter

* test with unmarshalled events

* test with unmarshalled events

(cherry picked from commit ae1af6bc8c)
This commit is contained in:
Elio Bischof
2023-09-22 11:37:16 +02:00
committed by Livio Spring
parent 41e31aad41
commit 1d4ec6cdba
20 changed files with 1385 additions and 318 deletions

View File

@@ -1,11 +1,15 @@
package crdb
import (
"database/sql"
"errors"
"strconv"
"strings"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/database"
caos_errs "github.com/zitadel/zitadel/internal/errors"
zitadel_errors "github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/handler"
)
@@ -14,8 +18,9 @@ type execOption func(*execConfig)
type execConfig struct {
tableName string
args []interface{}
err error
args []interface{}
err error
ignoreNotFound bool
}
func WithTableSuffix(name string) func(*execConfig) {
@@ -24,6 +29,12 @@ func WithTableSuffix(name string) func(*execConfig) {
}
}
func WithIgnoreNotFound() func(*execConfig) {
return func(o *execConfig) {
o.ignoreNotFound = true
}
}
func NewCreateStatement(event eventstore.Event, values []handler.Column, opts ...execOption) *handler.Statement {
cols, params, args := columnsToQuery(values)
columnNames := strings.Join(cols, ", ")
@@ -436,7 +447,11 @@ func exec(config execConfig, q query, opts []execOption) Exec {
}
if _, err := ex.Exec(q(config), config.args...); err != nil {
return caos_errs.ThrowInternal(err, "CRDB-pKtsr", "exec failed")
if config.ignoreNotFound && errors.Is(err, sql.ErrNoRows) {
logging.WithError(err).Debugf("ignored not found: %v", err)
return nil
}
return zitadel_errors.ThrowInternal(err, "CRDB-pKtsr", "exec failed")
}
return nil