gen_server:cast/call and {via, Module, ViaName}

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

gen_server:cast/call and {via, Module, ViaName}

t ty
Hello,

Looking a the code I notice that a gen_server:cast({via, M, N}, Msg) would use M:send/2 but there does not seem to be a similar functionality for gen_server:call/2.

Was this intentional ?

Thanks 

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server:cast/call and {via, Module, ViaName}

Loïc Hoguin-3
gen_server:call/2 calls gen:call which handles the via tuple.

On 07/16/2018 04:38 PM, T Ty wrote:

> Hello,
>
> Looking a the code I notice that a gen_server:cast({via, M, N}, Msg)
> would use M:send/2 but there does not seem to be a similar functionality
> for gen_server:call/2.
>
> Was this intentional ?
>
> Thanks
>
>
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
>

--
Loïc Hoguin
https://ninenines.eu
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server:cast/call and {via, Module, ViaName}

t ty
gen:call uses erlang:send/2 after finding the pid() using the via tuple.

Where else for gen_server:cast (line 224) it uses the ViaModule:send/2 function instead of erlang:send/2


On Mon, Jul 16, 2018 at 3:43 PM, Loïc Hoguin <[hidden email]> wrote:
gen_server:call/2 calls gen:call which handles the via tuple.


On 07/16/2018 04:38 PM, T Ty wrote:
Hello,

Looking a the code I notice that a gen_server:cast({via, M, N}, Msg) would use M:send/2 but there does not seem to be a similar functionality for gen_server:call/2.

Was this intentional ?

Thanks


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


--
Loïc Hoguin
https://ninenines.eu


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server:cast/call and {via, Module, ViaName}

黃耀賢 (Yau-Hsien Huang)
gen_server:call/2 performs synchronous approach, while gen_server:cast/2, asynchronous approach.

On Mon, Jul 16, 2018 at 11:18 PM, T Ty <[hidden email]> wrote:
gen:call uses erlang:send/2 after finding the pid() using the via tuple.

Where else for gen_server:cast (line 224) it uses the ViaModule:send/2 function instead of erlang:send/2


On Mon, Jul 16, 2018 at 3:43 PM, Loïc Hoguin <[hidden email]> wrote:
gen_server:call/2 calls gen:call which handles the via tuple.


On 07/16/2018 04:38 PM, T Ty wrote:
Hello,

Looking a the code I notice that a gen_server:cast({via, M, N}, Msg) would use M:send/2 but there does not seem to be a similar functionality for gen_server:call/2.

Was this intentional ?

Thanks


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


--
Loïc Hoguin
https://ninenines.eu


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions




--

Best Regards.

--- Y-H. H.


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server:cast/call and {via, Module, ViaName}

t ty
Simply put what I was trying to achieve is the following: By using {via, ViaModule, Name} I was trying to trap the cast/calls to a gen_server and manipulate the outgoing message. If the message is "large" (based on the message tuple structure) I can push the message via a separate TCP socket mimicking a separation between data and command channel to avoid saturating the disterl pipe.

In any case I'll look at a different setup.

On Mon, Jul 16, 2018 at 4:38 PM, 黃耀賢 (Yau-Hsien Huang) <[hidden email]> wrote:
gen_server:call/2 performs synchronous approach, while gen_server:cast/2, asynchronous approach.

On Mon, Jul 16, 2018 at 11:18 PM, T Ty <[hidden email]> wrote:
gen:call uses erlang:send/2 after finding the pid() using the via tuple.

Where else for gen_server:cast (line 224) it uses the ViaModule:send/2 function instead of erlang:send/2


On Mon, Jul 16, 2018 at 3:43 PM, Loïc Hoguin <[hidden email]> wrote:
gen_server:call/2 calls gen:call which handles the via tuple.


On 07/16/2018 04:38 PM, T Ty wrote:
Hello,

Looking a the code I notice that a gen_server:cast({via, M, N}, Msg) would use M:send/2 but there does not seem to be a similar functionality for gen_server:call/2.

Was this intentional ?

Thanks


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


--
Loïc Hoguin
https://ninenines.eu


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions




--

Best Regards.

--- Y-H. H.


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions