mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-16 12:58:00 +00:00
b522588d98
# Which Problems Are Solved Float64 which was used for the event.Position field is [not precise in go and gets rounded](https://github.com/golang/go/issues/47300). This can lead to unprecies position tracking of events and therefore projections especially on cockcoachdb as the position used there is a big number. example of a unprecies position: exact: 1725257931223002628 float64: 1725257931223002624.000000 # How the Problems Are Solved The float64 was replaced by [github.com/jackc/pgx-shopspring-decimal](https://github.com/jackc/pgx-shopspring-decimal). # Additional Changes Correct behaviour of makefile for load tests. Rename `latestSequence`-queries to `latestPosition`
48 lines
835 B
Go
48 lines
835 B
Go
package eventstore
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
func NewEventstore(querier Querier, pusher Pusher) *EventStore {
|
|
return &EventStore{
|
|
Pusher: pusher,
|
|
Querier: querier,
|
|
}
|
|
}
|
|
|
|
func NewEventstoreFromOne(o one) *EventStore {
|
|
return NewEventstore(o, o)
|
|
}
|
|
|
|
type EventStore struct {
|
|
Pusher
|
|
Querier
|
|
}
|
|
|
|
type one interface {
|
|
Pusher
|
|
Querier
|
|
}
|
|
|
|
type healthier interface {
|
|
Health(ctx context.Context) error
|
|
}
|
|
|
|
type GlobalPosition struct {
|
|
Position decimal.Decimal
|
|
InPositionOrder uint32
|
|
}
|
|
|
|
func (gp GlobalPosition) IsLess(other GlobalPosition) bool {
|
|
return gp.Position.LessThan(other.Position) || (gp.Position.Equal(other.Position) && gp.InPositionOrder < other.InPositionOrder)
|
|
}
|
|
|
|
type Reducer interface {
|
|
Reduce(events ...*StorageEvent) error
|
|
}
|
|
|
|
type Reduce func(events ...*StorageEvent) error
|