lapinkoira
lapinkoira

Reputation: 8988

Can a Dispatcher access it's parent Producer methods/attributes?

Can a custom dispatcher made with @behavior GenStage.Dispatcher access its parent modules which invokes him as {:producer, state, dispatcher: CustomDispatcher} ?

I have realized the dispatcher is launched within the same process than the producer.

If I for example try to launch a handle_call from the dispatcher to the producer then I will receive:

GenStage.call(producer, :test)                   
** (exit) exited in: GenServer.call(#PID<0.1575.0>, :test, 5000)
    ** (EXIT) process attempted to call itself
    (elixir) lib/gen_server.ex:917: GenServer.call/3

So having this error, is there any other obvious way to access producer's methods?

I know you can initialize the dispatcher with params but I would like to access producer methods/state because they are modified withing producer callbacks

Upvotes: 0

Views: 54

Answers (0)

Related Questions