本文整理匯總了Golang中github.com/coreos/etcd/migrate/etcd4pb.LogEntry類的典型用法代碼示例。如果您正苦於以下問題:Golang LogEntry類的具體用法?Golang LogEntry怎麽用?Golang LogEntry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了LogEntry類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: toEntry5
func toEntry5(ent4 *etcd4pb.LogEntry, raftMap map[string]uint64) (*raftpb.Entry, error) {
cmd4, err := NewCommand4(ent4.GetCommandName(), ent4.GetCommand(), raftMap)
if err != nil {
return nil, err
}
data, err := cmd4.Data5()
if err != nil {
return nil, err
}
ent5 := raftpb.Entry{
Term: ent4.GetTerm(),
Index: ent4.GetIndex(),
Type: cmd4.Type5(),
Data: data,
}
log.Printf("%d: %s -> %s", ent5.Index, ent4.GetCommandName(), ent5.Type)
return &ent5, nil
}
示例2: DecodeNextEntry4
// DecodeNextEntry4 unmarshals a v0.4 log entry from a reader. Returns the
// number of bytes read and any error that occurs.
func DecodeNextEntry4(r io.Reader) (*etcd4pb.LogEntry, int, error) {
var length int
_, err := fmt.Fscanf(r, "%8x\n", &length)
if err != nil {
return nil, -1, err
}
data := make([]byte, length)
if _, err = io.ReadFull(r, data); err != nil {
return nil, -1, err
}
ent4 := new(etcd4pb.LogEntry)
if err = ent4.Unmarshal(data); err != nil {
return nil, -1, err
}
// add width of scanner token to length
length = length + 8 + 1
return ent4, length, nil
}
示例3: toEntry2
func toEntry2(ent4 *etcd4pb.LogEntry, raftMap map[string]uint64) (*raftpb.Entry, error) {
cmd4, err := NewCommand4(ent4.GetCommandName(), ent4.GetCommand(), raftMap)
if err != nil {
return nil, err
}
data, err := cmd4.Data2()
if err != nil {
return nil, err
}
ent2 := raftpb.Entry{
Term: ent4.GetTerm() + termOffset4to2,
Index: ent4.GetIndex(),
Type: cmd4.Type2(),
Data: data,
}
return &ent2, nil
}