drpc

package module
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 3 Imported by: 102

README

package drpc

import "storj.io/drpc"

Package drpc is a light replacement for gprc.

Usage

var (
	Error         = errs.Class("drpc")
	InternalError = errs.Class("internal error")
	ProtocolError = errs.Class("protocol error")
)

These error classes represent some common errors that drpc generates.

type Conn
type Conn interface {
	// Close closes the connection.
	Close() error

	// Closed returns true if the connection is definitely closed.
	Closed() bool

	// Transport returns the transport the connection is using.
	Transport() Transport

	// Invoke issues a unary rpc to the remote. Only one Invoke or Stream may be
	// open at once.
	Invoke(ctx context.Context, rpc string, in, out Message) error

	// NewStream starts a stream with the remote. Only one Invoke or Stream may be
	// open at once.
	NewStream(ctx context.Context, rpc string) (Stream, error)
}

Conn represents a client connection to a server.

type Description
type Description interface {
	// NumMethods returns the number of methods available.
	NumMethods() int

	// Method returns the information about the nth method along with a handler
	// to invoke it. The method interface that it returns is expected to be
	// a method expression like `(*Type).HandlerName`.
	Method(n int) (rpc string, receiver Receiver, method interface{}, ok bool)
}

Description is the interface implemented by things that can be registered by a Server.

type Handler
type Handler interface {
	HandleRPC(stream Stream, rpc string) (err error)
}

Handler handles streams and rpcs dispatched to it by a Server.

type Message
type Message interface {
	Reset()
	String() string
	ProtoMessage()
}

Message is a protobuf message, just here so protobuf isn't necessary to import or be exposed in the types.

type Mux
type Mux interface {
	Register(srv interface{}, desc Description) error
}

Mux is a type that can have an implementation and a Description registered with it.

type Receiver
type Receiver = func(srv interface{}, ctx context.Context, in1, in2 interface{}) (out Message, err error)

Receiver is invoked by a server for a given rpc.

type Stream
type Stream interface {
	// Context returns the context associated with the stream. It is canceled
	// when the Stream is closed and no more messages will ever be sent or
	// received on it.
	Context() context.Context

	// MsgSend sends the Message to the remote.
	MsgSend(msg Message) error

	// MsgRecv receives a Message from the remote.
	MsgRecv(msg Message) error

	// CloseSend signals to the remote that we will no longer send any messages.
	CloseSend() error

	// Close closes the stream.
	Close() error
}

Stream is a bi-directional stream of messages to some other party.

type Transport
type Transport interface {
	io.Reader
	io.Writer
	io.Closer
}

Transport is an interface describing what is required for a drpc connection.

Documentation

Overview

Package drpc is a light replacement for gprc.

Index

Constants

This section is empty.

Variables

View Source
var (
	Error         = errs.Class("drpc")
	InternalError = errs.Class("internal error")
	ProtocolError = errs.Class("protocol error")
)

These error classes represent some common errors that drpc generates.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	// Close closes the connection.
	Close() error

	// Closed returns true if the connection is definitely closed.
	Closed() bool

	// Transport returns the transport the connection is using.
	Transport() Transport

	// Invoke issues a unary rpc to the remote. Only one Invoke or Stream may be
	// open at once.
	Invoke(ctx context.Context, rpc string, in, out Message) error

	// NewStream starts a stream with the remote. Only one Invoke or Stream may be
	// open at once.
	NewStream(ctx context.Context, rpc string) (Stream, error)
}

Conn represents a client connection to a server.

type Description

type Description interface {
	// NumMethods returns the number of methods available.
	NumMethods() int

	// Method returns the information about the nth method along with a handler
	// to invoke it. The method interface that it returns is expected to be
	// a method expression like `(*Type).HandlerName`.
	Method(n int) (rpc string, receiver Receiver, method interface{}, ok bool)
}

Description is the interface implemented by things that can be registered by a Server.

type Handler

type Handler interface {
	HandleRPC(stream Stream, rpc string) (err error)
}

Handler handles streams and rpcs dispatched to it by a Server.

type Message

type Message interface {
	Reset()
	String() string
	ProtoMessage()
}

Message is a protobuf message, just here so protobuf isn't necessary to import or be exposed in the types.

type Mux added in v0.0.10

type Mux interface {
	Register(srv interface{}, desc Description) error
}

Mux is a type that can have an implementation and a Description registered with it.

type Receiver added in v0.0.10

type Receiver = func(srv interface{}, ctx context.Context, in1, in2 interface{}) (out Message, err error)

Receiver is invoked by a server for a given rpc.

type Stream

type Stream interface {
	// Context returns the context associated with the stream. It is canceled
	// when the Stream is closed and no more messages will ever be sent or
	// received on it.
	Context() context.Context

	// MsgSend sends the Message to the remote.
	MsgSend(msg Message) error

	// MsgRecv receives a Message from the remote.
	MsgRecv(msg Message) error

	// CloseSend signals to the remote that we will no longer send any messages.
	CloseSend() error

	// Close closes the stream.
	Close() error
}

Stream is a bi-directional stream of messages to some other party.

type Transport

type Transport interface {
	io.Reader
	io.Writer
	io.Closer
}

Transport is an interface describing what is required for a drpc connection.

Directories

Path Synopsis
cmd
Package drpccache implements per stream cache for drpc.
Package drpccache implements per stream cache for drpc.
Package drpcconn creates a drpc client connection from a transport.
Package drpcconn creates a drpc client connection from a transport.
Package drpcctx has helpers to interact with context.Context.
Package drpcctx has helpers to interact with context.Context.
Package drpcdebug provides helpers for debugging.
Package drpcdebug provides helpers for debugging.
Package drpcerr lets one associate error codes with errors.
Package drpcerr lets one associate error codes with errors.
Package drpcmanager reads packets from a transport to make streams.
Package drpcmanager reads packets from a transport to make streams.
Package drpcmetadata define the structure of the metadata supported by drpc library.
Package drpcmetadata define the structure of the metadata supported by drpc library.
invoke
Package invoke defines the proto messages exposed by drpc for sending metadata across the wire.
Package invoke defines the proto messages exposed by drpc for sending metadata across the wire.
Package drpcmux is a handler to dispatch rpcs to implementations.
Package drpcmux is a handler to dispatch rpcs to implementations.
Package drpcserver allows one to execute registered rpcs.
Package drpcserver allows one to execute registered rpcs.
Package drpcsignal holds a helper type to signal errors.
Package drpcsignal holds a helper type to signal errors.
Package drpcstream sends protobufs using the dprc wire protocol.
Package drpcstream sends protobufs using the dprc wire protocol.
Package drpcwire provides low level helpers for the drpc wire protocol.
Package drpcwire provides low level helpers for the drpc wire protocol.
examples
drpc Module
drpc_and_http Module
grpc Module
grpc_and_drpc Module
opentelemetry Module
internal
fuzz-drpcwire
Package fuzz is used to fuzz drpcwire frame parsing.
Package fuzz is used to fuzz drpcwire frame parsing.
integration
Package integration holds integration tests for drpc.
Package integration holds integration tests for drpc.
backcompat Module
grpccompat Module
twirpcompat Module

Jump to

Keyboard shortcuts

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