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

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
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 record...
New
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
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
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
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
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
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
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
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement