Reduced default stream boundary to 5 minutes

Updated moonstreamdb requirement in backend to 0.0.3 so that it can set
statement timeouts.

Added a TODO to properly handle the statement timeout error on the
ethereum_blockchain provider.
pull/105/head
Neeraj Kashyap 2021-08-22 16:16:36 -07:00
rodzic 94135b054c
commit baa42fc36c
3 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -263,6 +263,12 @@ def get_events(
ethereum_transactions = ethereum_transactions.order_by(text("timestamp desc"))
# TODO(zomglings): Catch the operational error denoting that the statement timed out here
# and wrap it in an error that tells the API to return the appropriate 400 response. Currently,
# when the statement times out, the API returns a 500 status code to the client, which doesn't
# do anything to help them get data from teh backend.
# The error message on the API side when the statement times out:
# > sqlalchemy.exc.OperationalError: (psycopg2.errors.QueryCanceled) canceling statement due to statement timeout
events: List[data.Event] = [
ethereum_transaction_event(row) for row in ethereum_transactions
]

Wyświetl plik

@ -11,7 +11,7 @@ fastapi==0.66.0
h11==0.12.0
idna==3.2
jmespath==0.10.0
-e git+https://git@github.com/bugout-dev/moonstream.git@39d2b8e36a49958a9ae085ec2cc1be3fc732b9d0#egg=moonstreamdb&subdirectory=db
-e git+https://git@github.com/bugout-dev/moonstream.git@94135b054cabb9dc11b0a2406431619279979469#egg=moonstreamdb&subdirectory=db
mypy==0.910
mypy-extensions==0.4.3
pathspec==0.9.0

Wyświetl plik

@ -38,11 +38,10 @@ export const clientServerOffsetMillis = async () => {
return clientTime - serverTime;
};
// Returns a stream boundary representing the past 10 minutes.
// Returns a stream boundary representing the past 5 minutes.
export const defaultStreamBoundary = async () => {
const endTime = await serverTimeNow();
// 1 hour ago (in milliseconds)
const startTimeMillis = endTime - 60 * 60 * 1000;
const startTimeMillis = endTime - 5 * 60 * 1000;
const streamBoundary = {
start_time: Math.floor(startTimeMillis / 1000),
end_time: Math.floor(endTime / 1000),