aws_lambda_ric 2.0.0 → 3.1.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 +40 -24
- data/aws_lambda_ric.gemspec +4 -5
- 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 +4 -5
- 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 +9 -12
- 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 +20 -7
- 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: 0f2523ec3d2acb227fa11e42ec19db8e6cfed477fd3fe696437e15ad403290c9
|
4
|
+
data.tar.gz: ada075ea78b2b5004ba1afae30a176621a7fb721d897911450916cd0605c02ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30b399adaafe4a614e8cbe4ebfebbec435fbeafe9be10e87033e6555a3b9dccb6ccaa2ac1d2a4ee1f909a067b9a1bf350317bb6e397786ee39ce44fa543926c
|
7
|
+
data.tar.gz: 9e2deffd3a8ad44bb62a5d9b66a8c3cf8b01ca70e3dd2a4898be35946cc69bef334e4e172d10d163c94194b54277fe7a2b7c0644364250848b6d83d6e09c7a92
|
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
@@ -1,25 +1,25 @@
|
|
1
1
|
## AWS Lambda Ruby Runtime Interface Client
|
2
2
|
|
3
|
-
We have open-sourced a set of software packages, Runtime Interface Clients (RIC), that
|
4
|
-
|
5
|
-
|
6
|
-
The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to
|
3
|
+
We have open-sourced a set of software packages, Runtime Interface Clients (RIC), that implements the Lambda
|
4
|
+
[Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html), allowing you to seamlessly extend
|
5
|
+
your preferred base images to be Lambda compatible.
|
6
|
+
The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to
|
7
|
+
receive requests from and send requests to the Lambda service.
|
7
8
|
|
8
9
|
The Lambda Ruby Runtime Interface Client is vended through [rubygems](https://rubygems.org/gems/aws_lambda_ric).
|
9
10
|
You can include this package in your preferred base image to make that base image Lambda compatible.
|
10
11
|
|
11
12
|
## Requirements
|
12
|
-
The Ruby Runtime Interface Client package currently supports
|
13
|
-
- 2.5.x up to and including 2.7.x
|
13
|
+
The Ruby Runtime Interface Client package currently supports ruby 3.0 and above.
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
17
|
### Creating a Docker Image for Lambda with the Runtime Interface Client
|
18
18
|
First step is to choose the base image to be used. The supported Linux OS distributions are:
|
19
19
|
|
20
|
+
- Amazon Linux 2023
|
20
21
|
- Amazon Linux 2
|
21
22
|
- Alpine
|
22
|
-
- CentOS
|
23
23
|
- Debian
|
24
24
|
- Ubuntu
|
25
25
|
|
@@ -37,17 +37,9 @@ Or install it manually as:
|
|
37
37
|
|
38
38
|
$ gem install aws_lambda_ric
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# Copy function code
|
44
|
-
RUN mkdir -p ${FUNCTION_DIR}
|
45
|
-
COPY app.rb ${FUNCTION_DIR}
|
46
|
-
|
47
|
-
WORKDIR ${FUNCTION_DIR}
|
48
|
-
```
|
49
|
-
|
50
|
-
The next step would be to set the `ENTRYPOINT` property of the Docker image to invoke the Runtime Interface Client and then set the `CMD` argument to specify the desired handler.
|
40
|
+
The next step would be to copy your Lambda function code into the image's working directory.
|
41
|
+
You will need to set the `ENTRYPOINT` property of the Docker image to invoke the Runtime Interface Client and
|
42
|
+
then set the `CMD` argument to specify the desired handler.
|
51
43
|
|
52
44
|
Example Dockerfile:
|
53
45
|
```dockerfile
|
@@ -57,7 +49,7 @@ FROM amazonlinux:latest
|
|
57
49
|
ARG FUNCTION_DIR="/function"
|
58
50
|
|
59
51
|
# Install ruby
|
60
|
-
RUN
|
52
|
+
RUN dnf install -y ruby3.2 make
|
61
53
|
|
62
54
|
# Install bundler
|
63
55
|
RUN gem install bundler
|
@@ -65,6 +57,15 @@ RUN gem install bundler
|
|
65
57
|
# Install the Runtime Interface Client
|
66
58
|
RUN gem install aws_lambda_ric
|
67
59
|
|
60
|
+
# If you want to install Runtime Interface Client From Source, you can uncomment the following `ADD` and `RUN` layers.
|
61
|
+
# Do not forget to comment/remove the above `RUN gem install aws_lambda_ric` command.
|
62
|
+
# ADD https://github.com/aws/aws-lambda-ruby-runtime-interface-client.git /aws_lambda_ric
|
63
|
+
# RUN cd /aws_lambda_ric && \
|
64
|
+
# make init && \
|
65
|
+
# make build && \
|
66
|
+
# gem install --local /aws_lambda_ric/pkg/aws_lambda_ric-3.0.0.gem && \
|
67
|
+
# rm -rf /aws_lambda_ric
|
68
|
+
|
68
69
|
# Copy function code
|
69
70
|
RUN mkdir -p ${FUNCTION_DIR}
|
70
71
|
COPY app.rb ${FUNCTION_DIR}
|
@@ -75,7 +76,18 @@ ENTRYPOINT ["/usr/local/bin/aws_lambda_ric"]
|
|
75
76
|
CMD ["app.App::Handler.process"]
|
76
77
|
```
|
77
78
|
|
78
|
-
|
79
|
+
Note that the `ENTRYPOINT` may differ based on the base image used. You can find the correct path by running an
|
80
|
+
interactive shell in the container and checking the installed location of the gem.
|
81
|
+
|
82
|
+
```shell script
|
83
|
+
docker run -it --rm amazonlinux:latest bash
|
84
|
+
yum install -y which ruby
|
85
|
+
gem install aws_lambda_ric
|
86
|
+
which aws_lambda_ric
|
87
|
+
```
|
88
|
+
|
89
|
+
Finally, create a Ruby handler. This is an example `app.rb`:
|
90
|
+
|
79
91
|
```ruby
|
80
92
|
module App
|
81
93
|
class Handler
|
@@ -88,7 +100,10 @@ end
|
|
88
100
|
|
89
101
|
### Local Testing
|
90
102
|
|
91
|
-
To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server,
|
103
|
+
To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server,
|
104
|
+
Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests.
|
105
|
+
You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function.
|
106
|
+
Thenm when you run the image function, you set the entrypoint to be the emulator.
|
92
107
|
|
93
108
|
*To install the emulator and test your Lambda function*
|
94
109
|
|
@@ -99,7 +114,8 @@ mkdir -p ~/.aws-lambda-rie && \
|
|
99
114
|
curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && \
|
100
115
|
chmod +x ~/.aws-lambda-rie/aws-lambda-rie
|
101
116
|
```
|
102
|
-
|
117
|
+
|
118
|
+
1) Run your Lambda image function using the docker run command.
|
103
119
|
|
104
120
|
```shell script
|
105
121
|
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
|
@@ -110,7 +126,7 @@ docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
|
|
110
126
|
|
111
127
|
This runs the image as a container and starts up an endpoint locally at `http://localhost:9000/2015-03-31/functions/function/invocations`.
|
112
128
|
|
113
|
-
|
129
|
+
1) Post an event to the following endpoint using a curl command:
|
114
130
|
|
115
131
|
```shell script
|
116
132
|
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
|
@@ -137,7 +153,7 @@ Make sure the project is built:
|
|
137
153
|
make init build
|
138
154
|
```
|
139
155
|
Then,
|
140
|
-
* to run unit tests: `make test`
|
156
|
+
* to run unit tests: `make test-unit`
|
141
157
|
* to run integration tests: `make test-integ`
|
142
158
|
* to run smoke tests: `make test-smoke`
|
143
159
|
|
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[
|
@@ -33,8 +31,9 @@ Gem::Specification.new do |spec|
|
|
33
31
|
spec.executables = 'aws_lambda_ric'
|
34
32
|
spec.require_paths = ['lib']
|
35
33
|
|
36
|
-
spec.add_development_dependency 'bundler', '
|
34
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
37
35
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
38
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
39
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,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
|
class LambdaContext
|
6
4
|
attr_reader :aws_request_id, :invoked_function_arn, :log_group_name,
|
7
5
|
:log_stream_name, :function_name, :memory_limit_in_mb, :function_version,
|
8
|
-
:identity, :client_context, :deadline_ms
|
6
|
+
:identity, :tenant_id, :client_context, :deadline_ms
|
9
7
|
|
10
8
|
def initialize(request)
|
11
9
|
@clock_diff = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond) - Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
|
@@ -17,8 +15,9 @@ 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
|
-
@
|
18
|
+
@identity = JSON.parse(request['Lambda-Runtime-Cognito-Identity']) unless request['Lambda-Runtime-Cognito-Identity'].to_s.empty?
|
19
|
+
@tenant_id = request['Lambda-Runtime-Aws-Tenant-Id'] unless request['Lambda-Runtime-Aws-Tenant-Id'].to_s.empty?
|
20
|
+
@client_context = JSON.parse(request['Lambda-Runtime-Client-Context']) unless request['Lambda-Runtime-Client-Context'].to_s.empty?
|
22
21
|
end
|
23
22
|
|
24
23
|
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)
|
@@ -4,18 +4,15 @@ module LoggerPatch
|
|
4
4
|
def initialize(logdev, shift_age = 0, shift_size = 1048576, level: 'debug',
|
5
5
|
progname: nil, formatter: nil, datetime_format: nil,
|
6
6
|
binmode: false, shift_period_suffix: '%Y%m%d')
|
7
|
-
|
8
|
-
if logdev
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
else
|
13
|
-
self.level = level
|
14
|
-
self.progname = progname
|
15
|
-
@default_formatter = LambdaLogFormatter.new
|
16
|
-
self.datetime_format = datetime_format
|
17
|
-
self.formatter = formatter
|
18
|
-
@logdev = AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper.telemetry_log_sink
|
7
|
+
logdev_lambda_overwrite = logdev
|
8
|
+
# use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
|
9
|
+
if !logdev || logdev == $stdout || logdev == $stderr
|
10
|
+
logdev_lambda_overwrite = AwsLambdaRIC::TelemetryLogger.telemetry_log_sink
|
11
|
+
@default_formatter = LogFormatter.new
|
19
12
|
end
|
13
|
+
|
14
|
+
super(logdev_lambda_overwrite, shift_age, shift_size, level: level, progname: progname,
|
15
|
+
formatter: formatter, datetime_format: datetime_format,
|
16
|
+
binmode: binmode, shift_period_suffix: shift_period_suffix)
|
20
17
|
end
|
21
18
|
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.1.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-05-24 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:
|
@@ -82,7 +96,6 @@ files:
|
|
82
96
|
- bin/aws_lambda_ric
|
83
97
|
- lib/aws_lambda_ric.rb
|
84
98
|
- lib/aws_lambda_ric/aws_lambda_marshaller.rb
|
85
|
-
- lib/aws_lambda_ric/bootstrap.rb
|
86
99
|
- lib/aws_lambda_ric/lambda_context.rb
|
87
100
|
- lib/aws_lambda_ric/lambda_errors.rb
|
88
101
|
- lib/aws_lambda_ric/lambda_handler.rb
|
@@ -105,14 +118,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
118
|
requirements:
|
106
119
|
- - ">="
|
107
120
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
121
|
+
version: '3.0'
|
109
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
123
|
requirements:
|
111
124
|
- - ">="
|
112
125
|
- !ruby/object:Gem::Version
|
113
126
|
version: '0'
|
114
127
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.0.3
|
116
129
|
signing_key:
|
117
130
|
specification_version: 4
|
118
131
|
summary: AWS Lambda Runtime Interface Client for Ruby
|
@@ -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
|