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

ExRated prune expired buckets #408

Open
vincentfretin opened this issue Aug 28, 2020 · 1 comment
Open

ExRated prune expired buckets #408

vincentfretin opened this issue Aug 28, 2020 · 1 comment

Comments

@vincentfretin
Copy link

Hi,
I'm learning Elixir and Phoenix, I looked at how you rate-limit calls to external services. I see you use https://hex.pm/packages/ex_rated in media_resolver
https://github.com/mozilla/reticulum/blob/13c932e81869096ad73879abf0c5cb2a5410c537/lib/ret/media_resolver.ex#L564
but doing a "rated" search in the code
https://github.com/mozilla/reticulum/search?q=rated&type=Code
I didn't find that you start the ex_rated GenServer application that is needed to prune expired buckets from the ETS table at periodic interval (cleanup_rate, default to 60s). Maybe you do and I just didn't find it, if so please close the issue.
Otherwise look at https://github.com/grempe/ex_rated#installation

@vincentfretin
Copy link
Author

vincentfretin commented Aug 28, 2020

As far as I understand the ExRated code, if you do a call to youtube every 8s https://github.com/mozilla/reticulum/blob/13c932e81869096ad73879abf0c5cb2a5410c537/lib/ret/media_resolver.ex#L21
the key change every 8s, see stamp_key at https://github.com/grempe/ex_rated/blob/744c14c679d7a82e5faf3559cb098679e3dd1c30/lib/ex_rated.ex#L203
and it will create a new key in the ETS table when a new youtube link is asked:
https://github.com/grempe/ex_rated/blob/744c14c679d7a82e5faf3559cb098679e3dd1c30/lib/ex_rated.ex#L209

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

No branches or pull requests

1 participant