Server to Server RPC calls

Hello!
Im currently aiming to move some CPU heavy tasks to GO (using lua for most basic stuff), but I cant seem to get a way to make the server call the GO registered RPC.

Took a read on the server to server documentation and it lacks any help on how you call the registered RPC.

Any kind of code example in any of the 3 supported languages will be gold.

If there is indeed documentation or an example on how to call an RPC from the server itself or to another server, please point me to it.

Thx!

Hi @KittySkin,

can you clarify on what you’re trying to do (and post a sample of your code)? Are you trying to call a custom Go RPC from a separate custom server?

Hello! Yeah, im trying to call a custom Go RPC on a separate server.

The aim of this is to send the output of a json_encode to the Go server, process its data, populate it, etc and then send it again to the Lua server.

The code its something like this:

function M.something(args, args)

objects = nk.storage_read(collectionToRead)

processedData = customRPCCall(context, nk.json_encode(objects)

doSomethingHere

return processedData

end

This is the basic concept Im aiming for. It could either be calling a custom RPC call on a separate nakama server or either on the same server if its possible to register both Go and Lua RPCs on it.

In that case, it’d be better to write the whole RPC function M.something() in Go instead of mixing languages, is there a reason you can’t do that? You can very well setup both runtimes (Lua and Go) in the same Nakama server (see Nakama: Introduction | Heroic Labs Documentation). I wouldn’t recommend calling Go RPCs from a Lua RPC in the same server, as you’d be just adding unnecessary overhead from doing so.

Im just doing that, making the whole function in Go instead. Atlhough the question still remains, is it possible to call an RPC within the server?

Yes, you could do that by making a request to localhost, like 127.0.0.1:7350/v2/rpc/your_function.
Check an example here: Nakama: Server Runtime Examples | Heroic Labs Documentation