Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ASGI support #1635

Merged
merged 49 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c5c8ec5
feat: initial ASGI support
Lancetnik Aug 3, 2024
15aa02a
docs: generate API References
Lancetnik Aug 3, 2024
8ac39f8
feat: add make_asyncapi_html method
Lancetnik Aug 3, 2024
f2afe38
Merge branch 'feat/asgi' of github.com:airtai/faststream into feat/asgi
Lancetnik Aug 3, 2024
32b68db
feat: detail make_asyncapi_asgi params
Lancetnik Aug 3, 2024
4ef0d06
refactor: reuse app.mount to add asyncapi url
Lancetnik Aug 3, 2024
94bb690
refactor: remove useless charset
Lancetnik Aug 3, 2024
6618d1a
refactor: add AsgiFastStream args comment
Lancetnik Aug 3, 2024
df75d67
refactor: rename AsgiFastStream lifespan
Lancetnik Aug 3, 2024
54c4ae6
tests: cover asgi
Lancetnik Aug 3, 2024
f742c9c
docs: add ASGI page
Lancetnik Aug 3, 2024
a5b26c9
tests: fix 3.8 compatibility
Lancetnik Aug 3, 2024
b4e171e
chore: make detail tests CI output
Lancetnik Aug 3, 2024
6223ff2
test: make asyncapi asgi test in-memory
Lancetnik Aug 3, 2024
6518a33
docs: add asgi and OTEL to Public API
Lancetnik Aug 3, 2024
cc14939
docs: run API generator
Lancetnik Aug 3, 2024
50655c0
Merge branch 'main' into feat/asgi
Lancetnik Aug 4, 2024
b4db46e
fix: use classmethod
Lancetnik Aug 4, 2024
42c2e3f
test: increase confuent testclient timeout
Lancetnik Aug 4, 2024
768bf3d
Merge branch 'main' into feat/asgi
Lancetnik Aug 4, 2024
99b0f70
tests: fix confluent
Lancetnik Aug 4, 2024
f0b9727
Merge branch 'feat/asgi' of github.com:airtai/faststream into feat/asgi
Lancetnik Aug 4, 2024
70c51a5
refactor: clarify BatchKafkaParser behavior
Lancetnik Aug 4, 2024
1893fcb
lint: run ruff
Lancetnik Aug 4, 2024
8f23bba
lint: fix mypy
Lancetnik Aug 4, 2024
8e64d6f
Update ASGI docs
kumaranvpl Aug 4, 2024
636cd1b
Merge branch 'feat/asgi' of github.com:airtai/faststream into feat/asgi
kumaranvpl Aug 4, 2024
b51b4ab
tests: fix confluent
Lancetnik Aug 5, 2024
ef4ecf1
chore: bump dependencies
Lancetnik Aug 5, 2024
16a2085
chore: bump version
Lancetnik Aug 5, 2024
2a7a875
chore: add kafka devcontainer
Lancetnik Aug 5, 2024
b49ed38
refactor: optimize confluent a bit
Lancetnik Aug 5, 2024
9bd52b9
refactor: optimize confluent client calls
Lancetnik Aug 6, 2024
aa2f44c
docs: generate API
Lancetnik Aug 6, 2024
f73d8fc
docs: remove useless API
Lancetnik Aug 6, 2024
4a2e2fc
chore: detail confluent tests
Lancetnik Aug 6, 2024
e432e29
tests: refactor to use custom args, kwargs for subscriber
Lancetnik Aug 6, 2024
9faa325
tests: fix confluent
Lancetnik Aug 7, 2024
d203fbf
docs: generate API References
Lancetnik Aug 7, 2024
a11f604
tests: fix asyncapi FastAPI
Lancetnik Aug 7, 2024
680bfe9
Merge branch 'feat/asgi' of github.com:airtai/faststream into feat/asgi
Lancetnik Aug 7, 2024
3fe4847
chore: revert FastAPI changes
Lancetnik Aug 7, 2024
92a2988
tests: increase confluent tests timeouts
Lancetnik Aug 7, 2024
3924a13
fix: fix Nats router subjects
Lancetnik Aug 7, 2024
24a0de6
lint: fix formating
Lancetnik Aug 7, 2024
81771b5
tests: increase confluent tests timeouts
Lancetnik Aug 7, 2024
6f2ebb8
lint: run ruff
Lancetnik Aug 7, 2024
741a22a
tests: remove explicit confluent address
Lancetnik Aug 7, 2024
83fe454
tests: run docs tests first
Lancetnik Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
"service": "python-3.12-faststream-studio",
"dockerComposeFile": [
"./docker-compose.yaml"
],
"shutdownAction": "stopCompose",
"forwardPorts": [
"kafka-faststream:9092"
],
"updateContentCommand": "bash .devcontainer/setup.sh",
"workspaceFolder": "/workspaces/faststream"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
33 changes: 33 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3'

