Skip to main content

A library for tracking transactions in Flask and FastAPI applications.

Project description

Overview

The tracking_lib is a python module that is used by the PA development team to orchestrate the control messages that are sent in the Control Channel. It uses the Web Frameworks' (Flask, FastAPI) feature to keep a state in the request lifecycle in order to maintain and communicate a transaction id among different services. The following section describes the supprted features.

Features

  • Create and store a Transaction id
  • Sent status messages for SUCCESS or FAILURE

Installation

pip install tracking-lib

How to use it

import os

from tracking_lib.config import Config
from tracking_lib.transaction import Transaction
from flask import Flask, jsonify

app = Flask(__name__)


def interactor_runc():
    # print(f"transaction_id in interactor func: {Transaction.read_transaction_id()}")
    return Transaction.read_transaction_id()


@app.route("/")
def hello_world_success():
    Transaction.init(Config(
         downstream_service="TVDI_CONFIGS_MANAGER",
        control_channel_project_id=os.getenv("CONTROL_CHANNEL_PROJECT_ID"),
        control_channel_topic_id=os.getenv("CONTROL_CHANNEL_TOPIC_ID")

    ))
    Transaction.set_transaction_id("123456")
    tr_id = interactor_runc()
    Transaction.set_transaction_status(src_event_name="AN_SRC_EVENT_NAME")
    return jsonify(message=tr_id)

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

tracking_lib-0.1.16.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracking_lib-0.1.16-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file tracking_lib-0.1.16.tar.gz.

File metadata

  • Download URL: tracking_lib-0.1.16.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for tracking_lib-0.1.16.tar.gz
Algorithm Hash digest
SHA256 6a95ef8edfdd9bb8aeeaf8ddd13529af13f3e1ae2d2134a9f887dee3345f3ec4
MD5 3b818deebf1f78b181236943f71f25ea
BLAKE2b-256 8e9b6887bcf7ad5d9d0d4b74e3bf355cc5d8a6fffd8a236b7377859d380ed8be

See more details on using hashes here.

File details

Details for the file tracking_lib-0.1.16-py3-none-any.whl.

File metadata

  • Download URL: tracking_lib-0.1.16-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for tracking_lib-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 2d0d2b42c22bbaccec6a7e9773be373455e4ed6fc60d283ec3981f1a4cc156eb
MD5 43dd0684f770cba5e720db816ae67937
BLAKE2b-256 471c4aedc96d02c29ec0c6ab61588da8dd6d8fd969f34442a3c3ff95efb4d056

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page