Skip to content

Conversation

@michalmuskala
Copy link
Owner

No description provided.

"""
@spec conditional_throttle(Plug.Conn.t, term, Keyword.t) :: PlugAttack.rule
def conditional_throttle(conn, key, opts) do
Copy link
Owner Author

Choose a reason for hiding this comment

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

@ericmj What do you think about this? Would this work for hexpm?

## Race conditions
Because the counter is imcremented lazily, there's a possible race condition,
Copy link

Choose a reason for hiding this comment

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

incremented*

if rem >= 0 do
Plug.Conn.register_before_send(conn, fn conn ->
before_send_throttle(conn, storage, key, now, period, expires_at, limit, rem)
end)
Copy link

Choose a reason for hiding this comment

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

If this returns a conn it should be added to the PlugAttack.rule type right?

@ericmj
Copy link

ericmj commented Jul 24, 2017

Ping? :)

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.

3 participants