The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Myriad::RPC::Message - RPC message implementation

SYNOPSIS

 Myriad::RPC::Message->new();

DESCRIPTION

This class is to handle the decoding/encoding and verification of the RPC messages received from the transport layer. It will throw an exception when the message is invalid or doesn't match the structure.

message_id

The ID of the message given by the requester.

transport_id

The ID of the message given by Redis, to be used in xack later.

rpc

The name of the procedure we are going to execute.

who

A string that should identify the sender of the message for the transport.

deadline

An epoch that represents when the timeout of the message.

args

A JSON encoded string contains the argument of the procedure.

response

The response to this message.

stash

information related to the request should be returned back to the requester.

trace

Tracing information.

BUILD

Build a new message.

as_hash

Return a simple hash with the message data, it mustn't return nested hashes so it will convert them to JSON encoded strings.

from_hash

a static method (can't be done with Object::Pad currently) that tries to parse a hash and return a Myriad::RPC::Message.

the hash should comply with the format returned by as_hash.

as_json

returns the message data as a JSON string.

from_json

a static method that tries to parse a JSON string and return a Myriad::RPC::Message.

is_valid

A static method used in the from_* methods family to make sure that we have the needed information.

apply_encoding

A helper method to enode the hash fields into JSON string.

apply_decoding

A helper sub to decode some field from JSON string into Perl hashes.

passed_deadline

Check if the message is stil relevent

INHERITED METHODS

Object::Pad::UNIVERSAL

BUILDARGS

AUTHOR

Deriv Group Services Ltd. DERIV@cpan.org.

See "CONTRIBUTORS" in Myriad for full details.

LICENSE

Copyright Deriv Group Services Ltd 2020-2022. Licensed under the same terms as Perl itself.