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
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ idna_ssl = {version = "*",markers = "python_version<'3.7'"}
pydantic = {extras = ["dotenv"],version = "*"}
python-dateutil = "*"
requests = "*"
scout-apm = "*"
uvicorn = "*"

[requires]
Expand Down
136 changes: 135 additions & 1 deletion Pipfile.lock

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

2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class _Settings(BaseSettings):
port: int = 5000
rediscloud_url: AnyUrl = None
local_redis_url: AnyUrl = None
# Scout APM
scout_name: str = None


@functools.lru_cache()
Expand Down
8 changes: 8 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
from scout_apm.async_.starlette import ScoutMiddleware

from .config import get_settings
from .data import data_source
Expand Down Expand Up @@ -39,6 +40,13 @@
# Middleware
#######################

# Scout APM
if SETTINGS.scout_name: # pragma: no cover
LOGGER.info(f"Adding Scout APM middleware for `{SETTINGS.scout_name}`")
APP.add_middleware(ScoutMiddleware)
else:
LOGGER.debug("No SCOUT_NAME config")

# Enable CORS.
APP.add_middleware(
CORSMiddleware, allow_credentials=True, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"],
Expand Down
2 changes: 1 addition & 1 deletion app/services/location/jhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def get(self, loc_id): # pylint: disable=arguments-differ
@cached(cache=TTLCache(maxsize=1024, ttl=1800))
async def get_category(category):
"""
Retrieves the data for the provided category. The data is cached for 1 hour.
Retrieves the data for the provided category. The data is cached for 30 minutes locally, 1 hour via shared Redis.

:returns: The data for category.
:rtype: dict
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ smmap==3.0.2
stevedore==1.32.0
toml==0.10.0
typed-ast==1.4.1
urllib3==1.25.9
urllib3[secure]==1.25.9 ; python_version >= '3.5'
wcwidth==0.1.9
wrapt==1.12.1
zipp==3.1.0
10 changes: 9 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ aiocache[redis]==0.11.1
aiofiles==0.5.0
aiohttp==3.6.2
aioredis==1.3.1
asgiref==3.2.7 ; python_version >= '3.5'
async-timeout==3.0.1
asyncache==0.1.1
attrs==19.3.0
cachetools==4.1.0
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
click==7.1.2
cryptography==2.9.2
dataclasses==0.6 ; python_version < '3.7'
fastapi==0.54.1
gunicorn==20.0.4
Expand All @@ -19,14 +22,19 @@ httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and plat
idna-ssl==1.1.0 ; python_version < '3.7'
idna==2.9
multidict==4.7.5
psutil==5.7.0
pycparser==2.20
pydantic[dotenv]==1.5.1
pyopenssl==19.1.0
python-dateutil==2.8.1
python-dotenv==0.13.0
requests==2.23.0
scout-apm==2.14.1
six==1.14.0
starlette==0.13.2
urllib3==1.25.9
urllib3[secure]==1.25.9 ; python_version >= '3.5'
uvicorn==0.11.5
uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
websockets==8.1
wrapt==1.12.1
yarl==1.4.2