mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +00:00
fix(eventstore): use decimal, correct mirror (#9914)
# Eventstore fixes - `event.Position` used float64 before which can lead to [precision loss](https://github.com/golang/go/issues/47300). The type got replaced by [a type without precision loss](https://github.com/jackc/pgx-shopspring-decimal) - the handler reported the wrong error if the current state was updated and therefore took longer to retry failed events. # Mirror fixes - max age of auth requests can be configured to speed up copying data from `auth.auth_requests` table. Auth requests last updated before the set age will be ignored. Default is 1 month - notification projections are skipped because notifications should be sent by the source system. The projections are set to the latest position - ensure that mirror can be executed multiple times --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
@@ -25,7 +27,7 @@ type SearchQueryBuilder struct {
|
||||
tx *sql.Tx
|
||||
lockRows bool
|
||||
lockOption LockOption
|
||||
positionAfter float64
|
||||
positionAtLeast decimal.Decimal
|
||||
awaitOpenTransactions bool
|
||||
creationDateAfter time.Time
|
||||
creationDateBefore time.Time
|
||||
@@ -76,8 +78,8 @@ func (b *SearchQueryBuilder) GetTx() *sql.Tx {
|
||||
return b.tx
|
||||
}
|
||||
|
||||
func (b SearchQueryBuilder) GetPositionAfter() float64 {
|
||||
return b.positionAfter
|
||||
func (b SearchQueryBuilder) GetPositionAtLeast() decimal.Decimal {
|
||||
return b.positionAtLeast
|
||||
}
|
||||
|
||||
func (b SearchQueryBuilder) GetAwaitOpenTransactions() bool {
|
||||
@@ -113,7 +115,7 @@ type SearchQuery struct {
|
||||
aggregateIDs []string
|
||||
eventTypes []EventType
|
||||
eventData map[string]interface{}
|
||||
positionAfter float64
|
||||
positionAfter decimal.Decimal
|
||||
}
|
||||
|
||||
func (q SearchQuery) GetAggregateTypes() []AggregateType {
|
||||
@@ -132,7 +134,7 @@ func (q SearchQuery) GetEventData() map[string]interface{} {
|
||||
return q.eventData
|
||||
}
|
||||
|
||||
func (q SearchQuery) GetPositionAfter() float64 {
|
||||
func (q SearchQuery) GetPositionAfter() decimal.Decimal {
|
||||
return q.positionAfter
|
||||
}
|
||||
|
||||
@@ -156,8 +158,8 @@ type Columns int8
|
||||
const (
|
||||
//ColumnsEvent represents all fields of an event
|
||||
ColumnsEvent = iota + 1
|
||||
// ColumnsMaxSequence represents the latest sequence of the filtered events
|
||||
ColumnsMaxSequence
|
||||
// ColumnsMaxPosition represents the latest sequence of the filtered events
|
||||
ColumnsMaxPosition
|
||||
// ColumnsInstanceIDs represents the instance ids of the filtered events
|
||||
ColumnsInstanceIDs
|
||||
|
||||
@@ -284,9 +286,9 @@ func (builder *SearchQueryBuilder) EditorUser(id string) *SearchQueryBuilder {
|
||||
return builder
|
||||
}
|
||||
|
||||
// PositionAfter filters for events which happened after the specified time
|
||||
func (builder *SearchQueryBuilder) PositionAfter(position float64) *SearchQueryBuilder {
|
||||
builder.positionAfter = position
|
||||
// PositionAtLeast filters for events which happened after the specified time
|
||||
func (builder *SearchQueryBuilder) PositionAtLeast(position decimal.Decimal) *SearchQueryBuilder {
|
||||
builder.positionAtLeast = position
|
||||
return builder
|
||||
}
|
||||
|
||||
@@ -393,7 +395,7 @@ func (query *SearchQuery) EventData(data map[string]interface{}) *SearchQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
func (query *SearchQuery) PositionAfter(position float64) *SearchQuery {
|
||||
func (query *SearchQuery) PositionAfter(position decimal.Decimal) *SearchQuery {
|
||||
query.positionAfter = position
|
||||
return query
|
||||
}
|
||||
|
Reference in New Issue
Block a user