Myriad::Service - starting point for building microservices
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;
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.
async method
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.
$log
$tracer
You can disable the language behaviour defaults by specifying :custom as an "import" parameter:
:custom
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.
Deriv Group Services Ltd. DERIV@cpan.org.
DERIV@cpan.org
See "CONTRIBUTORS" in Myriad for full details.
Copyright Deriv Group Services Ltd 2020-2021. Licensed under the same terms as Perl itself.
To install Myriad, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Myriad
CPAN shell
perl -MCPAN -e shell install Myriad
For more information on module installation, please visit the detailed CPAN module installation guide.