services:
python-3.12-faststream-studio: # nosemgrep
image: mcr.microsoft.com/devcontainers/python:3.12
container_name: python-3.12-faststream-studio
volumes:
- ../:/workspaces/faststream:cached
command: sleep infinity
network_mode: "host"

kafka-faststream: # nosemgrep
image: bitnami/kafka:3.5.0
container_name: kafka-faststream
ports:
- 9092:9092
environment:
KAFKA_ENABLE_KRAFT: "true"
KAFKA_CFG_NODE_ID: "1"
KAFKA_CFG_PROCESS_ROLES: "broker,controller"
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
KAFKA_CFG_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093"
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://127.0.0.1:9092"
KAFKA_BROKER_ID: "1"
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "1@kafka-faststream:9093"
ALLOW_PLAINTEXT_LISTENER: "true"
networks:
- faststream-network

networks:
faststream-network:
name: "${USER}-faststream-network"
7 changes: 7 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pip install uv

uv venv .venv

uv pip install -e ".[dev]"

source .venv/bin/activate
17 changes: 0 additions & 17 deletions .github/dependabot.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
4 changes: 2 additions & 2 deletions .github/workflows/pr_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
run: pip install --pre "pydantic>=2.0.0b2,<3.0.0"
- run: mkdir coverage
- name: Test
run: bash scripts/test.sh -m "(slow and (not nats and not kafka and not confluent and not rabbit and not redis)) or (not nats and not kafka and not confluent and not rabbit and not redis)"
run: bash scripts/test.sh -vv -m "(slow and (not nats and not kafka and not confluent and not rabbit and not redis)) or (not nats and not kafka and not confluent and not rabbit and not redis)"
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
Expand Down Expand Up @@ -269,7 +269,7 @@ jobs:
run: pip install .[optionals,testing]
- run: mkdir coverage
- name: Test
run: bash scripts/test.sh -m "(slow and confluent) or confluent"
run: bash scripts/test.sh -vv -m "(slow and confluent) or confluent"
env:
COVERAGE_FILE: coverage/.coverage.confluent-py
CONTEXT: confluent-py
Expand Down
2 changes: 2 additions & 0 deletions docs/create_api_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@


