fix: handle sequence correctly in subscription (#1209)

This commit is contained in:
Livio Amstutz
2021-01-27 10:35:01 +01:00
committed by GitHub
parent 6f6d59f380
commit 1d472bac51
129 changed files with 349 additions and 371 deletions

View File

@@ -89,8 +89,8 @@ func (_ *Notification) AggregateTypes() []models.AggregateType {
return []models.AggregateType{es_model.UserAggregate}
}
func (n *Notification) CurrentSequence(event *models.Event) (uint64, error) {
sequence, err := n.view.GetLatestNotificationSequence(string(event.AggregateType))
func (n *Notification) CurrentSequence() (uint64, error) {
sequence, err := n.view.GetLatestNotificationSequence()
if err != nil {
return 0, err
}
@@ -98,7 +98,7 @@ func (n *Notification) CurrentSequence(event *models.Event) (uint64, error) {
}
func (n *Notification) EventQuery() (*models.SearchQuery, error) {
sequence, err := n.view.GetLatestNotificationSequence("")
sequence, err := n.view.GetLatestNotificationSequence()
if err != nil {
return nil, err
}

View File

@@ -63,8 +63,8 @@ func (_ *NotifyUser) AggregateTypes() []es_models.AggregateType {
return []es_models.AggregateType{es_model.UserAggregate, org_es_model.OrgAggregate}
}
func (p *NotifyUser) CurrentSequence(event *es_models.Event) (uint64, error) {
sequence, err := p.view.GetLatestNotifyUserSequence(string(event.AggregateType))
func (p *NotifyUser) CurrentSequence() (uint64, error) {
sequence, err := p.view.GetLatestNotifyUserSequence()
if err != nil {
return 0, err
}
@@ -72,7 +72,7 @@ func (p *NotifyUser) CurrentSequence(event *es_models.Event) (uint64, error) {
}
func (p *NotifyUser) EventQuery() (*es_models.SearchQuery, error) {
sequence, err := p.view.GetLatestNotifyUserSequence("")
sequence, err := p.view.GetLatestNotifyUserSequence()
if err != nil {
return nil, err
}

View File

@@ -9,8 +9,8 @@ const (
notificationTable = "notification.notifications"
)
func (v *View) GetLatestNotificationSequence(aggregateType string) (*repository.CurrentSequence, error) {
return v.latestSequence(notificationTable, aggregateType)
func (v *View) GetLatestNotificationSequence() (*repository.CurrentSequence, error) {
return v.latestSequence(notificationTable)
}
func (v *View) ProcessedNotificationSequence(event *models.Event) error {

View File

@@ -36,8 +36,8 @@ func (v *View) DeleteNotifyUser(userID string, event *models.Event) error {
return v.ProcessedNotifyUserSequence(event)
}
func (v *View) GetLatestNotifyUserSequence(aggregateType string) (*repository.CurrentSequence, error) {
return v.latestSequence(notifyUserTable, aggregateType)
func (v *View) GetLatestNotifyUserSequence() (*repository.CurrentSequence, error) {
return v.latestSequence(notifyUserTable)
}
func (v *View) ProcessedNotifyUserSequence(event *models.Event) error {

View File

@@ -12,15 +12,15 @@ const (
)
func (v *View) saveCurrentSequence(viewName string, event *models.Event) error {
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, string(event.AggregateType), event.Sequence, event.CreationDate)
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, event.Sequence, event.CreationDate)
}
func (v *View) latestSequence(viewName, aggregateType string) (*repository.CurrentSequence, error) {
return repository.LatestSequence(v.Db, sequencesTable, viewName, aggregateType)
func (v *View) latestSequence(viewName string) (*repository.CurrentSequence, error) {
return repository.LatestSequence(v.Db, sequencesTable, viewName)
}
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
}