Skip to content
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

Deprecate #36

Closed
wants to merge 5 commits into from
Closed

Deprecate #36

wants to merge 5 commits into from

Conversation

ruslandoga
Copy link


plug :#{plug_name} # when action in ...

#{render_custom_plug(config) |> String.replace("\n", "\n ")}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example warning:

15:54:07.496 [warning] Hummer.Plug is deprecated. Please consider replacing it with a function plug:

    plug :rate_limit_video_upload # when action in ...

    defp rate_limit_video_upload(conn, _opts) do
      request_id = get_session(conn, :user_id)

      # note that request_id might be nil
      key = "video:upload:#{request_id}"
      scale = 60000
      limit = 10

      case Hammer.check_rate(key, scale, limit) do
        {:allow, _count} ->
          conn

        {:deny, _limit} ->
          conn |> send_resp(429, "Too Many Requests") |> halt()

        {:error, _reason} ->
          conn |> send_resp(429, "Too Many Requests") |> halt()
      end
    end

@epinault epinault marked this pull request as ready for review December 7, 2024 00:12
lib/hammer_plug.ex Outdated Show resolved Hide resolved
lib/hammer_plug.ex Outdated Show resolved Hide resolved
@ruslandoga ruslandoga closed this Dec 7, 2024
@ruslandoga ruslandoga deleted the deprecate branch December 7, 2024 00:44
@epinault
Copy link
Contributor

epinault commented Dec 7, 2024

@ruslandoga would it be helpful to chat in person ? I think we are misunderstanding each other you are misunderstanding my intention here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants