ese774_frame.routers package

Submodules

ese774_frame.routers.device_router module

FastAPI 用 DeviceRouter

実際にハンドラーメソッドが動くところ

  • api_spec に従ってルートを動的生成

  • device のメソッド/プロパティを透過的に公開

  • args/kwargs の抽出と adapter の pack/unpack を一括処理

設計思想:
  • Router は「透過プロキシ」である

  • FastAPI/Pydantic は入出力契約の検証のみを担当

  • 実処理ロジックは device_instance 側に存在

  • API名とメンバ名は 1:1 対応させる

Kengo NAKADA: https://github.com/shimane-dev, https://github.com/kengo-nakada kengo.nakada@mat.shimane-u.ac.jp, kengo.nakada@gmail.com

class ese774_frame.routers.device_router.DeviceRouter(device_instance: Any, api_spec=None, logger: Any | None = None, log_level: str | None = None, object_name: str | None = None, dispatch_exclude: List[str] | None = None)[ソース]

ベースクラス: object

device_instance + api_spec から FastAPI ルートを生成する。

責務: - request_model に基づく入力受理 - API名から device/router メンバ解決 - 実呼び出し時の args/kwargs 展開 - response_model 契約に沿った返却形への整形 - __dispatch__ 汎用エンドポイント提供

本クラスは「透過型プロキシ」として振る舞い、 device_instance の API を HTTP レイヤーに公開する。

ese774_frame.routers.make_pyi_device_router module

Kengo NAKADA: https://github.com/shimane-dev, https://github.com/kengo-nakada kengo.nakada@mat.shimane-u.ac.jp, kengo.nakada@gmail.com

PYIスタブファイル自動生成(Router用)

ese774_frame.routers.make_pyi_device_router.as_one_line_comment(val)[ソース]
ese774_frame.routers.make_pyi_device_router.make_pyi_device_router(filename: str, api_spec, class_name='DeviceRouter')[ソース]

DeviceRouter 実装に対応する .pyi を生成する。

方針: - api_spec から request_model 型を抽出 - 実装の手動メソッド(_extract_args_kwargs, _wrap_response など)を明示 - APIごとの async メソッドシグネチャを出力