mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:27:42 +00:00
append events without return value
This commit is contained in:
@@ -142,7 +142,7 @@ type reducer interface {
|
||||
// it only appends the newly added events
|
||||
Reduce() error
|
||||
//AppendEvents appends the passed events to an internal list of events
|
||||
AppendEvents(...EventReader) error
|
||||
AppendEvents(...EventReader)
|
||||
}
|
||||
|
||||
//FilterToReducer filters the events based on the search query, appends all events to the reducer and calls it's reduce function
|
||||
@@ -151,9 +151,8 @@ func (es *Eventstore) FilterToReducer(ctx context.Context, searchQuery *SearchQu
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = r.AppendEvents(events...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.AppendEvents(events...)
|
||||
|
||||
return r.Reduce()
|
||||
}
|
||||
@@ -180,9 +179,7 @@ func (es *Eventstore) FilterToQueryReducer(ctx context.Context, r queryReducer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = r.AppendEvents(events...); err != nil {
|
||||
return err
|
||||
}
|
||||
r.AppendEvents(events...)
|
||||
|
||||
return r.Reduce()
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package eventstore
|
||||
|
||||
import "time"
|
||||
|
||||
func NewWriteModel() *WriteModel {
|
||||
return &WriteModel{
|
||||
Events: []EventReader{},
|
||||
@@ -14,6 +16,7 @@ type WriteModel struct {
|
||||
ProcessedSequence uint64 `json:"-"`
|
||||
Events []EventReader `json:"-"`
|
||||
ResourceOwner string `json:"-"`
|
||||
ChangeDate time.Time `json:"-"`
|
||||
}
|
||||
|
||||
//AppendEvents adds all the events to the read model.
|
||||
@@ -38,6 +41,7 @@ func (wm *WriteModel) Reduce() error {
|
||||
}
|
||||
|
||||
wm.ProcessedSequence = wm.Events[len(wm.Events)-1].Sequence()
|
||||
wm.ChangeDate = wm.Events[len(wm.Events)-1].CreationDate()
|
||||
|
||||
// all events processed and not needed anymore
|
||||
wm.Events = nil
|
||||
|
Reference in New Issue
Block a user