Skip to content

Commit

Permalink
Merge pull request #1 from weni-ai/feature/event-driven-setup
Browse files Browse the repository at this point in the history
Install the weni-eda package and configure event-driven
  • Loading branch information
Sandro-Meireles authored Jul 25, 2024
2 parents d802147 + 4b47560 commit b17cd18
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ services:
- POSTGRES_USER=${POSTGRES_USER:-retail}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-retail}
- POSTGRES_DB=${POSTGRES_DB:-retail}
rabbitmq:
image: rabbitmq:3.9.7-management
ports:
- "5672:5672"
- "15672:15672"
environment:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest
63 changes: 62 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name = "retail-setup"
version = "0.0.1"
description = ""
authors = ["Weni"]
package-mode = false

[tool.poetry.dependencies]
python = "^3.10"
django = "^5.0.7"
django-environ = "^0.11.2"
weni-eda = "^0.0.1"
psycopg2 = "^2.9.9"


[tool.poetry.group.dev.dependencies]
Expand Down
Empty file added retail/event_driven/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions retail/event_driven/handle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import amqp


def handle_consumers(channel: amqp.Channel):
pass
15 changes: 15 additions & 0 deletions retail/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"weni.eda.django.eda_app",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -128,3 +129,17 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"


# Event Driven Architecture configurations

USE_EDA = env.bool("USE_EDA", default=False)

if USE_EDA:
EDA_CONSUMERS_HANDLE = "retail.event_driven.handle.handle_consumers"

EDA_BROKER_HOST = env("EDA_BROKER_HOST", default="localhost")
EDA_VIRTUAL_HOST = env("EDA_VIRTUAL_HOST", default="/")
EDA_BROKER_PORT = env.int("EDA_BROKER_PORT", default=5672)
EDA_BROKER_USER = env("EDA_BROKER_USER", default="guest")
EDA_BROKER_PASSWORD = env("EDA_BROKER_PASSWORD", default="guest")

0 comments on commit b17cd18

Please sign in to comment.