Skip to content

Commit

Permalink
chore: use local redis when developing
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperHG90 committed Mar 21, 2024
1 parent 383e70d commit 0c009bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions dags/luchtmeetnet_ingestion/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.justfile
Dockerfile
tests
*.rdb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from luchtmeetnet_ingestion.luchtmeetnet.api import get_results_luchtmeetnet_endpoint
from pydantic import PrivateAttr
from pyrate_limiter import BucketFullException, Duration, Limiter, Rate, RedisBucket
from redis import Redis
from redis import ConnectionError, Redis


class RedisResource(ConfigurableResource):
Expand All @@ -32,6 +32,9 @@ def connection(self, context: InitResourceContext):
username=self.username,
)
yield conn
except ConnectionError as e:
context.log.error(f"Failed to connect to Redis backend: {e}")
raise e
finally:
conn.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
rate_minutes=5,
bucket_key=f"luchtmeetnet_api_{environment}",
redis=RedisResource(
host=EnvVar("DAGSTER_SECRET_REDIS_HOST"),
port=16564,
password=EnvVar("DAGSTER_SECRET_REDIS_PASSWORD"),
username=EnvVar("DAGSTER_SECRET_REDIS_USERNAME"),
host="localhost" if environment == "dev" else EnvVar("DAGSTER_SECRET_REDIS_HOST"),
port=6379 if environment == "dev" else 16564,
password=None if environment == "dev" else EnvVar("DAGSTER_SECRET_REDIS_PASSWORD"),
username=None if environment == "dev" else EnvVar("DAGSTER_SECRET_REDIS_USERNAME"),
),
)
),
Expand Down

0 comments on commit 0c009bf

Please sign in to comment.