aws_lambda_ric 1.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +159 -213
- data/README.md +15 -5
- data/aws_lambda_ric.gemspec +5 -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 +20 -21
- data/lib/aws_lambda_ric/logger_patch.rb +22 -0
- 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 +60 -32
- metadata +34 -7
- data/Gemfile.lock +0 -22
- data/lib/aws_lambda_ric/bootstrap.rb +0 -38
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
|
|
@@ -113,7 +112,7 @@ This runs the image as a container and starts up an endpoint locally at `http://
|
|
113
112
|
3) Post an event to the following endpoint using a curl command:
|
114
113
|
|
115
114
|
```shell script
|
116
|
-
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
|
115
|
+
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
|
117
116
|
```
|
118
117
|
|
119
118
|
This command invokes the function running in the container image and returns a response.
|
@@ -137,15 +136,26 @@ 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
|
|
143
|
+
### Troubleshooting
|
144
|
+
While running integration tests, you might encounter the Docker Hub rate limit error with the following body:
|
145
|
+
```
|
146
|
+
You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limits
|
147
|
+
```
|
148
|
+
To fix the above issue, consider authenticating to a Docker Hub account by setting the Docker Hub credentials as below CodeBuild environment variables.
|
149
|
+
```shell script
|
150
|
+
DOCKERHUB_USERNAME=<dockerhub username>
|
151
|
+
DOCKERHUB_PASSWORD=<dockerhub password>
|
152
|
+
```
|
153
|
+
Recommended way is to set the Docker Hub credentials in CodeBuild job by retrieving them from AWS Secrets Manager.
|
154
|
+
|
144
155
|
## Security
|
145
156
|
|
146
157
|
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
|
147
158
|
|
148
159
|
## License
|
149
160
|
|
150
|
-
This project is licensed under the Apache-2.0 License.
|
151
|
-
|
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,7 +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'
|
37
|
+
spec.add_development_dependency 'activesupport', '~> 6.0.1'
|
38
|
+
spec.add_development_dependency 'test-unit', '~> 3.5.5'
|
40
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,37 +1,36 @@
|
|
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
|
|
13
|
-
|
14
|
-
|
11
|
+
MAX_HEADER_SIZE_BYTES = 1024 * 1024
|
12
|
+
LONG_TIMEOUT_MS = 1_000_000
|
15
13
|
|
16
|
-
def initialize(server_address)
|
14
|
+
def initialize(server_address, user_agent)
|
17
15
|
server_address ||= LAMBDA_DEFAULT_SERVER_ADDRESS
|
18
|
-
@server_address =
|
16
|
+
@server_address = "http://#{server_address}/#{LAMBDA_RUNTIME_API_VERSION}"
|
17
|
+
@user_agent = user_agent
|
19
18
|
end
|
20
19
|
|
21
20
|
def next_invocation
|
22
21
|
next_invocation_uri = URI(@server_address + '/runtime/invocation/next')
|
23
22
|
begin
|
24
23
|
http = Net::HTTP.new(next_invocation_uri.host, next_invocation_uri.port)
|
25
|
-
http.read_timeout =
|
24
|
+
http.read_timeout = LONG_TIMEOUT_MS
|
26
25
|
resp = http.start do |connection|
|
27
|
-
connection.get(next_invocation_uri.path)
|
26
|
+
connection.get(next_invocation_uri.path, { 'User-Agent' => @user_agent })
|
28
27
|
end
|
29
28
|
if resp.is_a?(Net::HTTPSuccess)
|
30
29
|
request_id = resp['Lambda-Runtime-Aws-Request-Id']
|
31
30
|
[request_id, resp]
|
32
31
|
else
|
33
32
|
raise LambdaErrors::InvocationError.new(
|
34
|
-
|
33
|
+
"Received #{resp.code} when waiting for next invocation."
|
35
34
|
)
|
36
35
|
end
|
37
36
|
rescue LambdaErrors::InvocationError => e
|
@@ -49,9 +48,9 @@ class LambdaServer
|
|
49
48
|
response_object = response_object.read
|
50
49
|
end
|
51
50
|
Net::HTTP.post(
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
response_uri,
|
52
|
+
response_object,
|
53
|
+
{ 'Content-Type' => content_type, 'User-Agent' => @user_agent }
|
55
54
|
)
|
56
55
|
rescue StandardError => e
|
57
56
|
raise LambdaErrors::LambdaRuntimeError.new(e)
|
@@ -61,12 +60,12 @@ class LambdaServer
|
|
61
60
|
def send_error_response(request_id:, error_object:, error:, xray_cause:)
|
62
61
|
response_uri = URI(@server_address + "/runtime/invocation/#{request_id}/error")
|
63
62
|
begin
|
64
|
-
headers = { 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type }
|
65
|
-
headers['Lambda-Runtime-Function-XRay-Error-Cause'] = xray_cause if xray_cause.bytesize <
|
63
|
+
headers = { 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type, 'User-Agent' => @user_agent }
|
64
|
+
headers['Lambda-Runtime-Function-XRay-Error-Cause'] = xray_cause if xray_cause.bytesize < MAX_HEADER_SIZE_BYTES
|
66
65
|
Net::HTTP.post(
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
response_uri,
|
67
|
+
error_object.to_json,
|
68
|
+
headers
|
70
69
|
)
|
71
70
|
rescue StandardError => e
|
72
71
|
raise LambdaErrors::LambdaRuntimeError.new(e)
|
@@ -77,9 +76,9 @@ class LambdaServer
|
|
77
76
|
uri = URI("#{@server_address}/runtime/init/error")
|
78
77
|
begin
|
79
78
|
Net::HTTP.post(
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
uri,
|
80
|
+
error_object.to_json,
|
81
|
+
{ 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type, 'User-Agent' => @user_agent }
|
83
82
|
)
|
84
83
|
rescue StandardError => e
|
85
84
|
raise LambdaErrors::LambdaRuntimeInitError.new(e)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
|
3
|
+
module LoggerPatch
|
4
|
+
def initialize(logdev, shift_age = 0, shift_size = 1048576, level: 'debug',
|
5
|
+
progname: nil, formatter: nil, datetime_format: nil,
|
6
|
+
binmode: false, shift_period_suffix: '%Y%m%d')
|
7
|
+
# use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
|
8
|
+
if logdev && logdev != $stdout && logdev != $stderr
|
9
|
+
super(logdev, shift_age, shift_size, level: level, progname: progname,
|
10
|
+
formatter: formatter, datetime_format: datetime_format,
|
11
|
+
binmode: binmode, shift_period_suffix: shift_period_suffix)
|
12
|
+
else
|
13
|
+
self.level = level
|
14
|
+
self.progname = progname
|
15
|
+
@default_formatter = LogFormatter.new
|
16
|
+
self.datetime_format = datetime_format
|
17
|
+
self.formatter = formatter
|
18
|
+
@logdev = AwsLambdaRIC::TelemetryLogger.telemetry_log_sink
|
19
|
+
@level_override = {}
|
20
|
+
end
|
21
|
+
end
|
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'
|
@@ -8,6 +6,7 @@ require_relative 'aws_lambda_ric/lambda_handler'
|
|
8
6
|
require_relative 'aws_lambda_ric/lambda_context'
|
9
7
|
require_relative 'aws_lambda_ric/lambda_logger'
|
10
8
|
require_relative 'aws_lambda_ric/lambda_log_formatter'
|
9
|
+
require_relative 'aws_lambda_ric/logger_patch'
|
11
10
|
require_relative 'aws_lambda_ric/telemetry_log_sink'
|
12
11
|
require_relative 'aws_lambda_ric/aws_lambda_marshaller'
|
13
12
|
require_relative 'aws_lambda_ric/xray_cause'
|
@@ -16,17 +15,24 @@ require 'logger'
|
|
16
15
|
|
17
16
|
$stdout.sync = true # Ensures that logs are flushed promptly.
|
18
17
|
|
19
|
-
module
|
18
|
+
module AwsLambdaRIC
|
20
19
|
|
21
20
|
class Error < StandardError; end
|
22
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
|
+
|
23
29
|
# Loads the user code and runs it upon invocation
|
24
30
|
class LambdaRunner
|
25
31
|
|
26
32
|
ENV_VAR_RUNTIME_API = 'AWS_LAMBDA_RUNTIME_API'
|
27
33
|
|
28
|
-
def initialize(runtime_server_addr)
|
29
|
-
@lambda_server =
|
34
|
+
def initialize(runtime_server_addr, user_agent)
|
35
|
+
@lambda_server = RapidClient.new(runtime_server_addr, user_agent)
|
30
36
|
@runtime_loop_active = true # if false, we will exit the program
|
31
37
|
@exit_code = 0
|
32
38
|
end
|
@@ -44,7 +50,7 @@ module AwsLambdaRuntimeInterfaceClient
|
|
44
50
|
@exit_code = -4
|
45
51
|
send_init_error_to_server(e)
|
46
52
|
ensure
|
47
|
-
|
53
|
+
TelemetryLogger.close
|
48
54
|
end
|
49
55
|
|
50
56
|
exit(@exit_code)
|
@@ -105,7 +111,7 @@ module AwsLambdaRuntimeInterfaceClient
|
|
105
111
|
@lambda_server.send_init_error(error_object: ex.to_lambda_response, error: ex)
|
106
112
|
end
|
107
113
|
|
108
|
-
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)
|
109
115
|
error_object = err.to_lambda_response
|
110
116
|
@lambda_server.send_error_response(
|
111
117
|
request_id: lambda_invocation.request_id,
|
@@ -120,7 +126,7 @@ module AwsLambdaRuntimeInterfaceClient
|
|
120
126
|
end
|
121
127
|
|
122
128
|
# Helper class to for mutating std logger with TelemetryLog
|
123
|
-
class
|
129
|
+
class TelemetryLogger
|
124
130
|
|
125
131
|
ENV_VAR_TELEMETRY_LOG_FD = '_LAMBDA_TELEMETRY_LOG_FD'
|
126
132
|
|
@@ -132,40 +138,32 @@ module AwsLambdaRuntimeInterfaceClient
|
|
132
138
|
end
|
133
139
|
end
|
134
140
|
|
135
|
-
def initialize(telemetry_log_fd
|
136
|
-
fd =
|
137
|
-
|
138
|
-
|
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
|
139
145
|
|
140
|
-
|
146
|
+
AwsLambdaRIC::TelemetryLogger.telemetry_log_sink = TelemetryLogSink.new(file: AwsLambdaRIC::TelemetryLogger.telemetry_log_fd_file)
|
141
147
|
|
142
148
|
mutate_std_logger
|
143
149
|
mutate_kernel_puts
|
144
|
-
rescue Errno::ENOENT
|
150
|
+
rescue Errno::ENOENT, Errno::EBADF
|
145
151
|
# If File.open() fails, then the mutation won't happen and the default behaviour (print to stdout) will prevail
|
146
152
|
end
|
147
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
|
+
|
148
162
|
private
|
149
163
|
|
150
164
|
def mutate_std_logger
|
151
165
|
Logger.class_eval do
|
152
|
-
|
153
|
-
def initialize(logdev, shift_age = 0, shift_size = 1048576, level: 'debug',
|
154
|
-
progname: nil, formatter: nil, datetime_format: nil,
|
155
|
-
binmode: false, shift_period_suffix: '%Y%m%d')
|
156
|
-
# use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
|
157
|
-
if logdev && logdev != $stdout && logdev != $stderr
|
158
|
-
orig_initialize(logdev, shift_age, shift_size, level, progname,
|
159
|
-
formatter, datetime_format, binmode, shift_period_suffix)
|
160
|
-
else
|
161
|
-
self.level = level
|
162
|
-
self.progname = progname
|
163
|
-
@default_formatter = LambdaLogFormatter.new
|
164
|
-
self.datetime_format = datetime_format
|
165
|
-
self.formatter = formatter
|
166
|
-
@logdev = AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper.telemetry_log_sink
|
167
|
-
end
|
168
|
-
end
|
166
|
+
prepend LoggerPatch
|
169
167
|
end
|
170
168
|
end
|
171
169
|
|
@@ -173,7 +171,11 @@ module AwsLambdaRuntimeInterfaceClient
|
|
173
171
|
Kernel.module_eval do
|
174
172
|
def puts(*arg)
|
175
173
|
msg = arg.flatten.collect { |a| a.to_s.encode('UTF-8') }.join("\n")
|
176
|
-
|
174
|
+
if msg[-1] != "\n"
|
175
|
+
msg += "\n"
|
176
|
+
end
|
177
|
+
AwsLambdaRIC::TelemetryLogger.telemetry_log_sink.write(msg)
|
178
|
+
return nil
|
177
179
|
end
|
178
180
|
end
|
179
181
|
end
|
@@ -191,4 +193,30 @@ module AwsLambdaRuntimeInterfaceClient
|
|
191
193
|
@trace_id = trace_id
|
192
194
|
end
|
193
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
|
194
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
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 6.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
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
|
55
83
|
description: The AWS Lambda Ruby Runtime Interface Client implements the Lambda programming
|
56
84
|
model for Ruby.
|
57
85
|
email:
|
@@ -61,7 +89,6 @@ extensions: []
|
|
61
89
|
extra_rdoc_files: []
|
62
90
|
files:
|
63
91
|
- Gemfile
|
64
|
-
- Gemfile.lock
|
65
92
|
- LICENSE
|
66
93
|
- NOTICE
|
67
94
|
- README.md
|
@@ -69,13 +96,13 @@ files:
|
|
69
96
|
- bin/aws_lambda_ric
|
70
97
|
- lib/aws_lambda_ric.rb
|
71
98
|
- lib/aws_lambda_ric/aws_lambda_marshaller.rb
|
72
|
-
- lib/aws_lambda_ric/bootstrap.rb
|
73
99
|
- lib/aws_lambda_ric/lambda_context.rb
|
74
100
|
- lib/aws_lambda_ric/lambda_errors.rb
|
75
101
|
- lib/aws_lambda_ric/lambda_handler.rb
|
76
102
|
- lib/aws_lambda_ric/lambda_log_formatter.rb
|
77
103
|
- lib/aws_lambda_ric/lambda_logger.rb
|
78
104
|
- lib/aws_lambda_ric/lambda_server.rb
|
105
|
+
- lib/aws_lambda_ric/logger_patch.rb
|
79
106
|
- lib/aws_lambda_ric/telemetry_log_sink.rb
|
80
107
|
- lib/aws_lambda_ric/version.rb
|
81
108
|
- lib/aws_lambda_ric/xray_cause.rb
|
@@ -91,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
118
|
requirements:
|
92
119
|
- - ">="
|
93
120
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
121
|
+
version: '3.0'
|
95
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
123
|
requirements:
|
97
124
|
- - ">="
|
data/Gemfile.lock
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
aws_lambda_ric (1.0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
minitest (5.14.2)
|
10
|
-
rake (13.0.1)
|
11
|
-
|
12
|
-
PLATFORMS
|
13
|
-
ruby
|
14
|
-
|
15
|
-
DEPENDENCIES
|
16
|
-
aws_lambda_ric!
|
17
|
-
bundler (>= 2.0)
|
18
|
-
minitest (~> 5.0)
|
19
|
-
rake (~> 13.0)
|
20
|
-
|
21
|
-
BUNDLED WITH
|
22
|
-
2.2.0.rc.2
|
@@ -1,38 +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)
|
34
|
-
puts "Executing '#{handler}' in function directory '#{app_root}'"
|
35
|
-
lambda_runner.run(app_root, handler)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|