Giter Site home page Giter Site logo

Comments (10)

wedneyyuri avatar wedneyyuri commented on May 19, 2024 7

Hi @asciimoo do you have any example using your retry solution?

from colly.

olivierpons avatar olivierpons commented on May 19, 2024 4
    c.OnError(func(resp *colly.Response, err error) {
        resp.Request.Retry()
    })

from colly.

samirsss avatar samirsss commented on May 19, 2024 2

bump on any example - since it helps give users a clear idea on how you intend users to use it.

from colly.

asciimoo avatar asciimoo commented on May 19, 2024

@xg-wang Currently this is not supported by default, but it's definitely a useful feature. It could be achieved by adding a Retry() member function to the Request object. What do you think?

from colly.

xg-wang avatar xg-wang commented on May 19, 2024

Or we can do it on [http_backend](https://github.com/gocolly/colly/blob/master/http_backend.go#L156) level by adding another LimitRule.Retry.

from colly.

asciimoo avatar asciimoo commented on May 19, 2024

@xg-wang yes, that is another good approach, however it gives less flexibility to manage retries imo. If it is a part of the Request object, then we are able to decide that on which returned status codes we want to perform further requests.
What are the benefits of extending LimitRule?

from colly.

xg-wang avatar xg-wang commented on May 19, 2024

@asciimoo The Response has all the information that Request have. By extending LimitRule is more consistent as it already has Delay and Parallelism, it is quite natural to specify the retry attempt number here imo.

from colly.

asciimoo avatar asciimoo commented on May 19, 2024

By extending LimitRule is more consistent as it already has Delay and Parallelism, it is quite natural to specify the retry attempt number here imo.

LimitRule doesn't feel like the right place for me to handle request resubmission, since it is responsible for limiting requests and not to perform requests again.
What if we want to increase the delay between retries or just print a debug message on each retry? It doesn't seem to be achievable with the LimitRule approach.

I've implemented the Request.Retry() solution on branch retry: 03c5f59 . It feels more intuitive and flexible for me so if you like this solution I'll merge it.

from colly.

xg-wang avatar xg-wang commented on May 19, 2024

I'm down for it. Looks good.

from colly.

samirsss avatar samirsss commented on May 19, 2024

@olivierpons thanks for the response. I did add retry logic once i due in a bit into the codebase. I wanted to limit the number of retries before i give up.

from colly.

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.