rclone/vendor/storj.io/drpc
2020-05-12 15:56:50 +00:00
..
drpcconn Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcctx Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcdebug Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcerr Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcmanager Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcmetadata Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcmux Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcsignal Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcstream Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpcwire Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
.gitignore Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
.golangci.yml Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
doc.go Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
Dockerfile.jenkins Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
drpc.go Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
go.mod Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
go.sum Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
Jenkinsfile Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
LICENSE Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
Makefile Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
README.md Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00
staticcheck.conf Tardigrade Backend: Dependencies 2020-05-12 15:56:50 +00:00

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

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