NAME
Myriad::Service - starting point for building microservices
SYNOPSIS
package Example::Service;
use Myriad::Service;
async method startup {
$log->infof('Starting %s', __PACKAGE__);
}
# Trivial RPC call, provides the `example` method
async method example : RPC {
return { ok => 1 };
}
# Slightly more useful - return all the original parameters.
# Due to an unfortunate syntactical choice in core Perl, the
# whitespace before the (%args) is *mandatory*, without that
# you're actually passing (%args) to the RPC attribute...
async method echo : RPC (%args) {
return \%args;
}
# Default internal diagnostics checks are performed automatically,
# this method is called after the microservice status such as Redis
# connections, exception status etc. are verified
async method diagnostics ($level) {
my ($self, $level) = @_;
return 'ok';
}
1;
DESCRIPTION
Since this is a framework, by default it attempts to enforce a common standard on all microservice modules. See Myriad::Class for the details.
The calling package will be marked as an Object::Pad class, providing the "method" in Object::Pad, "has" in Object::Pad and async method
keywords.
This also makes available a Log::Any instance in the $log
package variable, and for OpenTracing::Any support you get $tracer
as an OpenTracing::Tracer instance.
Custom language features
You can disable the language behaviour defaults by specifying :custom
as an "import" parameter:
package Example::Service;
use strict;
use warnings;
use Myriad::Service qw(:custom);
use Log::Any qw($log);
This will only apply the Myriad::Service::Implementation parent class, and avoid any changes to syntax or other features.
INHERITED METHODS
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.