feat: add servicelink RPC mesh endpoint
Build and Push Docker Container / build-and-push (push) Successful in 3m21s
Build and Push Docker Container / build-and-push (push) Successful in 3m21s
- Add the servicelink submodule and register POST /rpc for node-to-node file operations. - Require bearer tokens with the mesh scope and apply rate/body-size limits to RPC calls. - Map database connectivity failures to the existing 504 database error flow, with JSON responses for API routes. - Cover the new RPC handlers and database error handling with focused pytest tests. - Bump the NanoShare package version to 1.21.0.
This commit is contained in:
@@ -13,6 +13,7 @@ from my_modules.functions import (
|
||||
)
|
||||
from quart_common.web.env import is_development_environment
|
||||
from quart_common.web.wide_event import add_wide_event_context
|
||||
import httpx
|
||||
|
||||
IGNORED_404_PATHS = [
|
||||
"/.well-known/",
|
||||
@@ -186,6 +187,11 @@ async def internal_server_error(e):
|
||||
file={'name': '500.webp', 'alt': "Astronaut jumping and clicking on random Buttons as a red alert gone off - They is a Text on the Image saying: Why don't shit Work!?!"},
|
||||
), 500
|
||||
|
||||
@app.errorhandler(httpx.HTTPError)
|
||||
@app.errorhandler(TimeoutError)
|
||||
async def database_unavailable_error(e):
|
||||
return await database_server_error(e)
|
||||
|
||||
@app.errorhandler(504)
|
||||
async def database_server_error(e):
|
||||
try:
|
||||
@@ -193,8 +199,12 @@ async def database_server_error(e):
|
||||
except LookupError as e:
|
||||
return await to_many_requests(e)
|
||||
|
||||
context = get_request_context()
|
||||
add_wide_event_context(error={"type": type(e).__name__, "message": str(e)})
|
||||
logger.error(e)
|
||||
if context.path.startswith("/api"):
|
||||
return jsonify({"error": "Database Error", "message": "The database is currently unavailable. Please try again in a moment."}), 504
|
||||
|
||||
return await render_template('views/basics/error.htm',
|
||||
title='Database Error',
|
||||
header={'title': '504 - Database Error', 'message': "It looks like something is broke on our end... but don't worry, we're fixing it! Either way, thanks for helping us find new ways to crash our system. Stay curious, hacker-friend!"},
|
||||
|
||||
Reference in New Issue
Block a user