sezaru

sezaru

I have a GenServer (I will call it A) that I connect to a external source (Actually it is a WebSockex process since I connect using websocket) and provide an API to communicate with that source.

A normal API call for A would be something like subscribe_to_channel(channel, callback) which means that it would subscribe that connection to a specific channel and pass all messages from that channel to the callback.

This works great, but the external source limits the number of channel subscriptions to a certain number per connection, let’s say 10. So, after 10 calls to subscribe_to_channel with specific channels, I would need to create a new A process with a new connection and use it to subscribe to new channels.

I was thinking in how to automatize this, what comes to mind is something like poolboy, where I can tell it to initialize like 5 A processes in a pool (and, as result, 5 websocket connections to the external source) and let it handle the subscribe_to_channel calls.

The idea is that A would have another method called available_subscriptions which returns the number of available subscriptions this process can handle. So, for example, if A have 1 channel subscribed, then available_subscriptions will return 9, for 2 channels, it will return 8, and so on.

From that, poolboy could check that function and decide to send the subscribe call to the process in the pool with the least subscriptions currently.

Now, as far as I know, I don’t think I can configure a behavior like that in poolboy, so my question is, is there any library that implements something like that? Or do I need to implement my custom pool with the above described logic?

Thanks!

Showing Posts 1 to 2

tty

tty

AFAIK with poolboy you are on your own and have to implement your custom pooler. Process poolers and message queues are the two most commonly (re)written applications in Erlang/Elixir. Welcome to the club!

At last count we have 4 different implementations of process pooling in our production code. Yes, 4.

sezaru

sezaru OP

Yeah, I guess you are right, I will need to implement a custom pool for that.
I tried to find some library in Hex to do that without success.

Thanks for the heads up!

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews