=encoding utf8

=for comment POD_DERIVED_INDEX_GENERATED

The following documentation is automatically generated.  Please do not edit
this file, but rather the original, inline with Myriad::RPC::Message
at lib/Myriad/RPC/Message.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.

=cut

=head1 NAME

Myriad::RPC::Message - RPC message implementation

=head1 SYNOPSIS

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

=head1 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.

=head2 message_id

The ID of the message given by the requester.

=head2 transport_id

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

=head2 rpc

The name of the procedure we are going to execute.

=head2 who

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

=head2 deadline

An epoch that represents when the timeout of the message.

=head2 args

A JSON encoded string contains the argument of the procedure.

=head2 resposne

The response to this message.

=head2 stash

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

=head2 trace

Tracing information.

=head2 BUILD

Build a new message.

=head2 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.

=head2 from_hash

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

the hash should comply with the format returned by C<as_hash>.

=head2 as_json

returns the message data as a JSON string.

=head2 from_json

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

=head2 is_valid

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

=head2 apply_encoding

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

=head2 apply_decoding

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

=head1 INHERITED METHODS

=over 4

=item L<Object::Pad::UNIVERSAL>

L<BUILDARGS|Object::Pad::UNIVERSAL/BUILDARGS>

=back

=head1 AUTHOR

Deriv Group Services Ltd. C<DERIV@cpan.org>.

See L<Myriad/CONTRIBUTORS> for full details.

=head1 LICENSE

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

