11local errors = require (' errors' )
22
3+ local call_cache = require (' crud.common.call_cache' )
34local dev_checks = require (' crud.common.dev_checks' )
45local utils = require (' crud.common.utils' )
56local sharding_utils = require (' crud.common.sharding.utils' )
@@ -11,8 +12,18 @@ local BasePostprocessor = require('crud.common.map_call_cases.base_postprocessor
1112
1213local CallError = errors .new_class (' CallError' )
1314
15+ local CALL_FUNC_NAME = ' call_on_storage'
16+ local CRUD_CALL_FUNC_NAME = utils .get_storage_call (CALL_FUNC_NAME )
17+
18+
1419local call = {}
1520
21+ local function call_on_storage (run_as_user , func_name , ...)
22+ return box .session .su (run_as_user , call_cache .func_name_to_func (func_name ), ... )
23+ end
24+
25+ call .storage_api = {[CALL_FUNC_NAME ] = call_on_storage }
26+
1627function call .get_vshard_call_name (mode , prefer_replica , balance )
1728 dev_checks (' string' , ' ?boolean' , ' ?boolean' )
1829
@@ -71,11 +82,12 @@ local function wrap_vshard_err(vshard_router, err, func_name, replicaset_id, buc
7182 ))
7283end
7384
74- local function retry_call_with_master_discovery (replicaset , method , ...)
85+ local function retry_call_with_master_discovery (replicaset , method , func_name , func_args , call_opts )
86+ local func_args_ext = utils .append_array ({ box .session .effective_user (), func_name }, func_args )
87+
7588 -- In case cluster was just bootstrapped with auto master discovery,
7689 -- replicaset may miss master.
77-
78- local resp , err = replicaset [method ](replicaset , ... )
90+ local resp , err = replicaset [method ](replicaset , CRUD_CALL_FUNC_NAME , func_args_ext , call_opts )
7991
8092 if err == nil then
8193 return resp , err
@@ -87,7 +99,7 @@ local function retry_call_with_master_discovery(replicaset, method, ...)
8799
88100 -- Retry only once: should be enough for initial discovery,
89101 -- otherwise force user fix up cluster bootstrap.
90- return replicaset [method ](replicaset , ... )
102+ return replicaset [method ](replicaset , CRUD_CALL_FUNC_NAME , func_args_ext , call_opts )
91103end
92104
93105function call .map (vshard_router , func_name , func_args , opts )
0 commit comments