ergo-services / ergo

An actor-based Framework with network transparency for creating event-driven architecture in Golang. Inspired by Erlang. Zero dependencies.
https://docs.ergo.services
MIT License
3.51k stars 138 forks source link

How to Call a gen.ServerProcess? #100

Closed finalclass closed 2 years ago

finalclass commented 2 years ago

Thank you for the great work you have done, I'm very excited about this library.

I think there is a problem with documentation. On pkg.go.dev there is an old version of documentation.

I browsed all the examples and I couldn't find information on how to make a Call request to a gen server process. What I wish is to get a process by name and then make a Call to it so that HandleCall will fire. In erlang it's easy and can be achieved with gen_server:call(pid,...) but in ergo it seams that I need to get hold of the gen.ServerProcess struct instance which appears to not be exposed.

Please help me with that.

Iamwaterlemon commented 2 years ago

你的邮件已查收,谢谢!!!       ------waterlemon

halturin commented 2 years ago

Thank you for the question. Yeah, there is a lack of documentation, and we are working on it.

The Cast and Call are gen.ServerProcess methods and are available within an actor only (to be specific - within the actor's callbacks). To operate with an actor from outside, you should use gen.Process methods: Send method for async messaging (will be invoked HandleInfo callback) or Direct to make sync calls to the actor (will be invoked HandleDirect).

halturin commented 2 years ago

just checked out pkg.go.dev - it has the latest version. Here are links you might find useful

https://pkg.go.dev/github.com/ergo-services/ergo@v1.999.202/gen#ServerProcess https://pkg.go.dev/github.com/ergo-services/ergo@v1.999.202/gen#Process https://pkg.go.dev/github.com/ergo-services/ergo@v1.999.202/gen#ServerBehavior

finalclass commented 2 years ago

Thanks a lot for your answer. Indeed the docs are there. I got confused because the link on the ergo.services website leads to https://pkg.go.dev/github.com/halturin/ergo

image

Now all is clear. Thanks again. ergo is AMAZING!

halturin commented 2 years ago

oh, sorry for that :) yeah, it should have been updated.