« blib/lib/auto/share/dist/Beekeeper/scraper/lib/MyApp/Service/Scraper/Worker.pm
↑ Summary
blib/lib/auto/share/dist/Beekeeper/chat/lib/MyApp/Service/Auth/Worker.pm »
| 1 | package Beekeeper::Service::LogTail; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | our $VERSION = '0.09'; | ||
| 7 | |||
| 8 | use Beekeeper::Client; | ||
| 9 | |||
| 10 | # Show errors from perspective of caller | ||
| 11 | $Carp::Internal{(__PACKAGE__)}++; | ||
| 12 | |||
| 13 | |||
| 14 | sub tail { | ||
| 15 | my ($class, %args) = @_; | ||
| 16 | |||
| 17 | my $client = Beekeeper::Client->instance; | ||
| 18 | my $guard = $client->__use_authorization_token('BKPR_ADMIN'); | ||
| 19 | my $timeout = delete $args{'timeout'}; | ||
| 20 | |||
| 21 | my $resp = $client->call_remote( | ||
| 22 | method => '_bkpr.logtail.tail', | ||
| 23 | params => \%args, | ||
| 24 | timeout => $timeout, | ||
| 25 | ); | ||
| 26 | |||
| 27 | return $resp->result; | ||
| 28 | } | ||
| 29 | |||
| 30 | sub tail_async { | ||
| 31 | my ($class, %args) = @_; | ||
| 32 | |||
| 33 | my $on_success = delete $args{'on_success'}; | ||
| 34 | my $on_error = delete $args{'on_error'}; | ||
| 35 | |||
| 36 | unless ($on_error) { | ||
| 37 | my ($file, $line) = (caller)[1,2]; | ||
| 38 | $on_error = sub { die $_[0]->message . " at $file line $line\n"; }; | ||
| 39 | } | ||
| 40 | |||
| 41 | my $client = Beekeeper::Client->instance; | ||
| 42 | my $guard = $client->__use_authorization_token('BKPR_ADMIN'); | ||
| 43 | my $timeout = delete $args{'timeout'}; | ||
| 44 | |||
| 45 | $client->call_remote_async( | ||
| 46 | method => '_bkpr.logtail.tail', | ||
| 47 | params => \%args, | ||
| 48 | timeout => $timeout, | ||
| 49 | on_success => $on_success, | ||
| 50 | on_error => $on_error, | ||
| 51 | ); | ||
| 52 | } | ||
| 53 | |||
| 54 | 1; | ||
| 55 | |||
| 56 | __END__ |