-
Notifications
You must be signed in to change notification settings - Fork 7
bug fix: Replace anonymous functions with &Mod.fun/arity #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
29cb4b6
update dependencies
milmazz 9755c10
remove compilation warnings
milmazz 5b7e385
review docs
milmazz da302e3
pass functions in the style &Mod.fun/arity
milmazz 007dcfa
add original ci from fabian
milmazz c68c540
add memcached service
milmazz e68ce32
remove config directory
milmazz f4b05df
set a default value for compile opts
milmazz 20156be
remove ex2ms dependency
milmazz 02be457
bump elixir/erlang versions in ci
milmazz 9430405
add ExLimiter.DataCase
milmazz 6b9c123
remove ExLimiter.Utils module
milmazz ca4ec2e
fix compile options for pruner
milmazz 123e431
apply formatter in unit test suite
milmazz 2ccd44a
add unit test to verify deletion of expired records
milmazz 331561a
bump minimum elixir version in ci
milmazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Elixir CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["master"] | ||
| pull_request: | ||
| branches: ["master"] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build and test | ||
| runs-on: ubuntu-latest | ||
| services: | ||
| memcached: | ||
| image: memcached:alpine | ||
| ports: | ||
| - 11211:11211 | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - elixir: "1.17" | ||
| otp: "27" | ||
| - elixir: "1.19" | ||
| otp: "28" | ||
| lint: true | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Elixir | ||
| uses: erlef/setup-beam@v1 | ||
| with: | ||
| otp-version: ${{matrix.otp}} | ||
| elixir-version: ${{matrix.elixir}} | ||
|
|
||
| - name: Restore dependencies cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: deps | ||
| key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | ||
| restore-keys: ${{ runner.os }}-mix- | ||
|
|
||
| - name: Install dependencies | ||
| run: mix deps.get | ||
|
|
||
| - name: Compile | ||
| run: mix compile --warnings-as-errors | ||
|
|
||
| - name: Run tests | ||
| run: mix test | ||
|
|
||
| - name: checks that the mix.lock file has no unused deps | ||
| run: mix deps.unlock --check-unused | ||
| if: ${{ matrix.lint }} | ||
|
|
||
| - name: check if files are already formatted | ||
| run: mix format --check-formatted | ||
| if: ${{ matrix.lint }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,26 @@ | ||
| defmodule ExLimiter do | ||
| @moduledoc """ | ||
| Configurable, leaky bucket rate limiting. You can define your own storage backend by | ||
| Configurable, leaky bucket rate limiting. | ||
|
|
||
| You can define your own storage backend by | ||
| implementing the `ExLimiter.Storage` behaviour, and configuring it with | ||
|
|
||
| ``` | ||
| config :ex_limiter, :storage, MyStorage | ||
| ``` | ||
| config :ex_limiter, :storage, MyStorage | ||
|
|
||
|
|
||
| usage once configured is: | ||
|
|
||
| ``` | ||
| case ExLimiter.consume(bucket, 1, scale: 1000, limit: 5) do | ||
| {:ok, bucket} -> #do some work | ||
| {:error, :rate_limited} -> #fail | ||
| end | ||
| ``` | ||
| case ExLimiter.consume(bucket, 1, scale: 1000, limit: 5) do | ||
| {:ok, bucket} -> #do some work | ||
| {:error, :rate_limited} -> #fail | ||
| end | ||
|
|
||
| Additionally, if you want to have multiple rate limiters with diverse backend implementations, | ||
| you can use the `ExLimiter.Base` macro, like so: | ||
|
|
||
| ``` | ||
| defmodule MyLimiter do | ||
| use ExLimiter.Base, storage: MyStorage | ||
| end | ||
| ``` | ||
| defmodule MyLimiter do | ||
| use ExLimiter.Base, storage: MyStorage | ||
| end | ||
| """ | ||
| use ExLimiter.Base, storage: Application.get_env(:ex_limiter, :storage) | ||
| use ExLimiter.Base, storage: Application.compile_env(:ex_limiter, :storage, ExLimiter.Storage.Memcache) | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main bug fix.