本文整理汇总了Golang中github.com/youtube/vitess/go/vt/topo.SrvTopoServer.GetEndPoints方法的典型用法代码示例。如果您正苦于以下问题:Golang SrvTopoServer.GetEndPoints方法的具体用法?Golang SrvTopoServer.GetEndPoints怎么用?Golang SrvTopoServer.GetEndPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/topo.SrvTopoServer
的用法示例。
在下文中一共展示了SrvTopoServer.GetEndPoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewShardConn
// NewShardConn creates a new ShardConn. It creates a Balancer using
// serv, cell, keyspace, tabletType and retryDelay. retryCount is the max
// number of retries before a ShardConn returns an error on an operation.
func NewShardConn(ctx context.Context, serv topo.SrvTopoServer, cell, keyspace, shard string, tabletType topodatapb.TabletType, retryDelay time.Duration, retryCount int, connTimeoutTotal, connTimeoutPerConn, connLife time.Duration, tabletConnectTimings *stats.MultiTimings) *ShardConn {
getAddresses := func() (*topodatapb.EndPoints, error) {
endpoints, _, err := serv.GetEndPoints(ctx, cell, keyspace, shard, tabletType)
if err != nil {
return nil, vterrors.NewVitessError(
vtrpcpb.ErrorCode_INTERNAL_ERROR, err,
"endpoints fetch error: %v", err,
)
}
return endpoints, nil
}
blc := NewBalancer(getAddresses, retryDelay)
var ticker *timer.RandTicker
if tabletType != topodatapb.TabletType_MASTER {
ticker = timer.NewRandTicker(connLife, connLife/2)
}
sdc := &ShardConn{
keyspace: keyspace,
shard: shard,
tabletType: tabletType,
retryDelay: retryDelay,
retryCount: retryCount,
connTimeoutTotal: connTimeoutTotal,
connTimeoutPerConn: connTimeoutPerConn,
connLife: connLife,
balancer: blc,
ticker: ticker,
consolidator: sync2.NewConsolidator(),
connectTimings: tabletConnectTimings,
}
if ticker != nil {
go func() {
for range ticker.C {
sdc.closeCurrent()
}
}()
}
return sdc
}