1
- from functools import lru_cache
2
-
3
- from service .dal .dynamo_dal_handler import DynamoDalHandler
1
+ from service .dal .db_handler import DalHandler
2
+ from service .dal .dynamo_dal_handler import get_dal_handler
4
3
from service .dal .schemas .db import OrderEntry
5
4
from service .handlers .schemas .dynamic_configuration import FeatureFlagsNames
6
5
from service .handlers .utils .dynamic_configuration import get_dynamic_configuration_store
7
6
from service .handlers .utils .observability import logger , tracer
8
7
from service .schemas .output import CreateOrderOutput
9
8
10
9
11
- @lru_cache
12
- def get_dynamodb_dal_handler (table_name : str ) -> DynamoDalHandler :
13
- return DynamoDalHandler (table_name )
14
-
15
-
16
10
@tracer .capture_method (capture_response = False )
17
11
def handle_create_request (customer_name : str , order_item_count : int , table_name : str ) -> CreateOrderOutput :
18
12
logger .info ('starting to handle create request' , extra = {'order_item_count' : order_item_count , 'customer_name' : customer_name })
@@ -31,7 +25,7 @@ def handle_create_request(customer_name: str, order_item_count: int, table_name:
31
25
default = False ,
32
26
)
33
27
logger .debug ('premium feature flag value' , extra = {'premium' : premium })
34
- dal_handler : DynamoDalHandler = get_dynamodb_dal_handler (table_name )
28
+ dal_handler : DalHandler = get_dal_handler (table_name )
35
29
order : OrderEntry = dal_handler .create_order_in_db (customer_name , order_item_count )
36
30
# convert from db entry to output, they won't always be the same
37
31
return CreateOrderOutput (customer_name = order .customer_name , order_item_count = order .order_item_count , order_id = order .order_id )
0 commit comments