Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:2.7

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN mkdir /app

WORKDIR /app

COPY . /app/

RUN pip install --upgrade pip

RUN pip install -r requirements-dev.txt

13 changes: 11 additions & 2 deletions django_toolkit/fallbacks/circuit_breaker/circuit_breaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ def _increase_failure_count(self):
# Between the cache.add and cache.incr, the cache MAY expire,
# which will lead to a circuit that will eventually open
self.cache.add(self.rule.failure_cache_key, 0, self.failure_timeout)
total = self.cache.incr(self.rule.failure_cache_key)
total = 0
try:
total = self.cache.incr(self.rule.failure_cache_key)
except ValueError:
logger.warning('Key {key} expired!'
.format(key=self.rule.failure_cache_key))

self.rule.log_increase_failures(
total_failures=total,
Expand All @@ -121,7 +126,11 @@ def _increase_request_count(self):
self.rule.failure_cache_key, 0, self.failure_timeout
)

self.cache.incr(self.rule.request_cache_key)
try:
self.cache.incr(self.rule.request_cache_key)
except ValueError:
logger.warning('Key {key} expired!'
.format(key=self.rule.request_cache_key))


circuit_breaker = CircuitBreaker
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'

services:
app:
build: .
volumes:
- .:/app
command: "make test"