Skip to content

Commit

Permalink
chore: add kafka devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed Aug 5, 2024
1 parent 16a2085 commit 2a7a875
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 19 deletions.
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:
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:
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
5 changes: 5 additions & 0 deletions serve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from faststream import FastStream
from faststream.kafka import KafkaBroker

broker = KafkaBroker()
app = FastStream(broker)
2 changes: 1 addition & 1 deletion tests/brokers/confluent/test_test_reentrancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def on_output_data(msg: int):
async with TestKafkaBroker(broker) as tester:
await tester.publish(1, "input_data")

await on_output_data.wait_call(3)
await on_output_data.wait_call(10)

on_input_data.mock.assert_called_with(1)
to_output_data.mock.assert_called_with(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def test_broker_context_confluent():
from faststream.confluent import TestKafkaBroker as TestConfluentKafkaBroker

async with TestConfluentKafkaBroker(broker, with_real=True), TestApp(app):
await handle.wait_call(5)
await handle.wait_call(10)
handle.mock.assert_called_once_with("Hi!")


Expand Down

0 comments on commit 2a7a875

Please sign in to comment.