mirror of
https://github.com/zitadel/zitadel.git
synced 2025-11-16 03:14:23 +00:00
fix(event handling): use internal pubsub for view update (#1118)
* 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
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
sequencesTable = "adminapi.current_sequences"
|
||||
)
|
||||
|
||||
func (v *View) saveCurrentSequence(viewName string, sequence uint64, eventTimeStamp time.Time) error {
|
||||
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence, eventTimeStamp)
|
||||
func (v *View) saveCurrentSequence(viewName string, event *models.Event) error {
|
||||
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, string(event.AggregateType), event.Sequence, event.CreationDate)
|
||||
}
|
||||
|
||||
func (v *View) latestSequence(viewName string) (*repository.CurrentSequence, error) {
|
||||
return repository.LatestSequence(v.Db, sequencesTable, viewName)
|
||||
func (v *View) latestSequence(viewName, aggregateType string) (*repository.CurrentSequence, error) {
|
||||
return repository.LatestSequence(v.Db, sequencesTable, viewName, aggregateType)
|
||||
}
|
||||
|
||||
func (v *View) AllCurrentSequences(db string) ([]*repository.CurrentSequence, error) {
|
||||
@@ -22,7 +24,7 @@ func (v *View) AllCurrentSequences(db string) ([]*repository.CurrentSequence, er
|
||||
}
|
||||
|
||||
func (v *View) updateSpoolerRunSequence(viewName string) error {
|
||||
currentSequence, err := repository.LatestSequence(v.Db, sequencesTable, viewName)
|
||||
currentSequence, err := repository.LatestSequence(v.Db, sequencesTable, viewName, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -30,13 +32,16 @@ func (v *View) updateSpoolerRunSequence(viewName string) error {
|
||||
currentSequence.ViewName = viewName
|
||||
}
|
||||
currentSequence.LastSuccessfulSpoolerRun = time.Now()
|
||||
//update all aggregate types
|
||||
//TODO: not sure if all scenarios work as expected
|
||||
currentSequence.AggregateType = ""
|
||||
return repository.UpdateCurrentSequence(v.Db, sequencesTable, currentSequence)
|
||||
}
|
||||
|
||||
func (v *View) GetCurrentSequence(db, viewName string) (*repository.CurrentSequence, error) {
|
||||
func (v *View) GetCurrentSequence(db, viewName, aggregateType string) (*repository.CurrentSequence, error) {
|
||||
sequenceTable := db + ".current_sequences"
|
||||
fullView := db + "." + viewName
|
||||
return repository.LatestSequence(v.Db, sequenceTable, fullView)
|
||||
return repository.LatestSequence(v.Db, sequenceTable, fullView, aggregateType)
|
||||
}
|
||||
|
||||
func (v *View) ClearView(db, viewName string) error {
|
||||
|
||||
Reference in New Issue
Block a user