Skip to content

Commit 75745d9

Browse files
committed
copilot: 初回呼び出し時に遅延初期化するようにして。
1 parent efaea09 commit 75745d9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

template_fastapi/repositories/restaurants.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ class RestaurantRepository:
1717
"""レストランデータを管理するリポジトリクラス"""
1818

1919
def __init__(self):
20-
self.container = self._setup_cosmos_client()
20+
self._container = None
21+
22+
@property
23+
def container(self):
24+
"""コンテナを遅延初期化するプロパティ"""
25+
if self._container is None:
26+
self._container = self._setup_cosmos_client()
27+
return self._container
2128

2229
def _setup_cosmos_client(self):
2330
"""Azure Cosmos DBに接続するクライアントを設定する"""

0 commit comments

Comments
 (0)