PUBLIC_API_FILES = [
"faststream/opentelemetry/__init__.py",
"faststream/asgi/__init__.py",
"faststream/asyncapi/__init__.py",
"faststream/__init__.py",
"faststream/nats/__init__.py",
Expand Down
35 changes: 33 additions & 2 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ search:
- [FastAPI Plugin](getting-started/integrations/fastapi/index.md)
- [Django](getting-started/integrations/django/index.md)
- [CLI commands](getting-started/cli/index.md)
- [ASGI](getting-started/asgi.md)
- [OpenTelemetry](getting-started/opentelemetry/index.md)
- [Logging](getting-started/logging.md)
- [Config Management](getting-started/config/index.md)
Expand Down Expand Up @@ -120,6 +121,12 @@ search:
- [Response](public_api/faststream/Response.md)
- [TestApp](public_api/faststream/TestApp.md)
- [apply_types](public_api/faststream/apply_types.md)
- asgi
- [AsgiFastStream](public_api/faststream/asgi/AsgiFastStream.md)
- [AsgiResponse](public_api/faststream/asgi/AsgiResponse.md)
- [get](public_api/faststream/asgi/get.md)
- [make_asyncapi_asgi](public_api/faststream/asgi/make_asyncapi_asgi.md)
- [make_ping_asgi](public_api/faststream/asgi/make_ping_asgi.md)
- asyncapi
- [get_app_schema](public_api/faststream/asyncapi/get_app_schema.md)
- [get_asyncapi_html](public_api/faststream/asyncapi/get_asyncapi_html.md)
Expand All @@ -131,6 +138,7 @@ search:
- [KafkaRouter](public_api/faststream/confluent/KafkaRouter.md)
- [TestApp](public_api/faststream/confluent/TestApp.md)
- [TestKafkaBroker](public_api/faststream/confluent/TestKafkaBroker.md)
- [TopicPartition](public_api/faststream/confluent/TopicPartition.md)
- kafka
- [KafkaBroker](public_api/faststream/kafka/KafkaBroker.md)
- [KafkaPublisher](public_api/faststream/kafka/KafkaPublisher.md)
Expand Down Expand Up @@ -164,6 +172,9 @@ search:
- [StreamSource](public_api/faststream/nats/StreamSource.md)
- [TestApp](public_api/faststream/nats/TestApp.md)
- [TestNatsBroker](public_api/faststream/nats/TestNatsBroker.md)
- opentelemetry
- [TelemetryMiddleware](public_api/faststream/opentelemetry/TelemetryMiddleware.md)
- [TelemetrySettingsProvider](public_api/faststream/opentelemetry/TelemetrySettingsProvider.md)
- rabbit
- [ExchangeType](public_api/faststream/rabbit/ExchangeType.md)
- [RabbitBroker](public_api/faststream/rabbit/RabbitBroker.md)
Expand Down Expand Up @@ -200,6 +211,23 @@ search:
- [apply_types](api/faststream/apply_types.md)
- app
- [FastStream](api/faststream/app/FastStream.md)
- asgi
- [AsgiFastStream](api/faststream/asgi/AsgiFastStream.md)
- [AsgiResponse](api/faststream/asgi/AsgiResponse.md)
- [get](api/faststream/asgi/get.md)
- [make_asyncapi_asgi](api/faststream/asgi/make_asyncapi_asgi.md)
- [make_ping_asgi](api/faststream/asgi/make_ping_asgi.md)
- app
- [AsgiFastStream](api/faststream/asgi/app/AsgiFastStream.md)
- factories
- [make_asyncapi_asgi](api/faststream/asgi/factories/make_asyncapi_asgi.md)
- [make_ping_asgi](api/faststream/asgi/factories/make_ping_asgi.md)
- handlers
- [get](api/faststream/asgi/handlers/get.md)
- response
- [AsgiResponse](api/faststream/asgi/response/AsgiResponse.md)
- websocket
- [WebSocketClose](api/faststream/asgi/websocket/WebSocketClose.md)
- asyncapi
- [get_app_schema](api/faststream/asyncapi/get_app_schema.md)
- [get_asyncapi_html](api/faststream/asyncapi/get_asyncapi_html.md)
Expand All @@ -214,6 +242,7 @@ search:
- [get_response_schema](api/faststream/asyncapi/message/get_response_schema.md)
- [parse_handler_params](api/faststream/asyncapi/message/parse_handler_params.md)
- proto
- [AsyncAPIApplication](api/faststream/asyncapi/proto/AsyncAPIApplication.md)
- [AsyncAPIProto](api/faststream/asyncapi/proto/AsyncAPIProto.md)
- schema
- [Channel](api/faststream/asyncapi/schema/Channel.md)
Expand Down Expand Up @@ -429,6 +458,7 @@ search:
- [KafkaRouter](api/faststream/confluent/KafkaRouter.md)
- [TestApp](api/faststream/confluent/TestApp.md)
- [TestKafkaBroker](api/faststream/confluent/TestKafkaBroker.md)
- [TopicPartition](api/faststream/confluent/TopicPartition.md)
- broker
- [KafkaBroker](api/faststream/confluent/broker/KafkaBroker.md)
- broker
Expand All @@ -441,8 +471,6 @@ search:
- [AsyncConfluentConsumer](api/faststream/confluent/client/AsyncConfluentConsumer.md)
- [AsyncConfluentProducer](api/faststream/confluent/client/AsyncConfluentProducer.md)
- [BatchBuilder](api/faststream/confluent/client/BatchBuilder.md)
- [MsgToSend](api/faststream/confluent/client/MsgToSend.md)
- [TopicPartition](api/faststream/confluent/client/TopicPartition.md)
- [check_msg_error](api/faststream/confluent/client/check_msg_error.md)
- [create_topics](api/faststream/confluent/client/create_topics.md)
- config
Expand Down Expand Up @@ -496,8 +524,11 @@ search:
- [KafkaRoute](api/faststream/confluent/router/KafkaRoute.md)
- [KafkaRouter](api/faststream/confluent/router/KafkaRouter.md)
- schemas
- [TopicPartition](api/faststream/confluent/schemas/TopicPartition.md)
- params
- [ConsumerConnectionParams](api/faststream/confluent/schemas/params/ConsumerConnectionParams.md)
- partition
- [TopicPartition](api/faststream/confluent/schemas/partition/TopicPartition.md)
- security
- [parse_security](api/faststream/confluent/security/parse_security.md)
- subscriber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: faststream.confluent.client.MsgToSend
::: faststream.asgi.AsgiFastStream
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/AsgiResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.AsgiResponse
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/app/AsgiFastStream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.app.AsgiFastStream
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/factories/make_asyncapi_asgi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.factories.make_asyncapi_asgi
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/factories/make_ping_asgi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.factories.make_ping_asgi
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.get
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/handlers/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.handlers.get
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/make_asyncapi_asgi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.make_asyncapi_asgi
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/make_ping_asgi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.make_ping_asgi
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/response/AsgiResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.response.AsgiResponse
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asgi/websocket/WebSocketClose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asgi.websocket.WebSocketClose
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/asyncapi/proto/AsyncAPIApplication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.asyncapi.proto.AsyncAPIApplication
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: faststream.confluent.client.TopicPartition
::: faststream.confluent.TopicPartition
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/confluent/schemas/TopicPartition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.confluent.schemas.TopicPartition
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.confluent.schemas.partition.TopicPartition
Loading
Loading