thojanssens1

thojanssens1

Understanding the request reference `request_ref` in Mint

When calling Mint.HTTP.request/5, a request identifier request_ref is returned.
Then when streaming the responses with Mint.HTTP.stream/2, I need to wait for messages and make sure that the request reference inside the message received matches with the request reference that was returned by request/5. More can be read here: Mint.HTTP — Mint v1.9.0

I do not actually understand how the messages could include another request reference; I was thinking, maybe it can happen if I execute multiple times in parallel request/5 and stream responses; however I tried spawning multiple processes executing requests, but never I get a message with another request_ref.

How can I reproduce it?

Most Liked

NobbZ

NobbZ

Well, you can start many requests from the same process, all of them will have a unique ref. You can use it to collect individual replies into individual result sets.

entone

entone

The model here, is we start one process per REST resource, and that process manages concurrent requests for that endpoint.

You could easily have one process manage all of your endpoints. But I didn’t want one hot resource to slow everything else down. For example, the Channel resource probably sees 80% more traffic than any other one.

Last Post!

entone

entone

Sorry for the delay, was on vacation.

It’s not a trivial question, and actually something I meant to address. I just forgot to revisit the connection stuff once it was working :wink:

Thanks for the reminder, it is supposed to maintain one connection.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement