diff --git a/.goreleaser.yml b/.goreleaser.yml index c06dedc..f7761a8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,7 +13,6 @@ builds: archives: - format: tar.gz - rlcp: true files: - config.toml.sample - README.md diff --git a/utils.go b/utils.go index 449bbaa..ce084a2 100644 --- a/utils.go +++ b/utils.go @@ -349,8 +349,9 @@ func waitTries(ctx context.Context, b time.Duration) { } } -// thresholdExceeded checks if the difference between the offsets is breaching the threshold +// thresholdExceeded checks if the difference between the sum of offsets in all topics is breaching the threshold func thresholdExceeded(offsetsX, offsetsY kadm.ListedOffsets, max int64) bool { + var diff int64 for t, po := range offsetsX { for p, x := range po { y, ok := offsetsY.Lookup(t, p) @@ -358,16 +359,11 @@ func thresholdExceeded(offsetsX, offsetsY kadm.ListedOffsets, max int64) bool { continue } - // check if the difference is breaching threshold - if y.Offset < x.Offset { - if (x.Offset - y.Offset) >= max { - return true - } - } + diff += (x.Offset - y.Offset) } } - return false + return diff >= max } // isCurrentNode checks if group is active and assigned the topics