diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5062485 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + + services: + valkey: + image: valkey/valkey:latest + ports: + - 6379:6379 + options: >- + --health-cmd "valkey-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: true + + - name: Install dependencies + run: go mod download + + - name: Run tests + run: go test -v ./... + env: + TEST_REDIS_ADDR: localhost:6379 \ No newline at end of file diff --git a/README.md b/README.md index c901bd3..d3b9586 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ ruelimit implements high-performance rate limiting algorithms with both in-memor Distributed variants built on top of [redis/rueidis](https://github.com/redis/rueidis) with auto-pipelining. The in-memory variants use a sharded lockable map. -[Godoc](https://pkg.go.dev/github.com/iamcalledrob/ruerate) +[![Go Reference](https://pkg.go.dev/badge/github.com/iamcalledrob/ruerate.svg)](https://pkg.go.dev/github.com/iamcalledrob/ruerate) + +[![Test](https://github.com/iamcalledrob/ruerate/actions/workflows/test.yml/badge.svg)](https://github.com/iamcalledrob/ruerate/actions/workflows/test.yml) ## Features @@ -30,7 +32,7 @@ with occasional bursts. ### Configuration The `tokenbucket.LimiterOpts` struct defines the bucket behavior: -``` +```golang type LimiterOpts struct { RatePerSec float64 // How many tokens are added to the bucket per second Capacity int64 // Maximum tokens the bucket can hold @@ -81,7 +83,7 @@ loops, i.e. with the local in-memory variants. ### Configuration The `backoff.LimiterOpts` struct defines the bucket behavior: -``` +```golang type LimiterOpts struct { BaseWait time.Duration // Minimum wait between attempts MaxWait time.Duration // Maximum "lockout" duration