Skip to content

Commit 511e9f3

Browse files
authored
Merge pull request #14 from zerodha/develop
Adds go-releaser and fixes lag threshold logic
2 parents ba4d0d8 + cda17e3 commit 511e9f3

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # Will trigger only if tag is pushed matching pattern `v*` (Eg: `v0.1.0`)
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: "1.21"
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v5
27+
with:
28+
version: latest
29+
args: release --clean
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
env:
2-
- CGO_ENABLED=1
3-
41
before:
52
hooks:
6-
- make dist
7-
3+
- go mod tidy
4+
85
builds:
9-
- binary: kaf-relay.bin
10-
main: .
6+
- env:
7+
- CGO_ENABLED=1
8+
binary: kaf-relay
119
goos:
12-
- windows
1310
- linux
14-
- netbsd
1511
goarch:
1612
- amd64
1713

1814
archives:
1915
- format: tar.gz
2016
files:
17+
- config.toml.sample
2118
- README.md
2219
- LICENSE

utils.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,25 +349,21 @@ func waitTries(ctx context.Context, b time.Duration) {
349349
}
350350
}
351351

352-
// thresholdExceeded checks if the difference between the offsets is breaching the threshold
352+
// thresholdExceeded checks if the difference between the sum of offsets in all topics is breaching the threshold
353353
func thresholdExceeded(offsetsX, offsetsY kadm.ListedOffsets, max int64) bool {
354+
var diff int64
354355
for t, po := range offsetsX {
355356
for p, x := range po {
356357
y, ok := offsetsY.Lookup(t, p)
357358
if !ok {
358359
continue
359360
}
360361

361-
// check if the difference is breaching threshold
362-
if y.Offset < x.Offset {
363-
if (x.Offset - y.Offset) >= max {
364-
return true
365-
}
366-
}
362+
diff += (x.Offset - y.Offset)
367363
}
368364
}
369365

370-
return false
366+
return diff >= max
371367
}
372368

373369
// isCurrentNode checks if group is active and assigned the topics

0 commit comments

Comments
 (0)