事件和契约驱动的无服务器“应用程序”框架

jeff的Python项目详细描述


PyPI versionJeffy CILicense: MITPython Versions

Serverless Application Framework Jeffy

Jeffy是Python AWS Lambda的无服务器应用程序框架。

说明

Jeffy是Python的无服务器的^{str1}$“Application”框架,它是 Lambda函数的一套实用程序,使开发无服务器应用程序变得容易。在

杰菲主要关注三件事。在

  • 日志:提供易于查看的JSON格式日志记录。所有装饰器都捕获所有事件、响应和错误。您可以配置为将您希望看到的其他属性注入到日志中。在
  • Decorators:为了节省时间来实现Lambda函数的公共功能,提供一些有用的装饰器和实用程序。在
  • 跟踪:在相关函数和AWS服务中生成并传递correlation_id的可跟踪事件。在
  • 可配置:您可以轻松自定义框架设置。在

安装

$ 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 ^{} method.

^{pr 4}$

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

^{} decorator allows you to output ^{}, ^{} and error infomations when you face Exceptions

^{pr 9}$

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 ^{}.

^{pr 11}$

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 ^{} list from SQS event source to each items for making it easy to treat it inside main process of Lambda.

Default encoding is ^{}.

^{pr 13}$

2.4. sns

Decorator for sns event. Automaticlly parse ^{} list from SNS event source to each items for making it easy to treat it inside main process of Lambda.

Default encoding is ^{}.

^{pr 14}$

2.5. kinesis_streams

Decorator for kinesis stream event. Automaticlly parse ^{} 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.

Default encoding is ^{}.

^{pr 15}$

2.6. dynamodb_streams

Decorator for dynamodb stream event. Automaticlly parse ^{} list from Dynamodb event source to items for making it easy to treat it inside main process of Lambda.

^{pr 16}$

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 ^{} permission.

Default encoding is ^{}.

^{pr 17}$

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 ^{} in the event payload and encode it to the specified(or default) encoding.

3.1. Kinesis Clinent

Default encoding is ^{}.

^{pr 19}$

3.2. SNS Client

Default encoding is ^{}.

^{pr 20}$

3.3. SQS Client

Default encoding is ^{}.

^{pr 21}$

3.4. S3 Client

Default encoding is ^{}.

^{pr 22}$

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 ^{} methods to encode ^{} data into own encoding.

^{pr 23}$

5. Validation

5.1. JSONSchemaValidator

^{} is automatically validate event payload with following json schema you define. raise ^{} exception if the validation fails.

^{pr 24}$

Requirements

  • Python 3.6 or higher

Development

拉请求是非常欢迎的!确保你的贴片经过良好测试。 理想情况下,为您所做的每一个单独的更改创建一个主题分支。为 示例:

  1. 分拆回购
  2. 创建您的功能分支(git checkout -b my-new-feature
  3. 提交更改(git commit -am"Added some feature"
  4. 推到分支(git push origin my-new-feature
  5. 创建新的请求请求

作者

学分

Jeffy的灵感来自以下产品。在

许可证

MIT许可证(见LICENSE

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java WebClient请求级别超时抛出名为default onErrorDropped的运算符   java JAXB外部绑定文件错误   Freemarker中的java转义宏参数值   java正在同步来自不同对象{已编辑}的线程   java如何在另一个类上更新活动中的元素   java Hibernate连接查询   java可以使用Apache Crunch创建类似于图形的数据结构吗?   java在JLabel的开头加上3个点   java 安卓应用程序显示线程错误   java@RequestBody在Spring中总是空的   java Android异步任务永远不会结束   具有多个属性的java Jaxws枚举   java中的安卓 Stripe InvalidRequestException   多线程java。util。非多线程程序中的ConcurrentModificationException   Minecraft Java插件如何删除HashMap中存储的所有块   空Java字符串的大小   从AJP连接器请求检索Shibboleth属性的java   oracle11g将Java类文件加载到Oracle数据库