Lambda/Context.pm

filter: Statementstmt 73.1% 30 / 41 Branchbran 50.0% 1 / 2 Conditioncond 22.7% 5 / 22 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 50.0% 8 / 16 Podpod 0.0% 0 / 12 totaltotal 41.9% 44 / 105 CC 12 SCAR 16.3
CC
12
Cov
55%
new
9.2
function_name
6.0
function_version
6.0
CRAP 5.1
« Lambda/ResponseWriter.pm ↑ Summary Lambda/AL2.pm »
1 package AWS::Lambda::Context;
2 20 ▶use 5.026000;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 20 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶sub new {
Subroutine new: called CC=7 SCAR=22.2
Pod undocumented
9 7 my $proto = shift;
10 7 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
070
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
11 7 my %args;
12 7 ▶ if (@_ == 1 && ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 0 7 7
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
700
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
13 0 %args = %{$_[0]};
14 } else {
15 7 %args = @_;
16 }
17 7 ▶ my $deadline_ms = $args{deadline_ms} // die 'deadline_ms is required';
Condition50%1/2
$args{"deadline_ms"} // die("deadline_ms is required")
l!l
70
MC/DC0%0/1
$args{"deadline_ms"} // die("deadline_ms is required")
$args{"deadline_ms"}
Truth table50%1/2
A
A= $args{"deadline_ms"}
Aresult
11
00
18 7 ▶ my $invoked_function_arn = $args{invoked_function_arn} // '';
Condition50%1/2
$args{"invoked_function_arn"} // ""
l!l
70
MC/DC0%0/1
$args{"invoked_function_arn"} // ""
$args{"invoked_function_arn"}
Truth table50%1/2
A
A= $args{"invoked_function_arn"}
Aresult
11
00
19 7 ▶ my $aws_request_id = $args{aws_request_id} // '';
Condition50%1/2
$args{"aws_request_id"} // ""
l!l
70
MC/DC0%0/1
$args{"aws_request_id"} // ""
$args{"aws_request_id"}
Truth table50%1/2
A
A= $args{"aws_request_id"}
Aresult
11
00
20 7 my $trace_id = $args{trace_id};
21 7 my $tenant_id = $args{tenant_id};
22 7 my $self = bless +{
23 deadline_ms => +$deadline_ms,
24 invoked_function_arn => $invoked_function_arn,
25 aws_request_id => $aws_request_id,
26 trace_id => $trace_id,
27 tenant_id => $tenant_id,
28 }, $class;
29  
30 7 return $self;
31 }
32  
33 0 ▶sub get_remaining_time_in_millis {
Subroutine get_remaining_time_in_millis: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my $self = shift;
35 0 return $self->{deadline_ms} - time() * 1000;
36 }
37  
38 0 ▶sub function_name {
Subroutine function_name: not called CC=2 SCAR=17.9
Pod undocumented
39 0 ▶ return $ENV{AWS_LAMBDA_FUNCTION_NAME} // die 'function_name is not found';
Condition0%0/2
$ENV{"AWS_LAMBDA_FUNCTION_NAME"} // die("function_name is not found")
l!l
00
MC/DC0%0/1
$ENV{"AWS_LAMBDA_FUNCTION_NAME"} // die("function_name is not found")
$ENV{"AWS_LAMBDA_FUNCTION_NAME"}
Truth table0%0/2
A
A= $ENV{"AWS_LAMBDA_FUNCTION_NAME"}
Aresult
11
00
40 }
41  
42 0 ▶sub function_version {
Subroutine function_version: not called CC=2 SCAR=17.9
Pod undocumented
43 0 ▶ return $ENV{AWS_LAMBDA_FUNCTION_VERSION} // die 'function_version is not found';
Condition0%0/2
$ENV{"AWS_LAMBDA_FUNCTION_VERSION"} // die("function_version is not found")
l!l
00
MC/DC0%0/1
$ENV{"AWS_LAMBDA_FUNCTION_VERSION"} // die("function_version is not found")
$ENV{"AWS_LAMBDA_FUNCTION_VERSION"}
Truth table0%0/2
A
A= $ENV{"AWS_LAMBDA_FUNCTION_VERSION"}
Aresult
11
00
44 }
45  
46 1 ▶sub invoked_function_arn {
Subroutine invoked_function_arn: called CC=1 SCAR=0.0
Pod undocumented
47 1 my $self = shift;
48 1 return $self->{invoked_function_arn};
49 }
50  
51 0 ▶sub memory_limit_in_mb {
Subroutine memory_limit_in_mb: not called CC=2 SCAR=17.9
Pod undocumented
52 0 ▶ return +$ENV{AWS_LAMBDA_FUNCTION_MEMORY_SIZE} // die 'memory_limit_in_mb is not found';
Condition0%0/2
$ENV{"AWS_LAMBDA_FUNCTION_MEMORY_SIZE"} // die("memory_limit_in_mb is not found")
l!l
00
MC/DC0%0/1
$ENV{"AWS_LAMBDA_FUNCTION_MEMORY_SIZE"} // die("memory_limit_in_mb is not found")
$ENV{"AWS_LAMBDA_FUNCTION_MEMORY_SIZE"}
Truth table0%0/2
A
A= $ENV{"AWS_LAMBDA_FUNCTION_MEMORY_SIZE"}
Aresult
11
00
53 }
54  
55 6 ▶sub aws_request_id {
Subroutine aws_request_id: called CC=1 SCAR=0.0
Pod undocumented
56 6 my $self = shift;
57 6 return $self->{aws_request_id};
58 }
59  
60 0 ▶sub log_group_name {
Subroutine log_group_name: not called CC=2 SCAR=17.9
Pod undocumented
61 0 ▶ return $ENV{AWS_LAMBDA_LOG_GROUP_NAME} // die 'log_group_name is not found';
Condition0%0/2
$ENV{"AWS_LAMBDA_LOG_GROUP_NAME"} // die("log_group_name is not found")
l!l
00
MC/DC0%0/1
$ENV{"AWS_LAMBDA_LOG_GROUP_NAME"} // die("log_group_name is not found")
$ENV{"AWS_LAMBDA_LOG_GROUP_NAME"}
Truth table0%0/2
A
A= $ENV{"AWS_LAMBDA_LOG_GROUP_NAME"}
Aresult
11
00
62 }
63  
64 0 ▶sub log_stream_name {
Subroutine log_stream_name: not called CC=2 SCAR=17.9
Pod undocumented
65 0 ▶ return $ENV{AWS_LAMBDA_LOG_STREAM_NAME} // die 'log_stream_name is not found';
Condition0%0/2
$ENV{"AWS_LAMBDA_LOG_STREAM_NAME"} // die("log_stream_name is not found")
l!l
00
MC/DC0%0/1
$ENV{"AWS_LAMBDA_LOG_STREAM_NAME"} // die("log_stream_name is not found")
$ENV{"AWS_LAMBDA_LOG_STREAM_NAME"}
Truth table0%0/2
A
A= $ENV{"AWS_LAMBDA_LOG_STREAM_NAME"}
Aresult
11
00
66 }
67  
68 0 ▶sub identity {
Subroutine identity: not called CC=1 SCAR=6.9
Pod undocumented
69 0 return undef; # TODO
70 }
71  
72 0 ▶sub client_context {
Subroutine client_context: not called CC=1 SCAR=6.9
Pod undocumented
73 0 return undef; # TODO
74 }
75  
76 1 ▶sub tenant_id {
Subroutine tenant_id: called CC=1 SCAR=0.0
Pod undocumented
77 1 my $self = shift;
78 1 return $self->{tenant_id};
79 }
80  
81 20 1;
82 =encoding utf-8
83  
84 =head1 NAME
85  
86 AWS::Lambda::Context - It's Perl port of the AWS Lambda Context.
87  
88 =head1 SYNOPSIS
89  
90 sub handle {
91 my ($payload, $context) = @_;
92 # $context is an instance of AWS::Lambda::Context
93 my $result = {
94 # The name of the Lambda function.
95 function_name => $context->function_name,
96  
97 # The version of the function.
98 function_version => $context->function_version,
99
100 # The Amazon Resource Name (ARN) used to invoke the function.
101 # Indicates if the invoker specified a version number or alias.
102 invoked_function_arn => $context->invoked_function_arn,
103  
104 # The amount of memory configured on the function.
105 memory_limit_in_mb => $context->memory_limit_in_mb,
106  
107 # The identifier of the invocation request.
108 aws_request_id => $context->aws_request_id,
109  
110 # The log group for the function.
111 log_group_name => $context->log_group_name,
112  
113 # The log stream for the function instance.
114 log_stream_name => $context->log_stream_name,
115  
116 # The tenant id for the function.
117 tenant_id => $context->tenant_id,
118 };
119 return $result;
120 }
121  
122 =head1 LICENSE
123  
124 The MIT License (MIT)
125  
126 Copyright (C) ICHINOSE Shogo.
127  
128 =head1 AUTHOR
129  
130 ICHINOSE Shogo E<lt>shogo82148@gmail.comE<gt>
131  
132 =cut
« Lambda/ResponseWriter.pm ↑ Summary Lambda/AL2.pm »