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

Test::Myriad::Service - an abstraction to mock microservices.

SYNOPSIS

 my $service = Myriad::Test::Service->new(..);
 $service->add_rpc('rpc_name', %default_response);

DESCRIPTION

Methods

add_rpc

Attaches a new RPC to the service with a defaultt response.

  • name - The name of the RPC.

  • response - A hash that will be sent as the response.

mock_rpc

Override the original RPC response for a single call.

  • name - The name of the RPC to be mocked.

  • response - A hash that will be sent as the response.

call_rpc

A shortcut to call an RPC in the current service.

The call will be conducted over Myriad Transport and not as a method invocation.

  • method - The RPC method name.

  • args - A hash of the method arguments.

add_subscription

Creats a new subscription in the service.

This sub takes the source of the data in multiple ways described in the parameters section, only one of them required.

  • channel - The channel name that the events will be emitted to.

  • array - A perl arrayref that its content is going to be emitted as events.

add_receiver

Adds a new receiver in the given service.

  • from - The source service name.

  • channel - The source of the events channel name.

  • handler - A coderef that will handle the events.

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. Licensed under the same terms as Perl itself.