Good Evening All,
I’m trying to figure out a way to create a simple inline event broadcaster adapter for a GenStage system that uses a BroadcastDispatcher.
In my test suite, I’d really love to be able to test against something as simple as:
defmodule InlineAdapter do
def sync_notify(event) do
Enum.each(magically_find_consumer_modules(), fn(consumer) ->
In dev/production, the adapter implementation would be like the example: https://github.com/elixir-lang/gen_stage/blob/master/examples/gen_event.exs#L31
So the issue is, how do I implement
Or is there another way I should be going about this?
Why do you want to magically find consumers instead of explicitly having consumers subscribe to producer which is how GenStage works?
I simply want to be able to test against a completely synchronous system. I don’t want to have to poll or sleep during my test suite or otherwise worry that there is pending events to be processed after the
sync_notify function has returned.
Pulled the example from GenStage and wrote a little comment with what I’m trying to accomplish.
So my thinking was… if I could figure out which consumers have subscribed and get their modules, I could write a simple Enum.each and be on my merry way.