| 1 | package DJabberd::Queue::ServerOut; | ||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 20 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 20 | ▶ | use base 'DJabberd::Queue'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 20 | ▶ | use DJabberd::Queue qw(NO_CONN RESOLVING); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 20 | ▶ | use fields ( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 20 | 'domain', | |||||||||
| 9 | 'del_source', | ||||||||||
| 10 | 20 | ); | |||||||||
| 11 | |||||||||||
| 12 | 20 | ▶ | use DJabberd::Connection::ServerOut; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 20 | ▶ | use DJabberd::Log; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 20 | our $logger = DJabberd::Log->get_logger; | |||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 19 | 0 | my ($class, %opts) = @_; | |||||||||
| 20 | |||||||||||
| 21 | # warn( join ",", keys %opts ); | ||||||||||
| 22 | # warn( $opts{domain}); | ||||||||||
| 23 | |||||||||||
| 24 | my $domain = delete $opts{domain} | ||||||||||
| 25 | 0 | ▶ | or Carp::confess "domain required"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | my $del_source = delete $opts{source} | ||||||||||
| 27 | 0 | ▶ | or die "delivery 'source' required"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | my $self = fields::new($class); | |||||||||
| 29 | 0 | $self->SUPER::new( %opts ); | |||||||||
| 30 | |||||||||||
| 31 | 0 | $self->{domain} = $domain; | |||||||||
| 32 | 0 | $self->{del_source} = $del_source; | |||||||||
| 33 | |||||||||||
| 34 | 0 | return $self; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub give_up_connecting { | ||||||||
|
Subroutine
give_up_connecting: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 38 | 0 | my $self = shift; | |||||||||
| 39 | 0 | $logger->error("Connection error while connecting to $self->{domain}, giving up"); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub domain { | ||||||||
|
Subroutine
domain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 43 | 0 | my $self = shift; | |||||||||
| 44 | 0 | return $self->{domain}; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub queue_stanza { | ||||||||
|
Subroutine
queue_stanza: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 48 | 0 | my $self = shift; | |||||||||
| 49 | # Passthrough, maybe we should warn and depricate? | ||||||||||
| 50 | 0 | return $self->SUPER::enqueue( @_ ); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub start_connecting { | ||||||||
|
Subroutine
start_connecting: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 54 | 0 | my $self = shift; | |||||||||
| 55 | 0 | $logger->debug("Starting connection to domain '$self->{domain}'"); | |||||||||
| 56 | 0 | ▶ | die unless $self->{state} == NO_CONN; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | |||||||||||
| 58 | # TODO: moratorium/exponential backoff on attempting to deliver to | ||||||||||
| 59 | # something that's recently failed to connect. instead, immediately | ||||||||||
| 60 | # call ->failed_to_connect without even trying. | ||||||||||
| 61 | |||||||||||
| 62 | 0 | $self->{state} = RESOLVING; | |||||||||
| 63 | |||||||||||
| 64 | # async DNS lookup | ||||||||||
| 65 | DJabberd::DNS->srv(service => "_xmpp-server._tcp", | ||||||||||
| 66 | domain => $self->{domain}, | ||||||||||
| 67 | 0 | ▶ | callback => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 68 | 0 | $self->endpoints(@_); | |||||||||
| 69 | 0 | $logger->debug("Resolver callback for '$self->{domain}': [@_]"); | |||||||||
| 70 | 0 | $self->{state} = NO_CONN; | |||||||||
| 71 | 0 | $self->SUPER::start_connecting; | |||||||||
| 72 | 0 | }); | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 0 | ▶ | sub new_connection { | ||||||||
|
Subroutine
new_connection: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 76 | 0 | my $self = shift; | |||||||||
| 77 | 0 | my %opts = @_; | |||||||||
| 78 | |||||||||||
| 79 | 0 | return DJabberd::Connection::ServerOut->new(%opts); | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 20 | 1; | |||||||||