aws_lambda_ric 1.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +159 -213
- data/README.md +2 -4
- data/aws_lambda_ric.gemspec +4 -6
- data/bin/aws_lambda_ric +4 -5
- data/lib/aws_lambda_ric/aws_lambda_marshaller.rb +2 -2
- data/lib/aws_lambda_ric/lambda_context.rb +2 -4
- data/lib/aws_lambda_ric/lambda_errors.rb +5 -6
- data/lib/aws_lambda_ric/lambda_handler.rb +3 -3
- data/lib/aws_lambda_ric/lambda_log_formatter.rb +2 -4
- data/lib/aws_lambda_ric/lambda_logger.rb +1 -1
- data/lib/aws_lambda_ric/lambda_server.rb +11 -13
- data/lib/aws_lambda_ric/logger_patch.rb +5 -4
- data/lib/aws_lambda_ric/telemetry_log_sink.rb +15 -12
- data/lib/aws_lambda_ric/version.rb +2 -4
- data/lib/aws_lambda_ric/xray_cause.rb +4 -4
- data/lib/aws_lambda_ric.rb +57 -14
- metadata +19 -7
- data/Gemfile.lock +0 -37
- data/lib/aws_lambda_ric/bootstrap.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7531514e0f2ab9ba840cdcd973a36cadb45e9887db24a7fa0337e6eaca16e8a
|
4
|
+
data.tar.gz: b1be16c96fdc08b4651e99a4eb20f17ca3af69dee48476e58b075b910863a72d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9d932188a665f2865a71c9e7d06a6864fd7728925589e587c3ef71926c20ae0345cb9b7879c7457f586f7956df3ec41260038464ef34d50af6a785c81cfd71
|
7
|
+
data.tar.gz: 2b00da39020716fda73d50954e74ec76013a2aa0548c363411d743c03e01b888ff59a123921cf8915bef617cae0ebde7a35743588a589ca56edb5649fb88a956
|
data/LICENSE
CHANGED
@@ -1,229 +1,175 @@
|
|
1
|
-
Apache License
|
2
1
|
|
3
|
-
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
4
5
|
|
5
|
-
|
6
|
-
AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
7
|
|
8
8
|
1. Definitions.
|
9
9
|
|
10
|
-
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
12
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
12
15
|
|
13
|
-
"
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
owner that is granting the License.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
"Legal Entity" shall mean the
|
25
|
-
union of the acting entity and all other entities that control, are controlled
|
26
|
-
by, or are under common control with that entity. For the purposes of this
|
27
|
-
definition, "control" means (i) the power, direct or indirect, to cause the
|
28
|
-
direction or management of such entity, whether by contract or otherwise, or (ii)
|
29
|
-
ownership of fifty percent (50%) or more of the outstanding shares, or (iii)
|
30
|
-
beneficial ownership of such entity.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
"You" (or "Your") shall mean
|
35
|
-
an individual or Legal Entity exercising permissions granted by this License.
|
36
|
-
|
37
|
-
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
38
23
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
39
26
|
|
40
27
|
"Source" form shall mean the preferred form for making modifications,
|
41
|
-
including but not limited to software source code, documentation
|
42
|
-
configuration files.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
direct or contributory patent infringement, then any patent licenses granted to
|
108
|
-
You under this License for that Work shall terminate as of the date such
|
109
|
-
litigation is filed.
|
110
|
-
|
111
|
-
4. Redistribution. You may reproduce and distribute
|
112
|
-
copies of the Work or Derivative Works thereof in any medium, with or without
|
113
|
-
modifications, and in Source or Object form, provided that You meet the following
|
114
|
-
conditions:
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
115
94
|
|
116
95
|
(a) You must give any other recipients of the Work or
|
117
|
-
Derivative Works a copy of this License; and
|
118
|
-
|
119
|
-
(b) You must cause any
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
(d) If the Work includes a "NOTICE" text
|
129
|
-
|
130
|
-
|
131
|
-
NOTICE file, excluding those notices that do not
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
171
153
|
|
172
154
|
8. Limitation of Liability. In no event and under no legal theory,
|
173
|
-
whether in tort (including negligence), contract, or otherwise,
|
174
|
-
by applicable law (such as deliberate and grossly
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
damages
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
182
165
|
|
183
166
|
9. Accepting Warranty or Additional Liability. While redistributing
|
184
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
185
|
-
for, acceptance of support, warranty, indemnity,
|
186
|
-
and/or rights consistent with this
|
187
|
-
obligations, You may act only
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
APPENDIX: How to
|
194
|
-
apply the Apache License to your work.
|
195
|
-
|
196
|
-
To apply the Apache License to your work,
|
197
|
-
attach the following boilerplate notice, with the fields enclosed by brackets
|
198
|
-
"[]" replaced with your own identifying information. (Don't include the
|
199
|
-
brackets!) The text should be enclosed in the appropriate comment syntax for the
|
200
|
-
file format. We also recommend that a file or class name and description of
|
201
|
-
purpose be included on the same "printed page" as the copyright notice for easier
|
202
|
-
identification within third-party archives.
|
203
|
-
|
204
|
-
Copyright [yyyy] Edgar
|
205
|
-
Hernandez
|
206
|
-
|
207
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
208
|
-
|
209
|
-
you
|
210
|
-
may not use this file except in compliance with the License.
|
211
|
-
|
212
|
-
You may obtain a
|
213
|
-
copy of the License at
|
214
|
-
|
215
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
216
|
-
|
217
|
-
Unless
|
218
|
-
required by applicable law or agreed to in writing, software
|
219
|
-
|
220
|
-
distributed under
|
221
|
-
the License is distributed on an "AS IS" BASIS,
|
222
|
-
|
223
|
-
WITHOUT WARRANTIES OR CONDITIONS
|
224
|
-
OF ANY KIND, either express or implied.
|
225
|
-
|
226
|
-
See the License for the specific
|
227
|
-
language governing permissions and
|
228
|
-
|
229
|
-
limitations under the License.
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
data/README.md
CHANGED
@@ -19,7 +19,6 @@ First step is to choose the base image to be used. The supported Linux OS distri
|
|
19
19
|
|
20
20
|
- Amazon Linux 2
|
21
21
|
- Alpine
|
22
|
-
- CentOS
|
23
22
|
- Debian
|
24
23
|
- Ubuntu
|
25
24
|
|
@@ -137,7 +136,7 @@ Make sure the project is built:
|
|
137
136
|
make init build
|
138
137
|
```
|
139
138
|
Then,
|
140
|
-
* to run unit tests: `make test`
|
139
|
+
* to run unit tests: `make test-unit`
|
141
140
|
* to run integration tests: `make test-integ`
|
142
141
|
* to run smoke tests: `make test-smoke`
|
143
142
|
|
@@ -159,5 +158,4 @@ If you discover a potential security issue in this project we ask that you notif
|
|
159
158
|
|
160
159
|
## License
|
161
160
|
|
162
|
-
This project is licensed under the Apache-2.0 License.
|
163
|
-
|
161
|
+
This project is licensed under the Apache-2.0 License.
|
data/aws_lambda_ric.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
1
|
# frozen_string_literal: true
|
4
2
|
|
5
3
|
lib = File.expand_path('lib', __dir__)
|
@@ -8,7 +6,7 @@ require './lib/aws_lambda_ric/version'
|
|
8
6
|
|
9
7
|
Gem::Specification.new do |spec|
|
10
8
|
spec.name = 'aws_lambda_ric'
|
11
|
-
spec.version =
|
9
|
+
spec.version = AwsLambdaRIC::VERSION
|
12
10
|
spec.authors = ['AWS Lambda']
|
13
11
|
|
14
12
|
spec.summary = 'AWS Lambda Runtime Interface Client for Ruby'
|
@@ -16,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
16
14
|
spec.homepage = 'https://github.com/aws/aws-lambda-ruby-runtime-interface-client'
|
17
15
|
|
18
16
|
spec.license = 'Apache-2.0'
|
19
|
-
spec.required_ruby_version = '>=
|
17
|
+
spec.required_ruby_version = '>= 3.0'
|
20
18
|
|
21
19
|
# Specify which files should be added to the gem when it is released.
|
22
20
|
spec.files = %w[
|
@@ -24,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
24
22
|
README.md
|
25
23
|
Gemfile
|
26
24
|
NOTICE
|
27
|
-
Gemfile.lock
|
28
25
|
aws_lambda_ric.gemspec
|
29
26
|
bin/aws_lambda_ric
|
30
27
|
] + Dir['lib/**/*']
|
@@ -34,8 +31,9 @@ Gem::Specification.new do |spec|
|
|
34
31
|
spec.executables = 'aws_lambda_ric'
|
35
32
|
spec.require_paths = ['lib']
|
36
33
|
|
37
|
-
spec.add_development_dependency 'bundler', '
|
34
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
38
35
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
39
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
40
37
|
spec.add_development_dependency 'activesupport', '~> 6.0.1'
|
38
|
+
spec.add_development_dependency 'test-unit', '~> 3.5.5'
|
41
39
|
end
|
data/bin/aws_lambda_ric
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
-
|
5
2
|
# frozen_string_literal: true
|
6
3
|
|
7
4
|
require 'bundler/setup'
|
8
|
-
require_relative '../lib/aws_lambda_ric
|
5
|
+
require_relative '../lib/aws_lambda_ric'
|
6
|
+
|
7
|
+
lambda_ric = AwsLambdaRIC::Bootstrap.new
|
9
8
|
|
10
|
-
|
9
|
+
lambda_ric.start
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
1
|
# frozen_string_literal: true
|
4
2
|
|
5
3
|
class LambdaContext
|
@@ -17,8 +15,8 @@ class LambdaContext
|
|
17
15
|
@function_name = ENV['AWS_LAMBDA_FUNCTION_NAME']
|
18
16
|
@memory_limit_in_mb = ENV['AWS_LAMBDA_FUNCTION_MEMORY_SIZE']
|
19
17
|
@function_version = ENV['AWS_LAMBDA_FUNCTION_VERSION']
|
20
|
-
@identity = JSON.parse(request['Lambda-Runtime-Cognito-Identity'])
|
21
|
-
@client_context = JSON.parse(request['Lambda-Runtime-Client-Context'])
|
18
|
+
@identity = JSON.parse(request['Lambda-Runtime-Cognito-Identity']) unless request['Lambda-Runtime-Cognito-Identity'].to_s.empty?
|
19
|
+
@client_context = JSON.parse(request['Lambda-Runtime-Client-Context']) unless request['Lambda-Runtime-Client-Context'].to_s.empty?
|
22
20
|
end
|
23
21
|
|
24
22
|
def get_remaining_time_in_millis
|
@@ -1,6 +1,5 @@
|
|
1
|
-
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
1
|
# frozen_string_literal: true
|
2
|
+
|
4
3
|
module LambdaErrors
|
5
4
|
|
6
5
|
class LambdaErrors::InvocationError < StandardError;
|
@@ -25,9 +24,9 @@ module LambdaErrors
|
|
25
24
|
|
26
25
|
def to_lambda_response
|
27
26
|
{
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
:errorMessage => @error_message,
|
28
|
+
:errorType => @error_type,
|
29
|
+
:stackTrace => @stack_trace
|
31
30
|
}
|
32
31
|
end
|
33
32
|
|
@@ -39,7 +38,7 @@ module LambdaErrors
|
|
39
38
|
if stacktrace
|
40
39
|
stacktrace.first(100).each do |line|
|
41
40
|
if safe_trace
|
42
|
-
if line.to_s.match(%r{
|
41
|
+
if line.to_s.match(%r{^/var/runtime/lib})
|
43
42
|
safe_trace = false
|
44
43
|
else
|
45
44
|
ret << line
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'aws_lambda_marshaller'
|
4
4
|
|
@@ -19,8 +19,8 @@ class LambdaHandler
|
|
19
19
|
|
20
20
|
def call_handler(request:, context:)
|
21
21
|
opts = {
|
22
|
-
|
23
|
-
|
22
|
+
event: request,
|
23
|
+
context: context
|
24
24
|
}
|
25
25
|
if @handler_class
|
26
26
|
response = Kernel.const_get(@handler_class).send(@handler_method_name, **opts)
|
@@ -1,11 +1,9 @@
|
|
1
|
-
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
1
|
# frozen_string_literal: true
|
4
2
|
|
5
3
|
require 'logger'
|
6
4
|
|
7
|
-
class
|
8
|
-
FORMAT = '%<sev>s, [%<datetime>s#%<process>d] %<severity>5s %<request_id>s -- %<progname>s: %<msg>s'
|
5
|
+
class LogFormatter < Logger::Formatter
|
6
|
+
FORMAT = '%<sev>s, [%<datetime>s #%<process>d] %<severity>5s %<request_id>s -- %<progname>s: %<msg>s'
|
9
7
|
|
10
8
|
def call(severity, time, progname, msg)
|
11
9
|
(FORMAT % {sev: severity[0..0], datetime: format_datetime(time), process: $$, severity: severity,
|
@@ -1,12 +1,10 @@
|
|
1
|
-
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
1
|
# frozen_string_literal: true
|
4
2
|
|
5
3
|
require 'net/http'
|
6
4
|
require 'json'
|
7
5
|
require_relative 'lambda_errors'
|
8
6
|
|
9
|
-
class
|
7
|
+
class RapidClient
|
10
8
|
LAMBDA_DEFAULT_SERVER_ADDRESS = '127.0.0.1:9001'
|
11
9
|
LAMBDA_RUNTIME_API_VERSION = '2018-06-01'
|
12
10
|
|
@@ -32,7 +30,7 @@ class LambdaServer
|
|
32
30
|
[request_id, resp]
|
33
31
|
else
|
34
32
|
raise LambdaErrors::InvocationError.new(
|
35
|
-
|
33
|
+
"Received #{resp.code} when waiting for next invocation."
|
36
34
|
)
|
37
35
|
end
|
38
36
|
rescue LambdaErrors::InvocationError => e
|
@@ -50,9 +48,9 @@ class LambdaServer
|
|
50
48
|
response_object = response_object.read
|
51
49
|
end
|
52
50
|
Net::HTTP.post(
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
response_uri,
|
52
|
+
response_object,
|
53
|
+
{ 'Content-Type' => content_type, 'User-Agent' => @user_agent }
|
56
54
|
)
|
57
55
|
rescue StandardError => e
|
58
56
|
raise LambdaErrors::LambdaRuntimeError.new(e)
|
@@ -65,9 +63,9 @@ class LambdaServer
|
|
65
63
|
headers = { 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type, 'User-Agent' => @user_agent }
|
66
64
|
headers['Lambda-Runtime-Function-XRay-Error-Cause'] = xray_cause if xray_cause.bytesize < MAX_HEADER_SIZE_BYTES
|
67
65
|
Net::HTTP.post(
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
response_uri,
|
67
|
+
error_object.to_json,
|
68
|
+
headers
|
71
69
|
)
|
72
70
|
rescue StandardError => e
|
73
71
|
raise LambdaErrors::LambdaRuntimeError.new(e)
|
@@ -78,9 +76,9 @@ class LambdaServer
|
|
78
76
|
uri = URI("#{@server_address}/runtime/init/error")
|
79
77
|
begin
|
80
78
|
Net::HTTP.post(
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
uri,
|
80
|
+
error_object.to_json,
|
81
|
+
{ 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type, 'User-Agent' => @user_agent }
|
84
82
|
)
|
85
83
|
rescue StandardError => e
|
86
84
|
raise LambdaErrors::LambdaRuntimeInitError.new(e)
|
@@ -7,15 +7,16 @@ module LoggerPatch
|
|
7
7
|
# use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
|
8
8
|
if logdev && logdev != $stdout && logdev != $stderr
|
9
9
|
super(logdev, shift_age, shift_size, level: level, progname: progname,
|
10
|
-
|
11
|
-
|
10
|
+
formatter: formatter, datetime_format: datetime_format,
|
11
|
+
binmode: binmode, shift_period_suffix: shift_period_suffix)
|
12
12
|
else
|
13
13
|
self.level = level
|
14
14
|
self.progname = progname
|
15
|
-
@default_formatter =
|
15
|
+
@default_formatter = LogFormatter.new
|
16
16
|
self.datetime_format = datetime_format
|
17
17
|
self.formatter = formatter
|
18
|
-
@logdev =
|
18
|
+
@logdev = AwsLambdaRIC::TelemetryLogger.telemetry_log_sink
|
19
|
+
@level_override = {}
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -1,35 +1,38 @@
|
|
1
|
-
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
1
|
# frozen_string_literal: true
|
4
2
|
|
5
3
|
require 'logger'
|
4
|
+
require 'time'
|
6
5
|
|
7
6
|
class TelemetryLogSink < Logger::LogDevice
|
8
7
|
|
9
8
|
# TelemetryLogSink implements the logging contract between runtimes and the platform. It implements a simple
|
10
9
|
# framing protocol so message boundaries can be determined. Each frame can be visualized as follows:
|
11
10
|
#
|
12
|
-
#
|
13
|
-
# | Frame Type - 4 bytes | Length (len) - 4 bytes | Message - \'len\' bytes |
|
14
|
-
#
|
11
|
+
# +----------------------+------------------------+---------------------+-------------------------+
|
12
|
+
# | Frame Type - 4 bytes | Length (len) - 4 bytes | Timestamp - 8 bytes | Message - \'len\' bytes |
|
13
|
+
# +----------------------+------------------------+---------------------+-------------------------+
|
15
14
|
#
|
16
|
-
# The first 4 bytes indicate the type of the frame - log frames have a type defined as the hex value
|
17
|
-
# second 4 bytes should indicate the message\'s length.
|
18
|
-
# big-endian.
|
15
|
+
# The first 4 bytes indicate the type of the frame - log frames have a type defined as the hex value 0xa55a0003. The
|
16
|
+
# second 4 bytes should indicate the message\'s length. Next, the timestamp in microsecond precision, and finally
|
17
|
+
# \'len\' bytes contain the message. The byte order is big-endian.
|
19
18
|
|
20
19
|
def initialize(file:)
|
21
20
|
@file = file
|
22
21
|
end
|
23
22
|
|
24
|
-
FRAME_BYTES = [
|
23
|
+
FRAME_BYTES = [0xa55a0003].pack('L>')
|
25
24
|
|
26
25
|
def write(msg)
|
26
|
+
@semaphore ||= Mutex.new
|
27
27
|
if @file.nil? || @file.closed?
|
28
28
|
$stdout.write(msg)
|
29
29
|
else
|
30
|
-
@
|
31
|
-
|
32
|
-
|
30
|
+
@semaphore.synchronize do
|
31
|
+
@file.write(FRAME_BYTES)
|
32
|
+
@file.write([msg.bytesize].pack('L>'))
|
33
|
+
@file.write([(Time.new.to_f*1000000).to_i].pack('Q>'))
|
34
|
+
@file.write(msg)
|
35
|
+
end
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'lambda_errors'
|
4
4
|
|
@@ -15,8 +15,8 @@ class XRayCause
|
|
15
15
|
|
16
16
|
def as_json
|
17
17
|
@as_json ||= begin
|
18
|
-
|
19
|
-
|
18
|
+
JSON.dump(@cause)
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -39,4 +39,4 @@ class XRayCause
|
|
39
39
|
end
|
40
40
|
[exception]
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
data/lib/aws_lambda_ric.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
1
|
# frozen_string_literal: true
|
4
2
|
|
5
3
|
require_relative 'aws_lambda_ric/lambda_errors'
|
@@ -17,17 +15,24 @@ require 'logger'
|
|
17
15
|
|
18
16
|
$stdout.sync = true # Ensures that logs are flushed promptly.
|
19
17
|
|
20
|
-
module
|
18
|
+
module AwsLambdaRIC
|
21
19
|
|
22
20
|
class Error < StandardError; end
|
23
21
|
|
22
|
+
def self.get_user_agent
|
23
|
+
ruby_version = RUBY_VERSION.to_s
|
24
|
+
version = AwsLambdaRIC::VERSION
|
25
|
+
|
26
|
+
"aws-lambda-ruby/#{ruby_version}-#{version}"
|
27
|
+
end
|
28
|
+
|
24
29
|
# Loads the user code and runs it upon invocation
|
25
30
|
class LambdaRunner
|
26
31
|
|
27
32
|
ENV_VAR_RUNTIME_API = 'AWS_LAMBDA_RUNTIME_API'
|
28
33
|
|
29
34
|
def initialize(runtime_server_addr, user_agent)
|
30
|
-
@lambda_server =
|
35
|
+
@lambda_server = RapidClient.new(runtime_server_addr, user_agent)
|
31
36
|
@runtime_loop_active = true # if false, we will exit the program
|
32
37
|
@exit_code = 0
|
33
38
|
end
|
@@ -45,7 +50,7 @@ module AwsLambdaRuntimeInterfaceClient
|
|
45
50
|
@exit_code = -4
|
46
51
|
send_init_error_to_server(e)
|
47
52
|
ensure
|
48
|
-
|
53
|
+
TelemetryLogger.close
|
49
54
|
end
|
50
55
|
|
51
56
|
exit(@exit_code)
|
@@ -106,7 +111,7 @@ module AwsLambdaRuntimeInterfaceClient
|
|
106
111
|
@lambda_server.send_init_error(error_object: ex.to_lambda_response, error: ex)
|
107
112
|
end
|
108
113
|
|
109
|
-
def send_error_response(lambda_invocation, err, exit_code = nil, runtime_loop_active
|
114
|
+
def send_error_response(lambda_invocation, err, exit_code = nil, runtime_loop_active = true)
|
110
115
|
error_object = err.to_lambda_response
|
111
116
|
@lambda_server.send_error_response(
|
112
117
|
request_id: lambda_invocation.request_id,
|
@@ -121,7 +126,7 @@ module AwsLambdaRuntimeInterfaceClient
|
|
121
126
|
end
|
122
127
|
|
123
128
|
# Helper class to for mutating std logger with TelemetryLog
|
124
|
-
class
|
129
|
+
class TelemetryLogger
|
125
130
|
|
126
131
|
ENV_VAR_TELEMETRY_LOG_FD = '_LAMBDA_TELEMETRY_LOG_FD'
|
127
132
|
|
@@ -133,19 +138,27 @@ module AwsLambdaRuntimeInterfaceClient
|
|
133
138
|
end
|
134
139
|
end
|
135
140
|
|
136
|
-
def initialize(telemetry_log_fd
|
137
|
-
fd =
|
138
|
-
|
139
|
-
|
141
|
+
def initialize(telemetry_log_fd)
|
142
|
+
fd = telemetry_log_fd.to_i
|
143
|
+
AwsLambdaRIC::TelemetryLogger.telemetry_log_fd_file = IO.new(fd, 'wb')
|
144
|
+
AwsLambdaRIC::TelemetryLogger.telemetry_log_fd_file.sync = true
|
140
145
|
|
141
|
-
|
146
|
+
AwsLambdaRIC::TelemetryLogger.telemetry_log_sink = TelemetryLogSink.new(file: AwsLambdaRIC::TelemetryLogger.telemetry_log_fd_file)
|
142
147
|
|
143
148
|
mutate_std_logger
|
144
149
|
mutate_kernel_puts
|
145
|
-
rescue Errno::ENOENT
|
150
|
+
rescue Errno::ENOENT, Errno::EBADF
|
146
151
|
# If File.open() fails, then the mutation won't happen and the default behaviour (print to stdout) will prevail
|
147
152
|
end
|
148
153
|
|
154
|
+
def self.from_env()
|
155
|
+
if ENV.key?(ENV_VAR_TELEMETRY_LOG_FD)
|
156
|
+
fd = ENV.fetch(AwsLambdaRIC::TelemetryLogger::ENV_VAR_TELEMETRY_LOG_FD)
|
157
|
+
ENV.delete(AwsLambdaRIC::TelemetryLogger::ENV_VAR_TELEMETRY_LOG_FD)
|
158
|
+
AwsLambdaRIC::TelemetryLogger.new(fd)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
149
162
|
private
|
150
163
|
|
151
164
|
def mutate_std_logger
|
@@ -158,7 +171,11 @@ module AwsLambdaRuntimeInterfaceClient
|
|
158
171
|
Kernel.module_eval do
|
159
172
|
def puts(*arg)
|
160
173
|
msg = arg.flatten.collect { |a| a.to_s.encode('UTF-8') }.join("\n")
|
161
|
-
|
174
|
+
if msg[-1] != "\n"
|
175
|
+
msg += "\n"
|
176
|
+
end
|
177
|
+
AwsLambdaRIC::TelemetryLogger.telemetry_log_sink.write(msg)
|
178
|
+
return nil
|
162
179
|
end
|
163
180
|
end
|
164
181
|
end
|
@@ -176,4 +193,30 @@ module AwsLambdaRuntimeInterfaceClient
|
|
176
193
|
@trace_id = trace_id
|
177
194
|
end
|
178
195
|
end
|
196
|
+
|
197
|
+
class Bootstrap
|
198
|
+
|
199
|
+
def start
|
200
|
+
AwsLambdaRIC::TelemetryLogger::from_env()
|
201
|
+
bootstrap_handler
|
202
|
+
end
|
203
|
+
|
204
|
+
def fetch_runtime_server
|
205
|
+
ENV.fetch(AwsLambdaRIC::LambdaRunner::ENV_VAR_RUNTIME_API)
|
206
|
+
rescue KeyError
|
207
|
+
puts 'Failed to get runtime server address from AWS_LAMBDA_RUNTIME_API env variable'
|
208
|
+
exit(-2)
|
209
|
+
end
|
210
|
+
|
211
|
+
def bootstrap_handler
|
212
|
+
if ENV['_HANDLER'] == nil
|
213
|
+
puts 'No handler specified, exiting Runtime Interface Client.'
|
214
|
+
exit
|
215
|
+
end
|
216
|
+
app_root = Dir.pwd
|
217
|
+
handler = ENV['_HANDLER']
|
218
|
+
lambda_runner = AwsLambdaRIC::LambdaRunner.new(fetch_runtime_server, AwsLambdaRIC::get_user_agent)
|
219
|
+
lambda_runner.run(app_root, handler)
|
220
|
+
end
|
221
|
+
end
|
179
222
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws_lambda_ric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AWS Lambda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 6.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.5.5
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.5.5
|
69
83
|
description: The AWS Lambda Ruby Runtime Interface Client implements the Lambda programming
|
70
84
|
model for Ruby.
|
71
85
|
email:
|
@@ -75,7 +89,6 @@ extensions: []
|
|
75
89
|
extra_rdoc_files: []
|
76
90
|
files:
|
77
91
|
- Gemfile
|
78
|
-
- Gemfile.lock
|
79
92
|
- LICENSE
|
80
93
|
- NOTICE
|
81
94
|
- README.md
|
@@ -83,7 +96,6 @@ files:
|
|
83
96
|
- bin/aws_lambda_ric
|
84
97
|
- lib/aws_lambda_ric.rb
|
85
98
|
- lib/aws_lambda_ric/aws_lambda_marshaller.rb
|
86
|
-
- lib/aws_lambda_ric/bootstrap.rb
|
87
99
|
- lib/aws_lambda_ric/lambda_context.rb
|
88
100
|
- lib/aws_lambda_ric/lambda_errors.rb
|
89
101
|
- lib/aws_lambda_ric/lambda_handler.rb
|
@@ -106,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
118
|
requirements:
|
107
119
|
- - ">="
|
108
120
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
121
|
+
version: '3.0'
|
110
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
123
|
requirements:
|
112
124
|
- - ">="
|
data/Gemfile.lock
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
aws_lambda_ric (1.0.2)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (6.0.3.4)
|
10
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
-
i18n (>= 0.7, < 2)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
tzinfo (~> 1.1)
|
14
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
15
|
-
concurrent-ruby (1.1.7)
|
16
|
-
i18n (1.8.5)
|
17
|
-
concurrent-ruby (~> 1.0)
|
18
|
-
minitest (5.14.2)
|
19
|
-
rake (13.0.1)
|
20
|
-
thread_safe (0.3.6)
|
21
|
-
tzinfo (1.2.8)
|
22
|
-
thread_safe (~> 0.1)
|
23
|
-
zeitwerk (2.4.2)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
x86_64-linux
|
28
|
-
|
29
|
-
DEPENDENCIES
|
30
|
-
activesupport (~> 6.0.1)
|
31
|
-
aws_lambda_ric!
|
32
|
-
bundler (>= 2.0)
|
33
|
-
minitest (~> 5.0)
|
34
|
-
rake (~> 13.0)
|
35
|
-
|
36
|
-
BUNDLED WITH
|
37
|
-
2.2.2
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require_relative '../aws_lambda_ric'
|
2
|
-
|
3
|
-
# Bootstrap runtime
|
4
|
-
module Bootstrap
|
5
|
-
|
6
|
-
def self.start
|
7
|
-
bootstrap_telemetry_log_sink
|
8
|
-
bootstrap_handler
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.fetch_runtime_server
|
12
|
-
ENV.fetch(AwsLambdaRuntimeInterfaceClient::LambdaRunner::ENV_VAR_RUNTIME_API)
|
13
|
-
rescue KeyError
|
14
|
-
puts 'Failed to get runtime server address from AWS_LAMBDA_RUNTIME_API env variable'
|
15
|
-
exit(-2)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.bootstrap_telemetry_log_sink(path_to_fd='/proc/self/fd/')
|
19
|
-
fd = ENV.fetch(AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper::ENV_VAR_TELEMETRY_LOG_FD)
|
20
|
-
ENV.delete(AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper::ENV_VAR_TELEMETRY_LOG_FD)
|
21
|
-
AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper.new(fd, path_to_fd)
|
22
|
-
rescue KeyError
|
23
|
-
puts 'Skipped bootstraping TelemetryLog'
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.bootstrap_handler
|
27
|
-
if ARGV.empty?
|
28
|
-
puts 'No handler specified, exiting Runtime Interface Client.'
|
29
|
-
exit
|
30
|
-
end
|
31
|
-
app_root = Dir.pwd
|
32
|
-
handler = ARGV[0]
|
33
|
-
lambda_runner = AwsLambdaRuntimeInterfaceClient::LambdaRunner.new(fetch_runtime_server, get_user_agent)
|
34
|
-
puts "Executing '#{handler}' in function directory '#{app_root}'"
|
35
|
-
lambda_runner.run(app_root, handler)
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.get_user_agent
|
39
|
-
ruby_version = RUBY_VERSION.to_s
|
40
|
-
version = AwsLambdaRuntimeInterfaceClient::VERSION
|
41
|
-
|
42
|
-
"aws-lambda-ruby/#{ruby_version}-#{version}"
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|