gen module - Generic OTP-style calls

A helper module to assist with gen:call-style message parsing and replying. A generic incoming message looks like {$gen_call, {From, Ref}, Message}.

Warning

This is a low level utility module. For handling GenServer-style calls please consider inheriting your Process from GenServer and following the docs.

class pyrlang.gen.GenIncomingCall(mod: str, fun: str, args: list, group_leader: term.pid.Pid, sender: term.pid.Pid, ref: term.reference.Reference, node_name: str)

Bases: pyrlang.gen.GenBase

A helper class which contains elements from the incoming gen:call RPC call message.

args_ = None

Call arguments as a list

fun_ = None

Function name as string (input can be binary, atom or str).

group_leader_ = None

Remote group leader pid, comes in as a part of message.

mod_ = None

Module name as string (input can be binary, atom or str).

class pyrlang.gen.GenIncomingMessage(sender: term.pid.Pid, ref: term.reference.Reference, message, node_name: str)

Bases: pyrlang.gen.GenBase

A helper class which contains elements from a generic incoming gen_server message. For those situations when gen message is not a call, or is an incoming gen_server call.

message_ = None

The last part of the incoming message, the payload.

pyrlang.gen.parse_gen_call(msg, node_name: str)

Determine if msg is a gen:call message and create a GenIncomingCall object.

Note

Module and function parameters to rpc:call can be binary, ASCII strings or atoms.

Note

You do not need to import module in rpc:call, it is done by Rex.

Parameters:
  • node_name -- Name of the current node, used to route replies back to the caller
  • msg -- An Erlang tuple hopefully starting with a '$gen_call'
Returns:

str with error if msg wasn't a call message, otherwise constructs and returns a GenIncomingCall object.

pyrlang.gen.parse_gen_message(msg, node_name: str)

Might be an 'is_auth' request which is not a call

Returns:string on error, otherwise a GenIncomingMessage object