Giter VIP home page Giter VIP logo

Comments (9)

pimpcapital avatar pimpcapital commented on June 29, 2024

I am not sure if I follow.

public static final RateLimitRule IP_WEB_SOCKET_CONNECTION_RULE =
RateLimitRule.newBuilder()
.setName("ip_web_socket_connection_rule")
.setType(IP)
.setMaxPermits(20)
.setResetPeriod(Duration.ofHours(1))
.build();

This code should limit WebSocket connection to 20 per hour. I think you are concerning that OkHttpClient's auto-retry feature may silently retry and break rate limit.

If this is the case, the proper solution shall be setting OkHttpClient's "retryOnConnectionFailure" field to false?

from io.contek.invoker.

norbert-gaulia avatar norbert-gaulia commented on June 29, 2024

Please check this line

it does not take into account provided resetPeriod, actually resetPeriod is not used anywhere.

from io.contek.invoker.

pimpcapital avatar pimpcapital commented on June 29, 2024

You are right indeed. That was a terrible bug. Will fix and release 2.7.5-SNAPSHOT.
Your comment is much appreciated.

from io.contek.invoker.

norbert-gaulia avatar norbert-gaulia commented on June 29, 2024

Also this line
returns false if acquisition failed due to Timeout, default is 5 seconds, if acquire returns false it needs to bubble up (true/false result) to the caller and abandon the request if acquire returned false.

Right now this method relies on Thread.park of acquirePermission() method, but in 5 seconds it releases park and request is submitted every 5 seconds

from io.contek.invoker.

norbert-gaulia avatar norbert-gaulia commented on June 29, 2024

I would be happy to add PR but i need you Intellij code formatting preset

from io.contek.invoker.

pimpcapital avatar pimpcapital commented on June 29, 2024

I am using google-java-format plugin, which is free from Intellij plugin Market Place. It actually does more than the out-of-box IntelliJ code style. I also recommend "Save Action" plugin.

Regarding the new issue you pointed out. I will need to investigate a bit further before I can fix it. I will be very grateful if you can do a PR for this. Thanks!

from io.contek.invoker.

pimpcapital avatar pimpcapital commented on June 29, 2024

Changing that line to RateLimiter.waitForPermission(limiter, permits);

Will this be enough?

from io.contek.invoker.

norbert-gaulia avatar norbert-gaulia commented on June 29, 2024

Yep perfect, tested - does to job. Although to completely support Bitmex Bucket Re-Fill algorithm it needs a bit more play, but this is good enough. You guys have really some high quality lib here.

from io.contek.invoker.

pimpcapital avatar pimpcapital commented on June 29, 2024

Awesome. The fix is included in 2.7.7-SNAPSHOT. Your contribution is much appreciated!

from io.contek.invoker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.