本文整理匯總了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
}