diff --git a/py/vtctl/gorpc_vtctl_client.py b/py/vtctl/gorpc_vtctl_client.py index 21bf2120ce..2c68097add 100644 --- a/py/vtctl/gorpc_vtctl_client.py +++ b/py/vtctl/gorpc_vtctl_client.py @@ -6,8 +6,8 @@ from net import bsonrpc from vtctl import vtctl_client -class GoRpcVtctlClient(vtctl_client.VctlClient): - """GoRpcVtctlClient is the go rpc implementation of VctlClient. +class GoRpcVtctlClient(vtctl_client.VtctlClient): + """GoRpcVtctlClient is the go rpc implementation of VtctlClient. It is registered as 'gorpc' protocol. """ @@ -38,8 +38,8 @@ class GoRpcVtctlClient(vtctl_client.VctlClient): def execute_vtctl_command(self, args, action_timeout=30.0, lock_timeout=5.0): req = { 'Args': args, - 'ActionTimeout': long(action_timeout * 1000000000), - 'LockTimeout': long(lock_timeout * 1000000000), + 'ActionTimeout': long(action_timeout * 1e9), + 'LockTimeout': long(lock_timeout * 1e9), } self.client.stream_call('VtctlServer.ExecuteVtctlCommand', req) while True: diff --git a/py/vtctl/grpc_vtctl_client.py b/py/vtctl/grpc_vtctl_client.py index 545727def0..7fddbcc88e 100644 --- a/py/vtctl/grpc_vtctl_client.py +++ b/py/vtctl/grpc_vtctl_client.py @@ -13,8 +13,8 @@ import vtctl_client from vtproto import vtctldata_pb2 from vtproto import vtctlservice_pb2 -class GRPCVtctlClient(vtctl_client.VctlClient): - """GoRpcVtctlClient is the gRPC implementation of VctlClient. +class GRPCVtctlClient(vtctl_client.VtctlClient): + """GoRpcVtctlClient is the gRPC implementation of VtctlClient. It is registered as 'grpc' protocol. """ @@ -44,8 +44,8 @@ class GRPCVtctlClient(vtctl_client.VctlClient): def execute_vtctl_command(self, args, action_timeout=30.0, lock_timeout=5.0): req = vtctldata_pb2.ExecuteVtctlCommandRequest( args=args, - action_timeout=long(action_timeout * 1000000000), - lock_timeout=long(lock_timeout * 1000000000)) + action_timeout=long(action_timeout * 1e9), + lock_timeout=long(lock_timeout * 1e9)) with self.stub as stub: it = stub.ExecuteVtctlCommand(req, action_timeout) for response in it: diff --git a/py/vtctl/vtctl_client.py b/py/vtctl/vtctl_client.py index 38feac89e3..68cc8c5b0b 100644 --- a/py/vtctl/vtctl_client.py +++ b/py/vtctl/vtctl_client.py @@ -38,7 +38,7 @@ def connect(protocol, *pargs, **kargs): class Event(object): - """Event is streamed by VctlClient. + """Event is streamed by VtctlClient. Eventually, we will just use the proto3 definition for logutil.proto/Event. """ @@ -55,8 +55,8 @@ class Event(object): self.value = value -class VctlClient(object): - """VctlClient is the interface for the vtctl client implementations. +class VtctlClient(object): + """VtctlClient is the interface for the vtctl client implementations. All implementations must implement all these methods. If something goes wrong with the connection, this object will be thrown out. """ diff --git a/py/vtdb/gorpc_update_stream.py b/py/vtdb/gorpc_update_stream.py index 56680e821e..8213987df9 100644 --- a/py/vtdb/gorpc_update_stream.py +++ b/py/vtdb/gorpc_update_stream.py @@ -92,10 +92,13 @@ class GoRpcUpdateStreamConnection(update_stream.UpdateStreamConnection): row = tuple(_make_row(pk_list, conversions)) rows.append(row) - yield update_stream.StreamEvent(category, reply['TableName'], - fields, rows, reply['Sql'], - reply['Timestamp'], - reply['GTIDField']) + yield update_stream.StreamEvent(category=category, + table_name=reply['TableName'], + fields=fields, + rows=rows, + sql=reply['Sql'], + timestamp=reply['Timestamp'], + position=reply['GTIDField']) except gorpc.AppError as e: raise dbexceptions.DatabaseError(*e.args) except gorpc.GoRpcError as e: diff --git a/py/vtdb/grpc_update_stream.py b/py/vtdb/grpc_update_stream.py index 3ce44b7d2c..07a90aceb2 100644 --- a/py/vtdb/grpc_update_stream.py +++ b/py/vtdb/grpc_update_stream.py @@ -86,12 +86,13 @@ class GRPCUpdateStreamConnection(update_stream.UpdateStreamConnection): rows.append(row) try: - yield update_stream.StreamEvent(int(stream_event.category), - stream_event.table_name, - fields, rows, - stream_event.sql, - stream_event.timestamp, - stream_event.gtid) + yield update_stream.StreamEvent(category=int(stream_event.category), + table_name=stream_event.table_name, + fields=fields, + rows=rows, + sql=stream_event.sql, + timestamp=stream_event.timestamp, + position=stream_event.gtid) except GeneratorExit: # if the loop is interrupted for any reason, we need to # cancel the iterator, so we close the RPC connection, diff --git a/py/vtdb/update_stream.py b/py/vtdb/update_stream.py index 1594d36479..2130afcdb7 100644 --- a/py/vtdb/update_stream.py +++ b/py/vtdb/update_stream.py @@ -23,7 +23,7 @@ def connect(protocol, *pargs, **kargs): Args: protocol: the registered protocol to use. - arsg: passed to the registered protocol __init__ method. + args: passed to the registered protocol __init__ method. Returns: A dialed UpdateStreamConnection.