mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
3118a99c1e
* start sub * start implement subsciptions * start subscription * implementation for member done * admin done * fix: tests * extend handlers * prepary notification * no errors in adminapi * changed current sequence in all packages * ignore mocks * works * subscriptions as singleton * tests * refactor: rename function scope var * fix: process ALL previous sequences * fix: spooler and pubsub * handler check * fix: process events until all done * fix break on query err * fix: handler * fix: process sequence or return error * check aggregate id * fix: log only in error case * fix tests * fix: handlers * fix: spooler * fix: spooler * fix: tests * fix: continue Co-authored-by: Livio Amstutz <livio.a@gmail.com>
35 lines
690 B
Go
35 lines
690 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type ObjectRoot struct {
|
|
AggregateID string `json:"-"`
|
|
Sequence uint64 `json:"-"`
|
|
ResourceOwner string `json:"-"`
|
|
CreationDate time.Time `json:"-"`
|
|
ChangeDate time.Time `json:"-"`
|
|
}
|
|
|
|
func (o *ObjectRoot) AppendEvent(event *Event) {
|
|
if o.AggregateID == "" {
|
|
o.AggregateID = event.AggregateID
|
|
} else if o.AggregateID != event.AggregateID {
|
|
return
|
|
}
|
|
if o.ResourceOwner == "" {
|
|
o.ResourceOwner = event.ResourceOwner
|
|
}
|
|
|
|
o.ChangeDate = event.CreationDate
|
|
if event.PreviousSequence == 0 {
|
|
o.CreationDate = o.ChangeDate
|
|
}
|
|
|
|
o.Sequence = event.Sequence
|
|
}
|
|
func (o *ObjectRoot) IsZero() bool {
|
|
return o.AggregateID == ""
|
|
}
|