示例#1
0
    def __str__(self):
        return "<GoRpcVtctlClient %s>" % self.addr

    def dial(self):
        if self.connected:
            self.client.close()

        self.client.dial()
        self.connected = True

    def close(self):
        self.connected = False
        self.client.close()

    def is_closed(self):
        return self.client.is_closed()

    def execute_vtctl_command(self, args, action_timeout=30.0):
        req = {"Args": args, "ActionTimeout": long(action_timeout * 1e9)}
        self.client.stream_call("VtctlServer.ExecuteVtctlCommand", req)
        while True:
            e = self.client.stream_next()
            if e is None:
                break
            t = datetime.datetime.utcfromtimestamp(e.reply["Time"]["Seconds"])
            yield vtctl_client.Event(t, e.reply["Level"], e.reply["File"], e.reply["Line"], e.reply["Value"])


# Register the gorpc vtctl client.
vtctl_client.register_conn_class("gorpc", GoRpcVtctlClient)
示例#2
0
def init():
  vtctl_client.register_conn_class('gorpc', gorpc_vtctl_client.GoRpcVtctlClient)
示例#3
0
    if self.connected:
      self.client.close()

    self.client.dial()
    self.connected = True

  def close(self):
    self.connected = False
    self.client.close()

  def is_closed(self):
    return self.client.is_closed()

  def execute_vtctl_command(self, args, action_timeout=30.0):
    req = {
        'Args': args,
        'ActionTimeout': long(action_timeout * 1e9),
    }
    self.client.stream_call('VtctlServer.ExecuteVtctlCommand', req)
    while True:
      e = self.client.stream_next()
      if e is None:
        break
      t = datetime.datetime.utcfromtimestamp(e.reply['Time']['Seconds'])
      yield vtctl_client.Event(t, e.reply['Level'], e.reply['File'],
                               e.reply['Line'], e.reply['Value'])


# Register the gorpc vtctl client.
vtctl_client.register_conn_class('gorpc', GoRpcVtctlClient)
示例#4
0
def init():
  vtctl_client.register_conn_class(
      'gorpc', gorpc_vtctl_client.GoRpcVtctlClient)