本文整理汇总了Golang中github.com/cockroachdb/cockroach/rpc.Context.Copy方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Copy方法的具体用法?Golang Context.Copy怎么用?Golang Context.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/rpc.Context
的用法示例。
在下文中一共展示了Context.Copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
// New creates an instance of a gossip node.
func New(rpcContext *rpc.Context, resolvers []resolver.Resolver, stopper *stop.Stopper) *Gossip {
g := &Gossip{
Connected: make(chan struct{}),
server: newServer(stopper),
outgoing: makeNodeSet(minPeers),
bootstrapping: map[string]struct{}{},
clients: []*client{},
disconnected: make(chan *client, 10),
stalled: make(chan struct{}, 1),
stallInterval: defaultStallInterval,
bootstrapInterval: defaultBootstrapInterval,
cullInterval: defaultCullInterval,
nodeDescs: map[roachpb.NodeID]*roachpb.NodeDescriptor{},
}
g.SetResolvers(resolvers)
// The gossip RPC context doesn't measure clock offsets, isn't
// shared with the other RPC clients which the node may be using,
// and disables reconnects to make it possible to know for certain
// which other nodes in the cluster are incoming via gossip.
if rpcContext != nil {
g.rpcContext = rpcContext.Copy()
g.rpcContext.DisableCache = true
g.rpcContext.DisableReconnects = true
g.rpcContext.RemoteClocks = nil
}
// Add ourselves as a SystemConfig watcher.
g.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
// Add ourselves as a node descriptor watcher.
g.is.registerCallback(MakePrefixPattern(KeyNodeIDPrefix), g.updateNodeAddress)
return g
}
示例2: New
// New creates an instance of a gossip node.
func New(rpcContext *rpc.Context, gossipInterval time.Duration, resolvers []resolver.Resolver) *Gossip {
g := &Gossip{
Connected: make(chan struct{}),
RPCContext: rpcContext,
server: newServer(gossipInterval),
outgoing: makeNodeSet(MaxPeers),
bootstrapping: map[string]struct{}{},
clients: []*client{},
disconnected: make(chan *client, MaxPeers),
stalled: make(chan struct{}, 1),
resolvers: resolvers,
}
// Create the bootstrapping RPC context. This context doesn't
// measure clock offsets and doesn't cache clients because bootstrap
// connections may go through a load balancer.
if rpcContext != nil {
g.bsRPCContext = rpcContext.Copy()
g.bsRPCContext.DisableCache = true
g.bsRPCContext.RemoteClocks = nil
}
// Add ourselves as a SystemConfig watcher.
g.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
return g
}
示例3: New
// New creates an instance of a gossip node.
func New(rpcContext *rpc.Context, resolvers []resolver.Resolver) *Gossip {
g := &Gossip{
Connected: make(chan struct{}),
server: newServer(),
outgoing: makeNodeSet(1),
bootstrapping: map[string]struct{}{},
clients: []*client{},
disconnected: make(chan *client, 10),
stalled: make(chan struct{}, 1),
resolverIdx: len(resolvers) - 1,
resolvers: resolvers,
}
// The gossip RPC context doesn't measure clock offsets, isn't
// shared with the other RPC clients which the node may be using,
// and disables reconnects to make it possible to know for certain
// which other nodes in the cluster are incoming via gossip.
if rpcContext != nil {
g.rpcContext = rpcContext.Copy()
g.rpcContext.DisableCache = true
g.rpcContext.DisableReconnects = true
g.rpcContext.RemoteClocks = nil
}
// Add ourselves as a SystemConfig watcher.
g.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
return g
}