Skip to content

Commit

Permalink
added changes according to brendan's recommandations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Facchetti committed Mar 29, 2022
1 parent 0ee530f commit 87e75dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions pkg/gateway/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ func (g *gateway) updateFromIterator(ctx context.Context, ticker *time.Ticker, g

for {
docs, err := gwIterator.Next(ctx, -1)
successful := true

for ; docs != nil && err == nil; docs, err = gwIterator.Next(ctx, -1) {
g.updateGateways(docs.GatewayDocuments)
}
if err != nil {
successful = false
g.log.Error(err)
}

if successful {
} else {
g.lastChangefeed.Store(time.Now())
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ func (g *gateway) Run(ctx context.Context, done chan<- struct{}) {
}

func (g *gateway) updateGateway(doc *api.GatewayDocument) {
g.mu.Lock()
defer g.mu.Unlock()

if doc.Gateway.Deleting {
// https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed-design-patterns#deletes
Expand All @@ -219,8 +221,6 @@ func (g *gateway) updateGateway(doc *api.GatewayDocument) {
}

func (g *gateway) updateGateways(docs []*api.GatewayDocument) {
g.mu.Lock()
defer g.mu.Unlock()
for _, doc := range docs {
g.updateGateway(doc)
}
Expand Down

0 comments on commit 87e75dd

Please sign in to comment.