Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create pool only once and update timvt/tifeatures version #14

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions stack/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ def __init__(
).to_string(),
}

env = {}
env["DB_MIN_CONN_SIZE"] = "1"
env["DB_MAX_CONN_SIZE"] = "1"

api_function = aws_lambda.Function(
self,
f"{id}-vector-lambda",
Expand All @@ -201,6 +205,7 @@ def __init__(
handler="handler.handler",
memory_size=api_settings.memory,
timeout=core.Duration.seconds(api_settings.timeout),
environment=env,
log_retention=logs.RetentionDays.ONE_WEEK,
)
for k, v in db_secrets.items():
Expand Down
17 changes: 12 additions & 5 deletions stack/app/handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

import os
import asyncio

from tifeatures.db import close_db_connection, connect_to_db, register_table_catalog
from tifeatures.factory import Endpoints
from timvt.factory import VectorTilerFactory
from tifeatures.factory import Endpoints as FeaturesEndpoints
# from timvt.factory import VectorTilerFactory
vincentsarago marked this conversation as resolved.
Show resolved Hide resolved
from fastapi import FastAPI
from starlette_cramjam.middleware import CompressionMiddleware

Expand All @@ -14,8 +17,8 @@
)

# Register endpoints.
endpoints = Endpoints()
app.include_router(endpoints.router, tags=["Features"])
endpoints = FeaturesEndpoints()
app.include_router(endpoints.router, tags=["OGC Features"])

# By default the VectorTilerFactory will only create tiles/ and tilejson.json endpoints
# mvt_endpoints = VectorTilerFactory()
Expand All @@ -39,4 +42,8 @@ async def shutdown_event() -> None:
await close_db_connection(app)


handler = Mangum(app)
handler = Mangum(app, lifespan="off")

if "AWS_EXECUTION_ENV" in os.environ:
loop = asyncio.get_event_loop()
loop.run_until_complete(app.router.startup())
4 changes: 2 additions & 2 deletions stack/app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
timvt @ git+https://github.com/developmentseed/timvt
tifeatures @ git+https://github.com/developmentseed/tifeatures
timvt==0.8.0a2
tifeatures==0.1.0a2

mangum>=0.10.0