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: https://hexdocs.pm/mint/Mint.HTTP.html#stream/2-responses

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

I’ve got a small client I wrote for the ex_ari library, you can check out the source here, https://github.com/CityBaseInc/ex_ari/blob/master/lib/ex_ari/http_client.ex

and it’s usage here, https://github.com/CityBaseInc/ex_ari/blob/master/lib/ex_ari/http/asterisk.ex

and here

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.

Where Next?

Popular in Questions Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement