Skip to content

Commit

Permalink
Merge pull request #14 from zerodha/develop
Browse files Browse the repository at this point in the history
Adds go-releaser and fixes lag threshold logic
  • Loading branch information
joeirimpan authored Jan 17, 2024
2 parents ba4d0d8 + cda17e3 commit 511e9f3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: goreleaser

on:
push:
tags:
- "v*" # Will trigger only if tag is pushed matching pattern `v*` (Eg: `v0.1.0`)

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 6 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
env:
- CGO_ENABLED=1

before:
hooks:
- make dist

- go mod tidy
builds:
- binary: kaf-relay.bin
main: .
- env:
- CGO_ENABLED=1
binary: kaf-relay
goos:
- windows
- linux
- netbsd
goarch:
- amd64

archives:
- format: tar.gz
files:
- config.toml.sample
- README.md
- LICENSE
12 changes: 4 additions & 8 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,25 +349,21 @@ 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)
if !ok {
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
Expand Down

0 comments on commit 511e9f3

Please sign in to comment.