GithubHelp home page GithubHelp logo

jegfish / goroyale Goto Github PK

View Code? Open in Web Editor NEW
10.0 0.0 2.0 45 KB

A Golang wrapper for the Clash Royale API at https://royaleapi.com/.

License: MIT License

Go 100.00%
golang clashroyale clash-royale clash-royale-api

goroyale's People

Contributors

jegfish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goroyale's Issues

Ratelimit handling

New/improved ratelimit handling besides an error message now implemented. It's still up to the user what to do with it but it's easier to handle. Here's a quick example:

switch e := err.(type) {
case goroyale.RatelimitError:
	// RatelimitError.RetryAfter is a time.Duration to wait before sending another request to the API.
	time.Sleep(e.RetryAfter)
}

More pressing issues

  • If multiple goroutines are running requests you can run into 429s. Ideas to fix:
    • Have rate limit remaining be a channel requests draw from and if there's nothing in the channel the request doesn't run. Problem with this is x-ratelimit-limit is not guaranteed to stay at 5 and the channel buffer size will probably need to be manually updated.

Some ideas for how to improve this in the future

  • Queue up requests and do something such as:
    • Still tell the user the ratelimit happened
    • Silently continue
    • Threshold of queued requests before flipping out

If anyone decides to use this lib I'd love to have some input on this.

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.