jsonrpc

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package jsonrpc provides methods for encapsulating JSON-RPC inside gRPC. This is useful for adding additional security to JSON-RPC APIs and multiplexing gRPC and JSON-RPC on the same port.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(ctx context.Context, logger *zap.Logger, dst, src RPCStream) error

Copy bidirectionally copies messages between src and dst until either src or dst returns an error. Or until the context is canceled.

Types

type JSONStream

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

JSONStream is a bidirectional stream of JSON-RPC messages.

func FromConnection

func FromConnection(conn io.ReadWriteCloser) *JSONStream

FromConnection creates a JSON-RPC stream from a net.Conn connection.

func FromUnixDomainSocket

func FromUnixDomainSocket(socketPath string) (*JSONStream, error)

FromUnixDomainSocket creates a JSON-RPC stream from the given unix socket.

func (*JSONStream) Close

func (s *JSONStream) Close() error

func (*JSONStream) Recv

func (s *JSONStream) Recv() (*pb.JSONRPCMessage, error)

func (*JSONStream) Send

func (s *JSONStream) Send(msg *pb.JSONRPCMessage) error

type RPCStream

type RPCStream interface {
	Send(*pb.JSONRPCMessage) error
	Recv() (*pb.JSONRPCMessage, error)
}

Jump to

Keyboard shortcuts

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