DJabberd/Queue/ServerOut.pm

filter: Statementstmt 46.9% 23 / 49 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 7 / 14 Podpod 0.0% 0 / 6 totaltotal 40.0% 30 / 75 CC 4 SCAR 13.4
CC
4
Cov
42%
new
12.0
start_connecting
6.0
give_up_connecting
2.0
CRAP 3.8
« DJabberd/StreamVersion.pm ↑ Summary DJabberd/PresenceChecker/Dummy.pm »
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
BranchTrueFalseTotal
my $domain = delete $opts{"domain"} or Carp::confess("domain required") 0 0 0
26 my $del_source = delete $opts{source}
27 0 ▶ or die "delivery 'source' required";
Branch: 1 branch
BranchTrueFalseTotal
my $del_source = delete $opts{"source"} or die "delivery 'source' required" 0 0 0
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
BranchTrueFalseTotal
unless $self->{"state"} == \"no connection" 0 0 0
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;
« DJabberd/StreamVersion.pm ↑ Summary DJabberd/PresenceChecker/Dummy.pm »