Skip to content

Commit

Permalink
Add ResetFailCount to subscriberAPI (redhat-cne#103)
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Ding <[email protected]>
  • Loading branch information
jzding committed Aug 26, 2024
1 parent 51aca34 commit 273e205
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/protocol/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ func (h *Server) SendTo(wg *sync.WaitGroup, clientID uuid.UUID, clientAddress, r
}
log.Errorf("connection lost addressing %s", clientAddress)
} else {
h.subscriberAPI.ResetFailCount(clientID)
localmetrics.UpdateEventCreatedCount(resourceAddress, localmetrics.SUCCESS, 1)
h.DataOut <- &channel.DataChan{
Address: resourceAddress,
Expand Down
8 changes: 8 additions & 0 deletions v1/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ func (p *API) IncFailCountToFail(clientID uuid.UUID) bool {
return false
}

// ResetFailCount ..reset fail count
func (p *API) ResetFailCount(clientID uuid.UUID) {
if subStore, ok := p.SubscriberStore.Get(clientID); ok {
subStore.ResetFailCount()
p.SubscriberStore.Set(clientID, subStore)
}
}

// FailCountThreshold .. get threshold
func (p *API) FailCountThreshold() int {
return subscriber.SetConnectionToFailAfter
Expand Down

0 comments on commit 273e205

Please sign in to comment.