Python DSL for setting up Flask app CDC
Project description
This is a helper module to allow you to capture all the request/response which comes to your Flask app.
pip install aws_ssm-devlibx
How to use
from flask_cdc import cdc
# We expect you already have the flask app
app = "Existing flask"
# Recorder is called everytime you get request response. You can do anything you want
# In this example we have logged data with a helper function provided by cdc. You can change
# this method to do anything else
def recorder(state):
cdc.log_results(state)
# Wrap app to your session record MW
app.wsgi_app = cdc.SessionRecorderMiddleware(app.wsgi_app, recorder)
How to enable CDC
Set following env variable:
export CDC_KAFKA=<your kafka broker>
export CDC_TOPIC=<your kafka topic for CDC>
You can use the pre-defined recorder to send data to kafka:
app.wsgi_app = cdc.SessionRecorderMiddleware(app.wsgi_app, cdc.publish_result_to_kafka)
Once it is defined then you can see the following data in your topic
{
"request": {
"body": {
"archive_existing_versions": true,
"name": "harish",
"stage": "Staging",
"version": "2"
},
"method": "POST",
"url": "/ajax-api/2.0/preview/mlflow/model-versions/transition-stage"
},
"response": {
"status": "200 OK"
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aws-ssm-devlibx-0.0.2.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for aws_ssm_devlibx-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8397dacaec6a395d87e1e4fdafd4652c71987331409ffed295fff30db75e2140 |
|
MD5 | 4513a25cc5de85ee2f5cb5bc55317d8a |
|
BLAKE2b-256 | d772eea7271cc8c3cc1ea9c7441aea229e39868751e14afa39009909d6004ec5 |