本文整理匯總了Golang中github.com/youtube/vitess/go/vt/mysqlctl/proto.ReplicationPosition.AtLeast方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReplicationPosition.AtLeast方法的具體用法?Golang ReplicationPosition.AtLeast怎麽用?Golang ReplicationPosition.AtLeast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/youtube/vitess/go/vt/mysqlctl/proto.ReplicationPosition
的用法示例。
在下文中一共展示了ReplicationPosition.AtLeast方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WaitBlpPosition
// WaitBlpPosition will wait for the filtered replication to reach at least
// the provided position.
func WaitBlpPosition(mysqld MysqlDaemon, bp *blproto.BlpPosition, waitTimeout time.Duration) error {
timeOut := time.Now().Add(waitTimeout)
for {
if time.Now().After(timeOut) {
break
}
cmd := binlogplayer.QueryBlpCheckpoint(bp.Uid)
qr, err := mysqld.FetchSuperQuery(cmd)
if err != nil {
return err
}
if len(qr.Rows) != 1 {
return fmt.Errorf("QueryBlpCheckpoint(%v) returned unexpected row count: %v", bp.Uid, len(qr.Rows))
}
var pos proto.ReplicationPosition
if !qr.Rows[0][0].IsNull() {
pos, err = proto.DecodeReplicationPosition(qr.Rows[0][0].String())
if err != nil {
return err
}
}
if pos.AtLeast(bp.Position) {
return nil
}
log.Infof("Sleeping 1 second waiting for binlog replication(%v) to catch up: %v != %v", bp.Uid, pos, bp.Position)
time.Sleep(1 * time.Second)
}
return fmt.Errorf("WaitBlpPosition(%v) timed out", bp.Uid)
}