Skip to content

Commit 8769a84

Browse files
authored
Incorrect reply routing (#27)
* Fix incorrect dynamic reply queue routing * Update lockfile * Fix pyright * Update resolver logic * Move service_name to Application from wire * Drop service name param from amqp wire * Move service name to endpoint params * Add default timeout * Update version * Add endpoint_params to application
1 parent b65587f commit 8769a84

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "asyncapi-python"
3-
version = "0.3.0rc3"
3+
version = "0.3.0rc4"
44
license = { text = "Apache-2.0" }
55
description = "Easily generate type-safe and async Python applications from AsyncAPI 3 specifications."
66
authors = [{ name = "Yaroslav Petrov", email = "[email protected]" }]
Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generated AsyncAPI application."""
2+
23
from __future__ import annotations
34

45
from typing import Any
@@ -7,52 +8,69 @@ from asyncapi_python.kernel.wire import AbstractWireFactory
78
from asyncapi_python.kernel.codec import CodecFactory
89
from asyncapi_python.contrib.codec.registry import CodecRegistry
910
from asyncapi_python.kernel.endpoint import AbstractEndpoint
11+
from asyncapi_python.kernel.endpoint.abc import EndpointParams
1012

1113
from .router import ProducerRouter, ConsumerRouter
1214
import sys
1315

1416

1517
class Application(BaseApplication):
1618
"""{{ app_title }} - {{ app_description }}
17-
19+
1820
AsyncAPI Version: {{ asyncapi_version }}
1921
Application Version: {{ app_version }}
2022
"""
21-
22-
def __init__(self, wire_factory: AbstractWireFactory[Any, Any]):
23+
24+
def __init__(
25+
self,
26+
wire_factory: AbstractWireFactory[Any, Any],
27+
*,
28+
endpoint_params: EndpointParams | None = None,
29+
):
2330
"""Initialize the AsyncAPI application.
24-
31+
2532
Args:
2633
wire_factory: Wire protocol factory for message transport
34+
endpoint_params: Optional endpoint configuration (service_name, default_rpc_timeout, etc.)
2735
"""
2836
# Use CodecRegistry with current module for message serialization
29-
current_module = sys.modules[self.__module__.rsplit('.', 1)[0]]
37+
current_module = sys.modules[self.__module__.rsplit(".", 1)[0]]
3038
codec_factory = CodecRegistry(current_module)
31-
32-
super().__init__(wire_factory=wire_factory, codec_factory=codec_factory)
33-
39+
40+
# Pass endpoint_params to BaseApplication if provided
41+
if endpoint_params is not None:
42+
super().__init__(
43+
wire_factory=wire_factory,
44+
codec_factory=codec_factory,
45+
endpoint_params=endpoint_params,
46+
)
47+
else:
48+
super().__init__(wire_factory=wire_factory, codec_factory=codec_factory)
49+
3450
# Initialize semantic routers with factories
3551
self.producer = ProducerRouter(wire_factory, codec_factory)
3652
self.consumer = ConsumerRouter(wire_factory, codec_factory)
37-
53+
3854
# Register all endpoints from routers
3955
self._register_router_endpoints(self.producer)
4056
self._register_router_endpoints(self.consumer)
41-
57+
4258
def _register_router_endpoints(self, router: object) -> None:
4359
"""Recursively register all endpoints from router tree.
44-
60+
4561
Args:
4662
router: Router object to scan for endpoints
4763
"""
4864
if isinstance(router, AbstractEndpoint):
4965
# This router is an endpoint - register it directly
5066
self._add_endpoint(router)
51-
elif hasattr(router, '__dict__'):
67+
elif hasattr(router, "__dict__"):
5268
# This router aggregates others - recurse through attributes
5369
for attr_name in dir(router):
54-
if not attr_name.startswith('_'):
70+
if not attr_name.startswith("_"):
5571
attr = getattr(router, attr_name, None)
5672
# Check if it's a router-like object (has __dict__ or is an endpoint)
57-
if attr is not None and (isinstance(attr, AbstractEndpoint) or hasattr(attr, '__dict__')):
58-
self._register_router_endpoints(attr)
73+
if attr is not None and (
74+
isinstance(attr, AbstractEndpoint) or hasattr(attr, "__dict__")
75+
):
76+
self._register_router_endpoints(attr)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)