本文整理匯總了Golang中github.com/influxdb/influxdb/meta/internal.Response.GetError方法的典型用法代碼示例。如果您正苦於以下問題:Golang Response.GetError方法的具體用法?Golang Response.GetError怎麽用?Golang Response.GetError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/influxdb/influxdb/meta/internal.Response
的用法示例。
在下文中一共展示了Response.GetError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: remoteExec
// remoteExec sends an encoded command to the remote leader.
func (s *Store) remoteExec(b []byte) error {
// Retrieve the current known leader.
leader := s.raft.Leader()
if leader == "" {
return errors.New("no leader")
}
// Create a connection to the leader.
conn, err := net.DialTimeout("tcp", leader, 10*time.Second)
if err != nil {
return err
}
defer conn.Close()
// Write a marker byte for exec messages.
_, err = conn.Write([]byte{MuxExecHeader})
if err != nil {
return err
}
// Write a marker message.
_, err = conn.Write([]byte(ExecMagic))
if err != nil {
return err
}
// Write command size & bytes.
if err := binary.Write(conn, binary.BigEndian, uint64(len(b))); err != nil {
return fmt.Errorf("write command size: %s", err)
} else if _, err := conn.Write(b); err != nil {
return fmt.Errorf("write command: %s", err)
}
// Read response bytes.
var sz uint64
if err := binary.Read(conn, binary.BigEndian, &sz); err != nil {
return fmt.Errorf("read response size: %s", err)
}
buf := make([]byte, sz)
if _, err := io.ReadFull(conn, buf); err != nil {
return fmt.Errorf("read response: %s", err)
}
// Unmarshal response.
var resp internal.Response
if err := proto.Unmarshal(buf, &resp); err != nil {
return fmt.Errorf("unmarshal response: %s", err)
} else if !resp.GetOK() {
return fmt.Errorf("exec failed: %s", resp.GetError())
}
// Wait for local FSM to sync to index.
if err := s.sync(resp.GetIndex(), 5*time.Second); err != nil {
return fmt.Errorf("sync: %s", err)
}
return nil
}