11"""Generated AsyncAPI application."""
2+
23from __future__ import annotations
34
45from typing import Any
@@ -7,52 +8,69 @@ from asyncapi_python.kernel.wire import AbstractWireFactory
78from asyncapi_python.kernel.codec import CodecFactory
89from asyncapi_python.contrib.codec.registry import CodecRegistry
910from asyncapi_python.kernel.endpoint import AbstractEndpoint
11+ from asyncapi_python.kernel.endpoint.abc import EndpointParams
1012
1113from .router import ProducerRouter, ConsumerRouter
1214import sys
1315
1416
1517class 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)
0 commit comments