RudolfVonKrugstein1

RudolfVonKrugstein1

A GenStage allowing me to reproduce all events send so far

Hi,

I am trying to build a gen stage that buffers incoming data, and sends it all to any new subscribed consumer.

Background: The GenStage buffers a file, that is created on the fly and the Consumers serve this file to clients in a Phoenix application

In other words: Whenever a new consumer is subscribed, all Events that have been send by this GenStage so far are “resend” to this consumer (but of course not to any existing consumer).

What I got so far:

  • Of course I can simply buffer all Events send by the GenStage
  • I subscribe new consumers by an explicit function. This function takes care of sending the events buffered explicitly to the consumer.

But here are my questions/problems:

  • The GenStage documentation says, that if no consumers are subscribed, events are buffered. When consumers are subscribed, they are not. This means that I cannot rely on some events, hat are in my self created buffer are send the normal way or not. Can I somehow completely disable the buffer behavior of GenStage?
  • When I say, that I send the events “explicitly” to the consumer, that means the consumer has to handle the buffered events in some other way. Is it possible to send the buffered events the normal GenStage way, but only sending it to this one (new consumer)?

Thank you!

Marked As Solved

LostKobrakai

LostKobrakai

You could “register” with the shared system to receive initial state (what it knows about now) and for it sending any later additions as messages.

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
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
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31307 143
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
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