pipy icon indicating copy to clipboard operation
pipy copied to clipboard

HTTP response code based failovers with caching

Open kickthemooon opened this issue 3 years ago • 3 comments

Could I achieve HTTP response code based failovers with caching using pipy?

What I mean is

  • Pipy receives a request and forwards it to the primary backend
  • If the request fails with e.g. 404, pipy retries the request with a secondary backend
  • Failed primary backend request urls are cached e.g. on disc
  • For performance, request urls present in the list of cached urls are forwarded to the secondary backend skipping the primary

Is this something I could do with pipy?

kickthemooon avatar Aug 29 '22 08:08 kickthemooon

This is a common requested feature but unfortunately, it's pretty hard to do in Pipy right now because the core logic that is involved here is some kind of loops in the pipelines, which is not implemented yet. However, we do have plans to support loops. We've come up with some ideas on the design actually. Hopefully it'll be done in the coming releases.

pajama-coder avatar Aug 30 '22 13:08 pajama-coder

@kickthemooon With the latest commit ecbd3b03f53c21d8852e85968936ea69e68c77cc, a new filter replay() is introduced, by which the logic you are looking to can be implemented. Also, the 'unhealthy' parameter for LoadBalancers can be useful to skip ill-responding backends. Please checkout out the builtin reference doc for the new replay() filter for detailed explanation on how to use it. You can also find an example there.

pajama-coder avatar Sep 17 '22 12:09 pajama-coder

Hi @kickthemooon Requested feature has been added. Can you please help to confirm if it fulfills your use case?

naqvis avatar Sep 20 '22 03:09 naqvis

Closing this issue, as looping construct is included in latest version of pipy.

naqvis avatar Oct 22 '22 14:10 naqvis