fix(General): fix for cm-dev deployment
This commit is contained in:
@@ -491,6 +491,9 @@ class CleverThisServiceAdapter:
|
||||
_routes = self.routes.get(method, [])
|
||||
_path, _args = AMQDataParser.parse_get_url(message.path())
|
||||
for _route in _routes:
|
||||
# TODO: here the regex will match with path prefix,
|
||||
# but it might not be a stable feature that we could rely on.
|
||||
# Need to figure out something stable for the prefix path.
|
||||
_match = _route.path_regex.match(_path)
|
||||
if _match:
|
||||
_args.update(_match.groupdict())
|
||||
|
||||
@@ -125,10 +125,7 @@ class DataMessageHandler:
|
||||
"""
|
||||
# Increment the counter for parallel executions and check resource availability
|
||||
self.backpressure_handler.increase_parallel_executions()
|
||||
await self.backpressure_handler.check_resource_availability(
|
||||
self.backpressure_handler.current_parallel_executions,
|
||||
self.backpressure_handler.parallel_workers,
|
||||
)
|
||||
await self.backpressure_handler.check_overload_condition()
|
||||
logging_info(
|
||||
f"PARALLEL: Current Capacity [{self.backpressure_handler.current_parallel_executions}] of [{self.backpressure_handler.parallel_workers}]"
|
||||
)
|
||||
@@ -159,10 +156,7 @@ class DataMessageHandler:
|
||||
logging_error(f"Request handler: {e}")
|
||||
|
||||
self.backpressure_handler.decrease_parallel_executions()
|
||||
await self.backpressure_handler.check_resource_availability(
|
||||
self.backpressure_handler.current_parallel_executions,
|
||||
self.backpressure_handler.parallel_workers,
|
||||
)
|
||||
await self.backpressure_handler.check_overload_condition()
|
||||
|
||||
async def reconstitute_data_message(
|
||||
self, message: AbstractIncomingMessage
|
||||
|
||||
@@ -94,6 +94,7 @@ internal_api_call_duration_histogram = meter.create_histogram(
|
||||
app = FastAPI(
|
||||
title="CleverMicro Document Service Demo",
|
||||
description="A FastAPI application demonstrating OpenTelemetry integration with Jaeger and Prometheus.",
|
||||
# root_path="/otdemo", # This won't affect router path
|
||||
)
|
||||
|
||||
# Instrument FastAPI: Automatically creates spans for incoming requests
|
||||
@@ -105,8 +106,6 @@ HTTPXClientInstrumentor().instrument()
|
||||
UPLOAD_DIR = "/tmp/clevermicro_documents"
|
||||
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
||||
|
||||
otadapter = OTDemoAmqpAdapter(AMQConfiguration("otdemo/otdemo.properties"), app.routes)
|
||||
|
||||
|
||||
@app.post("/api/v3/documents")
|
||||
async def upload_document(
|
||||
@@ -223,6 +222,8 @@ async def get_documents():
|
||||
return {"documents": documents}
|
||||
|
||||
|
||||
# Need to place below all route methods, otherwise the routes are incomplete
|
||||
otadapter = OTDemoAmqpAdapter(AMQConfiguration("otdemo/otdemo.properties"), app.routes)
|
||||
# --- How to Run the Demo ---
|
||||
# 1. Save the code:
|
||||
# Save the Python code above as `main.py` in a new directory.
|
||||
|
||||
@@ -11,7 +11,10 @@ cm.amq-adapter.generator-id=1
|
||||
# Route mapping. For route detail description see section 3.1 in Onboarding Guide for Python:
|
||||
# https://docs.cleverthis.com/en/architecture/microservices/onboarding/python
|
||||
# NOTE: this is a comma-separated list of route mappings (multiple, comma-separated routes are allowed here)
|
||||
cm.amq-adapter.route-mapping=otdemo::otdemo:otdemo.localhost.#:5:0
|
||||
# cm-dev route
|
||||
cm.amq-adapter.route-mapping=otdemo::otdemo:api.cm.dev.cleverthis.com.test-python.#:5:0
|
||||
# local route
|
||||
#cm.amq-adapter.route-mapping=otdemo::otdemo:api.dev.localhost.otdemo.#:5:0
|
||||
# Indicate if AMQ Adapter should respond with HTTP 401 Unauthorized if the request does not contain valid JWT token
|
||||
cm.amq-adapter.require-authenticated-user=false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user