| 1 | package Myriad::Role::Subscription; | ||
| 2 | |||
| 3 | 3 | ▶ | use Myriad::Class type => 'role'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 3 | our $VERSION = '1.001'; # VERSION | |
| 6 | 3 | our $AUTHORITY = 'cpan:DERIV'; # AUTHORITY | |
| 7 | |||
| 8 | =encoding utf8 | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Myriad::Subscription - microservice subscription abstraction | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | my $storage = $myriad->subscription; | ||
| 17 | |||
| 18 | =head1 DESCRIPTION | ||
| 19 | |||
| 20 | =head1 Implementation | ||
| 21 | |||
| 22 | Note that this is defined as a rĂ´le, so it does not provide | ||
| 23 | a concrete implementation - instead, see classes such as: | ||
| 24 | |||
| 25 | =over 4 | ||
| 26 | |||
| 27 | =item * L<Myriad::Subscription::Implementation::Redis> | ||
| 28 | |||
| 29 | =item * L<Myriad::Subscription::Implementation::Memory> | ||
| 30 | |||
| 31 | =back | ||
| 32 | |||
| 33 | =cut | ||
| 34 | |||
| 35 | =head1 METHODS | ||
| 36 | |||
| 37 | =head2 create_from_sink | ||
| 38 | |||
| 39 | Register a new C<Receiver> to notify it when there is new data. | ||
| 40 | |||
| 41 | it takes a hash as an argument that should have the following | ||
| 42 | |||
| 43 | =over 4 | ||
| 44 | |||
| 45 | =item * C<sink> - a L<Ryu::Sink> that the subscription will emit new messages to. | ||
| 46 | |||
| 47 | =item * C<channel> - The events channel name where the C<Emitter> will emit the new events. | ||
| 48 | |||
| 49 | =item * C<client> - The name that this C<Receiver> should use while fetching new events. | ||
| 50 | |||
| 51 | =back | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | 3 | method create_from_sink; | |
| 56 | |||
| 57 | =head2 create_from_source | ||
| 58 | |||
| 59 | Register a new C<Emitter> to receive events from. | ||
| 60 | |||
| 61 | it takes a hash as an argument that should have the following | ||
| 62 | |||
| 63 | =over 4 | ||
| 64 | |||
| 65 | =item * C<source> - a L<Ryu::Source> where the messages will be emitted to. | ||
| 66 | |||
| 67 | =item * C<channel> - The name of the events channel that should be used to send the messages to. | ||
| 68 | |||
| 69 | =back | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | 3 | method create_from_source; | |
| 74 | |||
| 75 | =head2 start | ||
| 76 | |||
| 77 | Start processing the subscriptions. | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | 3 | method start; | |
| 82 | |||
| 83 | =head2 stop | ||
| 84 | |||
| 85 | Stop processing the subscriptions. | ||
| 86 | |||
| 87 | =cut | ||
| 88 | |||
| 89 | 3 | method stop; | |
| 90 | |||
| 91 | 3 | 1; | |
| 92 | |||
| 93 | __END__ | ||