| 1 | package WWW::MailboxOrg::Role::IO; | ||
| 2 | |||
| 3 | # ABSTRACT: Interface role for pluggable JSON-RPC backends | ||
| 4 | |||
| 5 | 1 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | our $VERSION = '0.001'; | |
| 8 | |||
| 9 | 1 | requires 'call'; | |
| 10 | |||
| 11 | 1 | 1; | |
| 12 | |||
| 13 | __END__ | ||
| 14 | |||
| 15 | =pod | ||
| 16 | |||
| 17 | =encoding UTF-8 | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | WWW::MailboxOrg::Role::IO - Interface role for pluggable JSON-RPC backends | ||
| 22 | |||
| 23 | =head1 VERSION | ||
| 24 | |||
| 25 | version 0.001 | ||
| 26 | |||
| 27 | =head1 SYNOPSIS | ||
| 28 | |||
| 29 | package My::AsyncIO; | ||
| 30 | use Moo; | ||
| 31 | with 'WWW::MailboxOrg::Role::IO'; | ||
| 32 | |||
| 33 | sub call { | ||
| 34 | my ($self, $req) = @_; | ||
| 35 | my $result = $self->_do_rpc($req); | ||
| 36 | return WWW::MailboxOrg::JSONRPCResponse->new(%$result); | ||
| 37 | } | ||
| 38 | |||
| 39 | =head1 DESCRIPTION | ||
| 40 | |||
| 41 | This role defines the interface that JSON-RPC backends must implement. | ||
| 42 | L<WWW::MailboxOrg::Role::HTTP> delegates all RPC communication through this | ||
| 43 | interface, making it possible to swap out the transport layer. | ||
| 44 | |||
| 45 | The default backend is L<WWW::MailboxOrg::LWPIO> (synchronous, using | ||
| 46 | L<Mojo::UserAgent>). To use an async event loop, implement this role. | ||
| 47 | |||
| 48 | =head1 REQUIRED METHODS | ||
| 49 | |||
| 50 | =head2 call($req) | ||
| 51 | |||
| 52 | Execute a L<WWW::MailboxOrg::JSONRPCRequest>. Receives the request object | ||
| 53 | with C<method>, C<params>, and C<id> already set. | ||
| 54 | |||
| 55 | Must return a L<WWW::MailboxOrg::JSONRPCResponse>. | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | =head1 SUPPORT | ||
| 60 | |||
| 61 | =head2 Issues | ||
| 62 | |||
| 63 | Please report bugs and feature requests on GitHub at | ||
| 64 | L<https://github.com/getty/p5-www-mailboxorg/issues>. | ||
| 65 | |||
| 66 | =head2 IRC | ||
| 67 | |||
| 68 | Join C<#perl-help> on C<irc.perl.org> or message Getty directly. | ||
| 69 | |||
| 70 | =head1 CONTRIBUTING | ||
| 71 | |||
| 72 | Contributions are welcome! Please fork the repository and submit a pull request. | ||
| 73 | |||
| 74 | =head1 AUTHOR | ||
| 75 | |||
| 76 | Torsten Raudssus <getty@cpan.org> | ||
| 77 | |||
| 78 | =head1 COPYRIGHT AND LICENSE | ||
| 79 | |||
| 80 | This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>. | ||
| 81 | |||
| 82 | This is free software; you can redistribute it and/or modify it under | ||
| 83 | the same terms as the Perl 5 programming language system itself. | ||
| 84 | |||
| 85 | =cut | ||