Skip to content

Commit

Permalink
Merge pull request #10 from mundipagg/feature/FHPROC-144-goroutine-bug
Browse files Browse the repository at this point in the history
[FHPROC-144] Goroutine Bug
  • Loading branch information
diegodesousas authored Aug 12, 2021
2 parents 7eed136 + 411ed7c commit 086db27
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (b *buffer) clear() {
b.items = make([]interface{}, b.cap)
go func() {
b.chunks <- entry{
items: events,
items: events,
retries: cap(b.chunks),
}
}()
Expand Down Expand Up @@ -75,7 +75,7 @@ type Config struct {
}

type entry struct {
items []interface{}
items []interface{}
retries int
}

Expand Down Expand Up @@ -115,15 +115,18 @@ func (b *buffer) consumer(c Config) {
}
}()
for events := range b.chunks {
err := c.OnOverflow(events.items)
if err != nil {
go func(events entry) {
go func(events entry) {
err := c.OnOverflow(events.items)
if err != nil {
go func(events entry) {
events.retries--
if events.retries >= 0 {
time.Sleep(b.backoff)
b.chunks <- events
}
}(events)
}
}(events)
}
}(events)

}
}

0 comments on commit 086db27

Please sign in to comment.