adamu

adamu

Boing - Debouncer with HTTP client support

Boing is a small package that provides the ability to debounce HTTP requests, with implementations included for Tesla and Req.

Example for Tesla from the README:

iex(1)> client = Tesla.client([Boing.TeslaMiddleware])
%Tesla.Client{...}
iex(2)> for _ <- 1..3, do: spawn(fn -> dbg(Tesla.get(client, "http://example.com")) end)
[#PID<0.208.0>, #PID<0.209.0>, #PID<0.210.0>]
Tesla.get(client, "http://example.com") #=> {:error, [debounced: "http://example.com"]}
Tesla.get(client, "http://example.com") #=> {:error, [debounced: "http://example.com"]}
Tesla.get(client, "http://example.com") #=> {:ok, %Tesla.Env{body: ...}}

This initial version only debounces GET requests. It also exposes the debouncer that can be used to integrate with other HTTP clients or any other application.

The debouncer is implemented using Registry, DynamicSupervisor, and :gen_statem. I’m hoping that relying on standard components helps keep this implementation performant, but feedback and suggestions for potential improvements are also welcome.

My motivation:

I have a project that handles webhook events concurrently, where many events are for the same remote resource. The event handlers for those resources result in many identical API requests being made against the remote service. I found that debouncing the identical requests, allowing only the latest one to go through (and the other event handlers to terminate), was an effective way to reduce redundant usage of the remote API.

Where Next?

Popular in Announcing Top

jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
Crowdhailer
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure). 1.0-rc.1 is now available. To use it re...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 11283 107
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New
Flo0807
Hello everyone! I am excited to share our heart project Backpex with you. After building several Phoenix applications, we realized that...
New

Other popular topics Top

grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement