Skip to content

Instantly share code, notes, and snippets.

View antunesleo's full-sized avatar

Leonardo Antunes antunesleo

View GitHub Profile
KAFKA_HOST=kafka:9092
PYTHONUNBUFFERED=1
import os
KAFKA_HOST = os.environ.get("KAFKA_HOST")
import json
from kafka import KafkaConsumer
from outboxexample import settings
print("starting consumer", settings.KAFKA_HOST)
NOTES_TOPIC = "notes"
version: '3.7'
networks:
my_network:
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
hostname: zookeeper
environment:
python manage.py makemigrations
python manage.py migrate
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()
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"]
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
@antunesleo
antunesleo / jaiminho-tutorial-start-project.sh
Last active May 12, 2023 16:45
jaiminho-tutorial-start-project.sh
mkdir django-jaiminho-outbox-example
cd django-jaiminho-outbox-example
pip install django==4.2
django-admin startproject outboxexample .
python manage.py startapp notes
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()