cockroach: github.com/abhinavdahiya/cockroach/rpc Index | Files

package rpc

import "github.com/abhinavdahiya/cockroach/rpc"

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

Package Files

clock_offset.go context.go heartbeat.go heartbeat.pb.go

Variables

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

func NewServer Uses

func NewServer(ctx *Context) *grpc.Server

NewServer is a thin wrapper around grpc.NewServer that registers a heartbeat service.

func RegisterHeartbeatServer Uses

func RegisterHeartbeatServer(s *grpc.Server, srv HeartbeatServer)

type Context Uses

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 Uses

func NewContext(baseCtx *base.Context, clock *hlc.Clock, stopper *stop.Stopper) *Context

NewContext creates an rpc Context with the supplied values.

func (*Context) GRPCDial Uses

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 Uses

func (ctx *Context) GetLocalInternalServerForAddr(addr string) roachpb.InternalServer

GetLocalInternalServerForAddr returns the context's internal batch server for addr, if it exists.

func (*Context) IsConnHealthy Uses

func (ctx *Context) IsConnHealthy(remoteAddr string) bool

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) SetLocalInternalServer Uses

func (ctx *Context) SetLocalInternalServer(internalServer roachpb.InternalServer)

SetLocalInternalServer sets the context's local internal batch server.

type HeartbeatClient Uses

type HeartbeatClient interface {
    Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error)
}

func NewHeartbeatClient Uses

func NewHeartbeatClient(cc *grpc.ClientConn) HeartbeatClient

type HeartbeatServer Uses

type HeartbeatServer interface {
    Ping(context.Context, *PingRequest) (*PingResponse, error)
}

type HeartbeatService Uses

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 Uses

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 Uses

type ManualHeartbeatService struct {
    // contains filtered or unexported fields
}

A ManualHeartbeatService allows manual control of when heartbeats occur, to facilitate testing.

func (*ManualHeartbeatService) Ping Uses

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 Uses

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 Uses

func (*PingRequest) Descriptor() ([]byte, []int)

func (*PingRequest) GetUser Uses

func (*PingRequest) GetUser() string

GetUser implements security.RequestWithUser. Heartbeat messages are always sent by the node user.

func (*PingRequest) Marshal Uses

func (m *PingRequest) Marshal() (data []byte, err error)

func (*PingRequest) MarshalTo Uses

func (m *PingRequest) MarshalTo(data []byte) (int, error)

func (*PingRequest) ProtoMessage Uses

func (*PingRequest) ProtoMessage()

func (*PingRequest) Reset Uses

func (m *PingRequest) Reset()

func (*PingRequest) Size Uses

func (m *PingRequest) Size() (n int)

func (*PingRequest) String Uses

func (m *PingRequest) String() string

func (*PingRequest) Unmarshal Uses

func (m *PingRequest) Unmarshal(data []byte) error

type PingResponse Uses

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 Uses

func (*PingResponse) Descriptor() ([]byte, []int)

func (*PingResponse) Marshal Uses

func (m *PingResponse) Marshal() (data []byte, err error)

func (*PingResponse) MarshalTo Uses

func (m *PingResponse) MarshalTo(data []byte) (int, error)

func (*PingResponse) ProtoMessage Uses

func (*PingResponse) ProtoMessage()

func (*PingResponse) Reset Uses

func (m *PingResponse) Reset()

func (*PingResponse) Size Uses

func (m *PingResponse) Size() (n int)

func (*PingResponse) String Uses

func (m *PingResponse) String() string

func (*PingResponse) Unmarshal Uses

func (m *PingResponse) Unmarshal(data []byte) error

type RemoteClockMonitor Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (*RemoteOffset) Descriptor() ([]byte, []int)

func (*RemoteOffset) Marshal Uses

func (m *RemoteOffset) Marshal() (data []byte, err error)

func (*RemoteOffset) MarshalTo Uses

func (m *RemoteOffset) MarshalTo(data []byte) (int, error)

func (*RemoteOffset) ProtoMessage Uses

func (*RemoteOffset) ProtoMessage()

func (*RemoteOffset) Reset Uses

func (m *RemoteOffset) Reset()

func (*RemoteOffset) Size Uses

func (m *RemoteOffset) Size() (n int)

func (RemoteOffset) String Uses

func (r RemoteOffset) String() string

String formats the RemoteOffset for human readability.

func (*RemoteOffset) Unmarshal Uses

func (m *RemoteOffset) Unmarshal(data []byte) error

Package rpc imports 20 packages (graph). Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).