This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KAFKA_HOST=kafka:9092 | |
PYTHONUNBUFFERED=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
KAFKA_HOST = os.environ.get("KAFKA_HOST") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from kafka import KafkaConsumer | |
from outboxexample import settings | |
print("starting consumer", settings.KAFKA_HOST) | |
NOTES_TOPIC = "notes" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
networks: | |
my_network: | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:latest | |
hostname: zookeeper | |
environment: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python manage.py makemigrations | |
python manage.py migrate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from django.db import models | |
from django.utils import timezone | |
class Note(models.Model): | |
id = models.AutoField(primary_key=True) | |
title = models.CharField(max_length=255) | |
content = models.TextField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.10-slim-buster | |
WORKDIR /app | |
COPY requirements.txt . | |
RUN pip install -r requirements.txt | |
COPY . /app | |
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
django==4.2 | |
django-jaiminho==1.1.1 | |
kafka-python==2.0 | |
black==23.3 | |
pytest-django==4.5.2 | |
pytest==7.3.1 | |
pytest-mock==3.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir django-jaiminho-outbox-example | |
cd django-jaiminho-outbox-example | |
pip install django==4.2 | |
django-admin startproject outboxexample . | |
python manage.py startapp notes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from django.db import connection | |
connection.force_debug_cursor = True | |
l = logging.getLogger('django.db.backends') | |
l.setLevel(logging.DEBUG) | |
l.addHandler(logging.StreamHandler()) | |
my_model = MyModel.objects.get() |