rpc

package
v0.0.0-...-6d60fb6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package rpc is a generated protocol buffer package.

It is generated from these files:

cockroach/rpc/heartbeat.proto

It has these top-level messages:

RemoteOffset
PingRequest
PingResponse

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthHeartbeat = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowHeartbeat   = fmt.Errorf("proto: integer overflow")
)

Functions

func NewServer

func NewServer(ctx *Context) *grpc.Server

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.Context

	Stopper      *stop.Stopper
	RemoteClocks *RemoteClockMonitor

	HeartbeatInterval time.Duration
	HeartbeatTimeout  time.Duration
	HeartbeatCB       func()
	// contains filtered or unexported fields
}

Context contains the fields required by the rpc framework.

func NewContext

func NewContext(baseCtx *base.Context, clock *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) 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

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"`
}

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) MarshalTo

func (m *PingRequest) MarshalTo(data []byte) (int, 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) MarshalTo

func (m *PingResponse) MarshalTo(data []byte) (int, 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 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) Registry

func (r *RemoteClockMonitor) Registry() *metric.Registry

Registry returns a registry with the metrics tracked by this server, which can be used to access its stats or be added to another 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) MarshalTo

func (m *RemoteOffset) MarshalTo(data []byte) (int, 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL