Documentation ¶
Overview ¶
Package rpc is a generated protocol buffer package.
It is generated from these files:
cockroach/pkg/rpc/heartbeat.proto
It has these top-level messages:
RemoteOffset PingRequest PingResponse
Index ¶
- Variables
- func NewServer(ctx *Context) *grpc.Server
- func RegisterHeartbeatServer(s *grpc.Server, srv HeartbeatServer)
- type Context
- func (ctx *Context) GRPCDial(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func (ctx *Context) GetLocalInternalServerForAddr(addr string) roachpb.InternalServer
- func (ctx *Context) IsConnHealthy(remoteAddr string) bool
- func (ctx *Context) NewBreaker() *circuit.Breaker
- func (ctx *Context) SetLocalInternalServer(internalServer roachpb.InternalServer)
- type HeartbeatClient
- type HeartbeatServer
- type HeartbeatService
- type ManualHeartbeatService
- type PingRequest
- func (*PingRequest) Descriptor() ([]byte, []int)
- func (*PingRequest) GetUser() string
- func (m *PingRequest) Marshal() (dAtA []byte, err error)
- func (m *PingRequest) MarshalTo(dAtA []byte) (int, error)
- func (*PingRequest) ProtoMessage()
- func (m *PingRequest) Reset()
- func (m *PingRequest) Size() (n int)
- func (m *PingRequest) String() string
- func (m *PingRequest) Unmarshal(dAtA []byte) error
- type PingResponse
- func (*PingResponse) Descriptor() ([]byte, []int)
- func (m *PingResponse) Marshal() (dAtA []byte, err error)
- func (m *PingResponse) MarshalTo(dAtA []byte) (int, error)
- func (*PingResponse) ProtoMessage()
- func (m *PingResponse) Reset()
- func (m *PingResponse) Size() (n int)
- func (m *PingResponse) String() string
- func (m *PingResponse) Unmarshal(dAtA []byte) error
- type RemoteClockMetrics
- type RemoteClockMonitor
- type RemoteOffset
- func (*RemoteOffset) Descriptor() ([]byte, []int)
- func (m *RemoteOffset) Marshal() (dAtA []byte, err error)
- func (m *RemoteOffset) MarshalTo(dAtA []byte) (int, error)
- func (*RemoteOffset) ProtoMessage()
- func (m *RemoteOffset) Reset()
- func (m *RemoteOffset) Size() (n int)
- func (r RemoteOffset) String() string
- func (m *RemoteOffset) Unmarshal(dAtA []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthHeartbeat = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowHeartbeat = fmt.Errorf("proto: integer overflow") )
Functions ¶
func NewServer ¶
NewServer is a thin wrapper around grpc.NewServer that registers a heartbeat service.
func RegisterHeartbeatServer ¶
func RegisterHeartbeatServer(s *grpc.Server, srv HeartbeatServer)
Types ¶
type Context ¶
type Context struct { *base.Config Stopper *stop.Stopper RemoteClocks *RemoteClockMonitor HeartbeatInterval time.Duration HeartbeatTimeout time.Duration HeartbeatCB func() // For unittesting. BreakerFactory func() *circuit.Breaker // contains filtered or unexported fields }
Context contains the fields required by the rpc framework.
func NewContext ¶
func NewContext( ambient log.AmbientContext, baseCtx *base.Config, hlcClock *hlc.Clock, stopper *stop.Stopper, ) *Context
NewContext creates an rpc Context with the supplied values.
func (*Context) GRPCDial ¶
func (ctx *Context) GRPCDial(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
GRPCDial calls grpc.Dial with the options appropriate for the context.
func (*Context) GetLocalInternalServerForAddr ¶
func (ctx *Context) GetLocalInternalServerForAddr(addr string) roachpb.InternalServer
GetLocalInternalServerForAddr returns the context's internal batch server for addr, if it exists.
func (*Context) IsConnHealthy ¶
IsConnHealthy returns whether the most recent heartbeat succeeded or not. This should not be used as a definite status of a nodes health and just used to prioritized healthy nodes over unhealthy ones.
func (*Context) NewBreaker ¶
func (ctx *Context) NewBreaker() *circuit.Breaker
NewBreaker creates a new circuit breaker properly configured for RPC connections.
func (*Context) SetLocalInternalServer ¶
func (ctx *Context) SetLocalInternalServer(internalServer roachpb.InternalServer)
SetLocalInternalServer sets the context's local internal batch server.
type HeartbeatClient ¶
type HeartbeatClient interface {
Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error)
}
func NewHeartbeatClient ¶
func NewHeartbeatClient(cc *grpc.ClientConn) HeartbeatClient
type HeartbeatServer ¶
type HeartbeatServer interface {
Ping(context.Context, *PingRequest) (*PingResponse, error)
}
type HeartbeatService ¶
type HeartbeatService struct {
// contains filtered or unexported fields
}
A HeartbeatService exposes a method to echo its request params. It doubles as a way to measure the offset of the server from other nodes. It uses the clock to return the server time every heartbeat. It also keeps track of remote clocks sent to it by storing them in the remoteClockMonitor.
func (*HeartbeatService) Ping ¶
func (hs *HeartbeatService) Ping(ctx context.Context, args *PingRequest) (*PingResponse, error)
Ping echos the contents of the request to the response, and returns the server's current clock value, allowing the requester to measure its clock. The requester should also estimate its offset from this server along with the requester's address.
type ManualHeartbeatService ¶
type ManualHeartbeatService struct {
// contains filtered or unexported fields
}
A ManualHeartbeatService allows manual control of when heartbeats occur, to facilitate testing.
func (*ManualHeartbeatService) Ping ¶
func (mhs *ManualHeartbeatService) Ping( ctx context.Context, args *PingRequest, ) (*PingResponse, error)
Ping waits until the heartbeat service is ready to respond to a Heartbeat.
type PingRequest ¶
type PingRequest struct { // Echo this string with PingResponse. Ping string `protobuf:"bytes,1,opt,name=ping" json:"ping"` // The last offset the client measured with the server. Offset RemoteOffset `protobuf:"bytes,2,opt,name=offset" json:"offset"` // The address of the client. Addr string `protobuf:"bytes,3,opt,name=addr" json:"addr"` // The configured maximum clock offset (in nanoseconds) on the server. MaxOffsetNanos int64 `protobuf:"varint,4,opt,name=max_offset_nanos,json=maxOffsetNanos" json:"max_offset_nanos"` }
A PingRequest specifies the string to echo in response. Fields are exported so that they will be serialized in the rpc call.
func (*PingRequest) Descriptor ¶
func (*PingRequest) Descriptor() ([]byte, []int)
func (*PingRequest) GetUser ¶
func (*PingRequest) GetUser() string
GetUser implements security.RequestWithUser. Heartbeat messages are always sent by the node user.
func (*PingRequest) Marshal ¶
func (m *PingRequest) Marshal() (dAtA []byte, err error)
func (*PingRequest) ProtoMessage ¶
func (*PingRequest) ProtoMessage()
func (*PingRequest) Reset ¶
func (m *PingRequest) Reset()
func (*PingRequest) Size ¶
func (m *PingRequest) Size() (n int)
func (*PingRequest) String ¶
func (m *PingRequest) String() string
func (*PingRequest) Unmarshal ¶
func (m *PingRequest) Unmarshal(dAtA []byte) error
type PingResponse ¶
type PingResponse struct { // An echo of value sent with PingRequest. Pong string `protobuf:"bytes,1,opt,name=pong" json:"pong"` ServerTime int64 `protobuf:"varint,2,opt,name=server_time,json=serverTime" json:"server_time"` }
A PingResponse contains the echoed ping request string.
func (*PingResponse) Descriptor ¶
func (*PingResponse) Descriptor() ([]byte, []int)
func (*PingResponse) Marshal ¶
func (m *PingResponse) Marshal() (dAtA []byte, err error)
func (*PingResponse) ProtoMessage ¶
func (*PingResponse) ProtoMessage()
func (*PingResponse) Reset ¶
func (m *PingResponse) Reset()
func (*PingResponse) Size ¶
func (m *PingResponse) Size() (n int)
func (*PingResponse) String ¶
func (m *PingResponse) String() string
func (*PingResponse) Unmarshal ¶
func (m *PingResponse) Unmarshal(dAtA []byte) error
type RemoteClockMetrics ¶
type RemoteClockMetrics struct { ClockOffsetMeanNanos *metric.Gauge ClockOffsetStdDevNanos *metric.Gauge }
RemoteClockMetrics is the collection of metrics for the clock monitor.
type RemoteClockMonitor ¶
type RemoteClockMonitor struct {
// contains filtered or unexported fields
}
RemoteClockMonitor keeps track of the most recent measurements of remote offsets from this node to connected nodes.
func (*RemoteClockMonitor) Metrics ¶
func (r *RemoteClockMonitor) Metrics() *RemoteClockMetrics
Metrics returns the metrics struct. Useful to examine individual metrics, or to add to the registry.
func (*RemoteClockMonitor) UpdateOffset ¶
func (r *RemoteClockMonitor) UpdateOffset(addr string, offset RemoteOffset)
UpdateOffset is a thread-safe way to update the remote clock measurements.
It only updates the offset for addr if one of the following cases holds: 1. There is no prior offset for that address. 2. The old offset for addr was measured long enough ago to be considered stale. 3. The new offset's error is smaller than the old offset's error.
func (*RemoteClockMonitor) VerifyClockOffset ¶
func (r *RemoteClockMonitor) VerifyClockOffset() error
VerifyClockOffset calculates the number of nodes to which the known offset is healthy (as defined by RemoteOffset.isHealthy). It returns nil iff more than half the known offsets are healthy, and an error otherwise. A non-nil return indicates that this node's clock is unreliable, and that the node should terminate.
type RemoteOffset ¶
type RemoteOffset struct { // The estimated offset from the remote server, in nanoseconds. Offset int64 `protobuf:"varint,1,opt,name=offset" json:"offset"` // The maximum error of the measured offset, in nanoseconds. Uncertainty int64 `protobuf:"varint,2,opt,name=uncertainty" json:"uncertainty"` // Measurement time, in nanoseconds from unix epoch. MeasuredAt int64 `protobuf:"varint,3,opt,name=measured_at,json=measuredAt" json:"measured_at"` }
RemoteOffset keeps track of this client's estimate of its offset from a remote server. Uncertainty is the maximum error in the reading of this offset, so that the real offset should be in the interval [Offset - Uncertainty, Offset + Uncertainty]. If the last heartbeat timed out, Offset = 0.
Offset and Uncertainty are measured using the remote clock reading technique described in http://se.inf.tu-dresden.de/pubs/papers/SRDS1994.pdf, page 6.
func (*RemoteOffset) Descriptor ¶
func (*RemoteOffset) Descriptor() ([]byte, []int)
func (*RemoteOffset) Marshal ¶
func (m *RemoteOffset) Marshal() (dAtA []byte, err error)
func (*RemoteOffset) ProtoMessage ¶
func (*RemoteOffset) ProtoMessage()
func (*RemoteOffset) Reset ¶
func (m *RemoteOffset) Reset()
func (*RemoteOffset) Size ¶
func (m *RemoteOffset) Size() (n int)
func (RemoteOffset) String ¶
func (r RemoteOffset) String() string
String formats the RemoteOffset for human readability.
func (*RemoteOffset) Unmarshal ¶
func (m *RemoteOffset) Unmarshal(dAtA []byte) error