本文整理匯總了Golang中github.com/youtube/vitess/go/vt/tabletmanager/actionnode.ActionNode.ToJson方法的典型用法代碼示例。如果您正苦於以下問題:Golang ActionNode.ToJson方法的具體用法?Golang ActionNode.ToJson怎麽用?Golang ActionNode.ToJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/youtube/vitess/go/vt/tabletmanager/actionnode.ActionNode
的用法示例。
在下文中一共展示了ActionNode.ToJson方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: StoreActionResponse
// Write the result of an action into topology server
func StoreActionResponse(ts topo.Server, actionNode *actionnode.ActionNode, actionPath string, actionErr error) error {
// change our state
if actionErr != nil {
// on failure, set an error field on the node
actionNode.Error = actionErr.Error()
actionNode.State = actionnode.ACTION_STATE_FAILED
} else {
actionNode.Error = ""
actionNode.State = actionnode.ACTION_STATE_DONE
}
actionNode.Pid = 0
// Write the data first to our action node, then to the log.
// In the error case, this node will be left behind to debug.
data := actionNode.ToJson()
return ts.StoreTabletActionResponse(actionPath, data)
}
示例2: unlockShard
func (wr *Wrangler) unlockShard(keyspace, shard string, actionNode *actionnode.ActionNode, lockPath string, actionError error) error {
// first update the actionNode
if actionError != nil {
log.Infof("Unlocking shard %v/%v for action %v with error %v", keyspace, shard, actionNode.Action, actionError)
actionNode.Error = actionError.Error()
actionNode.State = actionnode.ACTION_STATE_FAILED
} else {
log.Infof("Unlocking shard %v/%v for successful action %v", keyspace, shard, actionNode.Action)
actionNode.Error = ""
actionNode.State = actionnode.ACTION_STATE_DONE
}
err := wr.ts.UnlockShardForAction(keyspace, shard, lockPath, actionNode.ToJson())
if actionError != nil {
if err != nil {
// this will be masked
log.Warningf("UnlockShardForAction failed: %v", err)
}
return actionError
}
return err
}
示例3: lockShard
func (wr *Wrangler) lockShard(keyspace, shard string, actionNode *actionnode.ActionNode) (lockPath string, err error) {
log.Infof("Locking shard %v/%v for action %v", keyspace, shard, actionNode.Action)
return wr.ts.LockShardForAction(keyspace, shard, actionNode.ToJson(), wr.lockTimeout, interrupted)
}