{"id":47875283,"url":"https://github.com/callowayproject/bgtransport","last_synced_at":"2026-04-04T01:11:49.786Z","repository":{"id":287949195,"uuid":"959261475","full_name":"callowayproject/bgtransport","owner":"callowayproject","description":"Send messages to a background processor","archived":false,"fork":false,"pushed_at":"2026-03-30T19:46:45.000Z","size":24,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-03-30T21:26:58.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/callowayproject.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-02T14:01:37.000Z","updated_at":"2025-04-02T14:05:14.000Z","dependencies_parsed_at":"2025-04-14T20:22:39.509Z","dependency_job_id":"b3fc3b75-07f9-4552-819d-fa3e0ce8556e","html_url":"https://github.com/callowayproject/bgtransport","commit_stats":null,"previous_names":["callowayproject/bgtransport"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/callowayproject/bgtransport","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callowayproject%2Fbgtransport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callowayproject%2Fbgtransport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callowayproject%2Fbgtransport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callowayproject%2Fbgtransport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/callowayproject","download_url":"https://codeload.github.com/callowayproject/bgtransport/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callowayproject%2Fbgtransport/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31383780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T23:20:52.058Z","status":"ssl_error","status_checked_at":"2026-04-03T23:20:51.675Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T01:11:48.248Z","updated_at":"2026-04-04T01:11:49.780Z","avatar_url":"https://github.com/callowayproject.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Background Transport\n\nA background data transport.\n\n## Installation\n\nThe basic library is installable via `pip`\n\n```shell\npip install bgtransport\n```\nBut you will need two additional things to make things work: a transport method and a serialization method.\n\n\n## Example\n\n```python\nfrom confluent_kafka import Producer\nfrom bgtransport.transport.kafka import KafkaTransport, KeyGetter\nfrom ds_serialization.json import dumps\nfrom bgtransport import create_task\n\n\ndef delivery_report(err, msg):\n    if err is not None:\n        print(f\"Message delivery failed: {err}\")\n    else:\n        print(f\"Message delivered to {msg.topic()} [{msg.partition()}]\")\n\n\nkafka_client = Producer({'bootstrap.servers': 'mybroker1,mybroker2'})\nproduce_kwargs = {\"callback\": delivery_report}\ntransport = KafkaTransport(\n    serializer=dumps,\n    kafka_client=kafka_client,\n    topic=\"foobarauditor\",\n    key_generator=KeyGetter(\"uid\"),\n    flush_timeout=0.5,\n    produce_kwargs=produce_kwargs,\n)\n\ncreate_task(\"auditor\", transport)\n```\n\n```python\nfrom bgtransport import get_task\nfrom .stuff import do_something\n\nauditor = get_task(\"auditor\")\n\n\ndef route(request):\n    auditor.new_record()\n    do_something(request)\n    auditor.send_record()\n    return 200\n```\n\n```python\nfrom bgtransport import get_task\n\nauditor = get_task(\"auditor\")\n\n\ndef do_something(request):\n    auditor.update(key=value, key2=value2, key3=value3)\n```\n\n```python\nfrom starlette_context import request_cycle_context\nfrom fastapi import FastAPI, Depends\n\n\nkafka_client = Producer({'bootstrap.servers': 'mybroker1,mybroker2'})\nproduce_kwargs = {\"callback\": delivery_report}\ntransport = KafkaTransport(\n    serializer=dumps,\n    kafka_client=kafka_client,\n    topic=\"foobarauditor\",\n    key_generator=KeyGetter(\"uid\"),\n    flush_timeout=0.5,\n    produce_kwargs=produce_kwargs,\n)\n\nasync def setup_audit_task():\n    \"\"\"\n    This sets up the audit task in each request.\n    \"\"\"\n    create_task(\"auditor\", transport)\n    \n    with request_cycle_context({}):\n        yield\n\n# use it as Depends across the whole FastAPI app\napp = FastAPI(dependencies=[Depends(my_context_dependency)])\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallowayproject%2Fbgtransport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcallowayproject%2Fbgtransport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallowayproject%2Fbgtransport/lists"}