NAME

Myriad::Role::RPC - microservice RPC abstraction

SYNOPSIS

my $rpc = $myriad->rpc;

DESCRIPTION

Implementation

Note that this is defined as a rôle, so it does not provide a concrete implementation - instead, see classes such as:

METHODS

The following methods are required in any concrete classes which implement this rôle.

start

Activate RPC - begin listening for messages.

Expected to return a Future which resolves once we think this instance is ready and able to process requests.

create_from_sink

Register a new RPC method and attach a Ryu::Sink to be able to publish messages when they are received.

stop

Deäctivate RPC - stop listening for messages.

This is the counterpart to "start".

Expected to return a Future which resolves once we are guaranteed not to pick up any further new requests.

reply_success

Reply back to the sender of the message with success payload. The method will take the raw response and take care of how we are going to encapsulate it.

  • message - The message we are processing.

  • response - The success response.

reply_error

Same concept of reply_success but for errors.

  • message - the message we are processing

  • error - the Myriad::Exception that happened while processing the message

drop

This should be used to handle dead messages (messages that we couldn't even parse).

It doesn't matter how the implementation is going to deal with it (delete it/ move it to another queue ..etc) the RPC handler should call this method when it's unable to parse a message and we can't reply to the client.

  • id - message id

AUTHOR

Deriv Group Services Ltd. DERIV@cpan.org.

See "CONTRIBUTORS" in Myriad for full details.

LICENSE

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