本文整理匯總了Golang中github.com/coreos/etcd/raft/raftpb.Snapshot.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Snapshot.String方法的具體用法?Golang Snapshot.String怎麽用?Golang Snapshot.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/etcd/raft/raftpb.Snapshot
的用法示例。
在下文中一共展示了Snapshot.String方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: saveToStorage
// HardState contains term, vote and commit.
// Snapshot contains data and snapshot metadata.
func (n *node) saveToStorage(hardState raftpb.HardState,
entries []raftpb.Entry, snapshot raftpb.Snapshot) {
if !raft.IsEmptySnap(snapshot) {
fmt.Printf("saveToStorage snapshot: %v\n", snapshot.String())
le, err := n.store.LastIndex()
if err != nil {
log.Fatalf("While retrieving last index: %v\n", err)
}
te, err := n.store.Term(le)
if err != nil {
log.Fatalf("While retrieving term: %v\n", err)
}
fmt.Printf("%d node Term for le: %v is %v\n", n.id, le, te)
if snapshot.Metadata.Index <= le {
fmt.Printf("%d node ignoring snapshot. Last index: %v\n", n.id, le)
return
}
if err := n.store.ApplySnapshot(snapshot); err != nil {
log.Fatalf("Applying snapshot: %v", err)
}
}
if !raft.IsEmptyHardState(hardState) {
n.store.SetHardState(hardState)
}
n.store.Append(entries)
}