def begin(self, effective_caller_id=None): try: request = vtgate_pb2.BeginRequest() _add_caller_id(request, effective_caller_id) response = self.stub.Begin(request, self.timeout) # we're saving effective_caller_id to re-use it for commit and rollback. self.effective_caller_id = effective_caller_id self.session = response.session except (face.AbortionError, vtgate_utils.VitessError) as e: raise _convert_exception(e)
def begin_request(self, effective_caller_id): """Builds a vtgate_pb2.BeginRequest object. Also remembers the effective caller id for next call to commit_request or rollback_request. Args: effective_caller_id: optional vtgate_client.CallerID. Returns: A vtgate_pb2.BeginRequest object. """ request = vtgate_pb2.BeginRequest() self._add_caller_id(request, effective_caller_id) self._effective_caller_id = effective_caller_id return request
def begin_request(self, effective_caller_id, single_db): """Builds a vtgate_pb2.BeginRequest object. Also remembers the effective caller id for next call to commit_request or rollback_request. Args: effective_caller_id: optional vtgate_client.CallerID. single_db: True if single db transaction is needed. Returns: A vtgate_pb2.BeginRequest object. """ request = vtgate_pb2.BeginRequest() request.single_db = single_db self._add_caller_id(request, effective_caller_id) self._effective_caller_id = effective_caller_id return request