11import typing
22from typing import Optional
33
4- import ydb
54from ydb import _apis , issues
65
7- from .coordination_lock import CoordinationLock
8- from .сoordination_session import CoordinationSession
96
7+ from .operations import DescribeNodeOperation , CreateNodeOperation , DropNodeOperation
108
11- def wrapper_create_node (rpc_state , response_pb , * _args , ** _kwargs ):
12- from .._grpc .grpcwrapper .ydb_coordination import CreateNodeResponse
139
10+ if typing .TYPE_CHECKING :
11+ import ydb
12+
13+
14+ def wrapper_create_node (rpc_state , response_pb , path , * _args , ** _kwargs ):
1415 issues ._process_response (response_pb .operation )
15- return CreateNodeResponse . from_proto ( response_pb )
16+ return CreateNodeOperation ( rpc_state , response_pb , path )
1617
1718
1819def wrapper_describe_node (rpc_state , response_pb , * _args , ** _kwargs ):
19- from .._grpc .grpcwrapper .ydb_coordination import DescribeNodeResponse
20-
2120 issues ._process_response (response_pb .operation )
22- return DescribeNodeResponse .from_proto (response_pb )
23-
21+ return DescribeNodeOperation (rpc_state , response_pb )
2422
25- def wrapper_delete_node (rpc_state , response_pb , * _args , ** _kwargs ):
26- from .._grpc .grpcwrapper .ydb_coordination import DropNodeResponse
2723
24+ def wrapper_delete_node (rpc_state , response_pb , path , * _args , ** _kwargs ):
2825 issues ._process_response (response_pb .operation )
29- return DropNodeResponse . from_proto ( response_pb )
26+ return DropNodeOperation ( rpc_state , response_pb , path )
3027
3128
3229class CoordinationClient :
3330 def __init__ (self , driver : "ydb.Driver" ):
3431 self ._driver = driver
3532
36- def session (self ) -> "CoordinationSession" :
37- return CoordinationSession (self ._driver )
38-
3933 def _call_node (
4034 self ,
4135 request ,
4236 rpc_method ,
4337 wrapper_fn ,
38+ wrap_args = (),
4439 settings : Optional ["ydb.BaseRequestSettings" ] = None ,
4540 ):
4641 return self ._driver (
4742 request ,
4843 _apis .CoordinationService .Stub ,
4944 rpc_method ,
5045 wrap_result = wrapper_fn ,
51- wrap_args = () ,
46+ wrap_args = wrap_args ,
5247 settings = settings ,
5348 )
5449
@@ -58,7 +53,7 @@ def create_node(
5853 config : typing .Optional [typing .Any ] = None ,
5954 operation_params : typing .Optional [typing .Any ] = None ,
6055 settings : Optional ["ydb.BaseRequestSettings" ] = None ,
61- ) -> _apis . ydb_coordination . CreateNodeResponse :
56+ ) -> CreateNodeOperation :
6257 request = _apis .ydb_coordination .CreateNodeRequest (
6358 path = path ,
6459 config = config ,
@@ -68,15 +63,16 @@ def create_node(
6863 request ,
6964 _apis .CoordinationService .CreateNode ,
7065 wrapper_create_node ,
71- settings ,
66+ wrap_args = (path ,),
67+ settings = settings ,
7268 )
7369
7470 def describe_node (
7571 self ,
7672 path : str ,
7773 operation_params : typing .Optional [typing .Any ] = None ,
7874 settings : Optional ["ydb.BaseRequestSettings" ] = None ,
79- ) -> _apis . ydb_coordination . DescribeNodeResponse :
75+ ) -> DescribeNodeOperation :
8076 request = _apis .ydb_coordination .DescribeNodeRequest (
8177 path = path ,
8278 operation_params = operation_params ,
@@ -85,15 +81,16 @@ def describe_node(
8581 request ,
8682 _apis .CoordinationService .DescribeNode ,
8783 wrapper_describe_node ,
88- settings ,
84+ wrap_args = (path ,),
85+ settings = settings ,
8986 )
9087
9188 def delete_node (
9289 self ,
9390 path : str ,
9491 operation_params : typing .Optional [typing .Any ] = None ,
9592 settings : Optional ["ydb.BaseRequestSettings" ] = None ,
96- ) -> _apis . ydb_coordination . DropNodeResponse :
93+ ):
9794 request = _apis .ydb_coordination .DropNodeRequest (
9895 path = path ,
9996 operation_params = operation_params ,
@@ -102,13 +99,7 @@ def delete_node(
10299 request ,
103100 _apis .CoordinationService .DropNode ,
104101 wrapper_delete_node ,
105- settings ,
102+ wrap_args = (path ,),
103+ settings = settings ,
106104 )
107105
108- def lock (
109- self ,
110- path : str ,
111- timeout : int = 5000 ,
112- count : int = 1 ,
113- ) -> "CoordinationLock" :
114- return CoordinationLock (self .session (), path , timeout , count )
0 commit comments