Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Call a gen.ServerProcess? #100

Closed
finalclass opened this issue Apr 13, 2022 · 5 comments
Closed

How to Call a gen.ServerProcess? #100

finalclass opened this issue Apr 13, 2022 · 5 comments
Labels

Comments

@finalclass
Copy link

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

This comment has been minimized.

@halturin
Copy link
Collaborator

halturin commented Apr 13, 2022

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).

  • gen.ServerProcess is available as a first argument in the callbacks like Init, HandleCast, HandleCall etc. (see gen.ServerBehavior interface)
  • gen.Process is an interface returned by Spawn method.

@halturin
Copy link
Collaborator

@finalclass
Copy link
Author

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants