forked from cockroachdb/cockroach
/
rpc.go
39 lines (34 loc) · 1014 Bytes
/
rpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package rpc
import (
"crypto/tls"
"github.com/cockroachdb/cockroach/util"
"github.com/cockroachdb/cockroach/util/hlc"
)
// Context contains the fields required by the rpc framework.
type Context struct {
localClock *hlc.Clock
tlsConfig *tls.Config
stopper *util.Stopper
RemoteClocks *RemoteClockMonitor
DisableCache bool // Disable client cache when calling NewClient()
}
// NewContext creates an rpc Context with the supplied values.
func NewContext(clock *hlc.Clock, config *tls.Config, stopper *util.Stopper) *Context {
return &Context{
localClock: clock,
tlsConfig: config,
stopper: stopper,
RemoteClocks: newRemoteClockMonitor(clock),
}
}
// Copy creates a copy of the rpc Context config values, but with a
// new remote clock monitor.
func (c *Context) Copy() *Context {
return &Context{
localClock: c.localClock,
tlsConfig: c.tlsConfig,
stopper: c.stopper,
RemoteClocks: newRemoteClockMonitor(c.localClock),
DisableCache: c.DisableCache,
}
}