事件和契约驱动的无服务器“应用程序”框架
jeff的Python项目详细描述
Jeffy是Python AWS Lambda的无服务器应用程序框架。
说明
Jeffy是Python的无服务器的^{str1}$“Application”框架,它是 Lambda函数的一套实用程序,使开发无服务器应用程序变得容易。在
杰菲主要关注三件事。在
- 日志:提供易于查看的JSON格式日志记录。所有装饰器都捕获所有事件、响应和错误。您可以配置为将您希望看到的其他属性注入到日志中。在
- Decorators:为了节省时间来实现Lambda函数的公共功能,提供一些有用的装饰器和实用程序。在
- 跟踪:在相关函数和AWS服务中生成并传递
correlation_id
的可跟踪事件。在 - 可配置:您可以轻松自定义框架设置。在
- 在 在
- 在
- 2.1条。common
- 2.2条。rest_api
- 2.3条。sqs
- 2.4条。sns
- 2.5条。kinesis_streams
- 2.6条。dynamodb_streams
- 2.7条。s3
- 2.8条。schedule
- 在
- 3.1条。Kinesis Clinent
- 3.2条。SNS Client
- 3.3条。SQS Client
- 3.4条。S3 Client
- 在 在
- 在
- 5.1条。JSONSchemaValidator
安装
$ pip install jeffy
特点
1。Logging
1.1. Basic Usage
Jeffy logger automatically inject some Lambda contexts to CloudWatchLogs.
^{pr 2}$Output in CloudWatchLogs
^{pr 3}$1.2. Injecting additional attributes to logs
You can inject some additional attributes what you want to output with using ^{
Output in CloudWatchLogs
^{pr 5}$1.3. Change the attribute name of correlation id
You can change the attribute name of correlation id in the setting options.
^{pr 6}$Output in CloudWatchLogs
^{pr 7}$1.4. Change the log lervel
You can change the log level of Jeffy logger.
^{pr 8}$2. Event handlers
Decorators make simple to implement common lamdba tasks, such as parsing array from Kinesis, SNS, SQS events etc.
Here are provided decorators
2.1. common
^{
Error output with auto_logging
^{pr 10}$2.2. rest_api
Decorator for API Gateway event. Automatically get the correlation id from request header and set the correlation id to response header.
Default encoding is ^{
Default header name is 'x-jeffy-correlation-id'. You can change this name in the setting option.
^{pr 12}$2.3. sqs
Decorator for sqs event. Automaticlly parse ^{
Default encoding is ^{
2.4. sns
Decorator for sns event. Automaticlly parse ^{
Default encoding is ^{
2.5. kinesis_streams
Decorator for kinesis stream event. Automaticlly parse ^{
Default encoding is ^{
2.6. dynamodb_streams
Decorator for dynamodb stream event. Automaticlly parse ^{
2.7. s3
Decorator for S3 event. Automatically parse body stream from triggered S3 object and S3 bucket and key name to Lambda.
This handler requires ^{
Default encoding is ^{
2.8. schedule
Decorator for schedule event. just captures correlation id before main Lambda process. do nothing other than that.
^{pr 18}$3. SDK
Jeffy has the original wrapper clients of AWS SDK(boto3). The clients automatically inject ^{
3.1. Kinesis Clinent
Default encoding is ^{
3.2. SNS Client
Default encoding is ^{
3.3. SQS Client
Default encoding is ^{
3.4. S3 Client
Default encoding is ^{
4. Encoding
Each handler and SDK client has a default encoding and automatically encode/decode the data from/to python object. And you can change the encoding.
Currently, the encodings you can choose are:
- ^{
} - ^{
}
Each encoding class also has ^{
5. Validation
5.1. JSONSchemaValidator
^{
Requirements
- Python 3.6 or higher
Development
- Source hosted at GitHub
- 在GitHub Issues上报告问题/问题/功能请求
拉请求是非常欢迎的!确保你的贴片经过良好测试。 理想情况下,为您所做的每一个单独的更改创建一个主题分支。为 示例:
- 分拆回购
- 创建您的功能分支(
git checkout -b my-new-feature
) - 提交更改(
git commit -am"Added some feature"
) - 推到分支(
git push origin my-new-feature
) - 创建新的请求请求
作者
- 由Masashi Terui(marcy9114@gmail.com)买下了最初的想法
- 由Serverless Operations, Inc创建和维护
学分
Jeffy的灵感来自以下产品。在
许可证
MIT许可证(见LICENSE)
- 项目
标签: