This file contains 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 time import sleep | |
import requests | |
UNSTABLE_API = "https://httpbin.org/status/200,500" | |
def notsodumbretry(max_attempts, retry_backoff, backoff_exponential): | |
succeeded = False | |
attempts = 0 |
This file contains 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 requests | |
UNSTABLE_API = "https://httpbin.org/status/200,500,503,401" | |
def dumbretry(): | |
succeeded = False | |
attempts = 0 | |
while not succeeded: |
This file contains 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
api_1 | [12/May/2023 17:42:32] "POST /notes HTTP/1.1" 200 80 | |
relayer_1 | note-created event published to Kafka | |
consumer_1 | {'name': 'note-created', 'note': {'id': 3, 'title': 'My Note Title', 'content': 'This is the content of my note', 'created_at': '2023-05-12 17:42:32', 'updated_at': '2023-05-12 17:42:32'}} |
This file contains 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
docker-compose run api python manage.py migrate |
This file contains 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
touch requirements.txt |
This file contains 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
docker-compose up |
This file contains 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
relayer: | |
build: . | |
command: python manage.py events_relay --run-in-loop | |
volumes: | |
- .:/app | |
env_file: | |
- .env | |
depends_on: | |
kafka: | |
condition: service_healthy |
This file contains 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 jaiminho.send import save_to_outbox | |
@save_to_outbox | |
def publish_note_created(note_dict): |
This file contains 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 migrate |
This file contains 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 jaiminho.constants import PublishStrategyType | |
JAIMINHO_CONFIG = { | |
"PUBLISH_STRATEGY": PublishStrategyType.KEEP_ORDER, | |
} |
NewerOlder