You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 2. <aname='Eventsourcespecificdecorators'></a>Event source specific decorators
160
+
## 2. <aname='Eventhandlers'></a>Event handlers
161
161
Decorators make simple to implement common lamdba tasks, such as parsing array from Kinesis, SNS, SQS events etc.
162
162
163
163
Here are provided decorators
@@ -210,7 +210,7 @@ Error output with auto_logging
210
210
### 2.2. <aname='rest_api'></a>rest_api
211
211
Decorator for API Gateway event. Automatically get the correlation id from request header and set the correlation id to response header.
212
212
213
-
Default event payload encoding is `jeffy.encoding.json.JsonEncoding`.
213
+
Default encoding is `jeffy.encoding.json.JsonEncoding`.
214
214
215
215
```python
216
216
from jeffy.framework import get_app
@@ -250,7 +250,7 @@ def handler(event, context):
250
250
### 2.3. <aname='sqs'></a>sqs
251
251
Decorator for sqs event. Automaticlly parse `"event.Records"` list from SQS event source to each items for making it easy to treat it inside main process of Lambda.
252
252
253
-
Default event payload encoding is `jeffy.encoding.json.JsonEncoding`.
253
+
Default encoding is `jeffy.encoding.json.JsonEncoding`.
254
254
255
255
```python
256
256
from jeffy.framework import get_app
@@ -274,7 +274,7 @@ def handler(event, context):
274
274
### 2.4. <aname='sns'></a>sns
275
275
Decorator for sns event. Automaticlly parse `event.Records` list from SNS event source to each items for making it easy to treat it inside main process of Lambda.
276
276
277
-
Default event payload encoding is `jeffy.encoding.json.JsonEncoding`.
277
+
Default encoding is `jeffy.encoding.json.JsonEncoding`.
Decorator for kinesis stream event. Automaticlly parse `event.Records` list from Kinesis event source to each items and decode it with base64 for making it easy to treat it inside main process of Lambda.
300
300
301
-
Default event payload encoding is `jeffy.encoding.json.JsonEncoding`.
301
+
Default encoding is `jeffy.encoding.json.JsonEncoding`.
302
302
303
303
```python
304
304
from jeffy.framework import get_app
@@ -344,7 +344,7 @@ def handler(event, context):
344
344
### 2.7. <aname='s3'></a>s3
345
345
Decorator for S3 event. Automatically parse body stream from triggered S3 object and S3 bucket and key name to Lambda.
346
346
347
-
Default event payload encoding is `jeffy.encoding.bytes.BytesEncoding`.
347
+
Default encoding is `jeffy.encoding.bytes.BytesEncoding`.
Each handler has a a default encoding and automatically decode the data to python object. And you can change the encoding.
374
+
## 3. <aname='SDK'></a>SDK
375
+
Jeffy has the original wrapper clients of AWS SDK(boto3). The clients automatically inject `correlation_id` in the event payload and encode it to the specified(or default) encoding.
`JsonSchemeValidator`is automatically validate event payload with following json scheme you define. raise`ValidationError` exception if the validation fails.
404
-
405
-
```python
406
-
from jeffy.framework import get_app
407
-
from jeffy.validator.jsonscheme import JsonSchemeValidator
408
-
409
-
app= get_app()
410
-
411
-
@app.handlers.rest_api(
412
-
validator=JsonSchemeValidator(scheme={
413
-
'type': 'object',
414
-
'properties': {
415
-
'message': {'type': 'string'}}}))
416
-
def handler(event, context):
417
-
return {
418
-
'statusCode': 200,
419
-
'headers': 'Content-Type':'application/json',
420
-
'body': json.dumps({
421
-
'message': 'ok.'
422
-
})
423
-
}
424
-
```
425
-
426
-
## 5. <a name='Tracing'></a>Tracing
427
-
`correlation_id`is to trace subsequent Lambda functions and services. Jeffy automatically extract correlation IDs and caputure logs from the invocation event.
428
-
429
-
And Jeffy provide boto3 wrapper client to create and automatically inject `correlation_id`.
`JsonSchemeValidator`is automatically validate event payload with following json scheme you define. raise`ValidationError` exception if the validation fails.
483
+
484
+
```python
485
+
from jeffy.framework import get_app
486
+
from jeffy.validator.jsonscheme import JsonSchemeValidator
0 commit comments