Help us shape the future of Go! Take the 2026 Go Developer Survey

yarpc

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2018 License: MIT Imports: 12 Imported by: 5

README

yarpc

yarpc is Yet Another RPC package for Go.

In a barely working state right now, little error handling and lots of details still to resolve.

  • How shall header and trailer data be handled (for open tracing, status)

Documentation

Index

Constants

View Source
const (
	SupportPackageIsVersion1 = true
)

Variables

This section is empty.

Functions

func Invoke

func Invoke(ctx context.Context, api uint16, args interface{}, reply interface{}, cc *ClientConn) error

Types

type ClientConn

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

func Dial

func Dial(addr string, opt ...DialOption) (*ClientConn, error)

func DialContext

func DialContext(ctx context.Context, addr string, opts ...DialOption) (*ClientConn, error)

func (*ClientConn) Close

func (cc *ClientConn) Close() error

func (*ClientConn) NewStream

func (cc *ClientConn) NewStream() (*yamux.Stream, error)

type ClientStream

type ClientStream interface {
	// CloseSend closes the send direction of the stream. It closes the stream
	// when non-nil error is met.
	CloseSend() error
	Stream
}

ClientStream defines the interface a client stream has to satisfy.

func NewClientStream

func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, api uint16) (ClientStream, error)

type Codec

type Codec interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

func NewCodec

func NewCodec() Codec

type DialOption

type DialOption func(*dialOptions)

func WithCodec

func WithCodec(c Codec) DialOption

type MethodDesc

type MethodDesc struct {
	Index      uint8
	MethodName string
	Handler    methodHandler
}

type Server

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

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) RegisterService

func (s *Server) RegisterService(sd *ServiceDesc, ss interface{})

RegisterService registers a service and its implementation to the gRPC server. It is called from the IDL generated code. This must be called before invoking Serve.

func (*Server) Serve

func (s *Server) Serve(lis net.Listener) error

func (*Server) Stop

func (s *Server) Stop()

type ServerOption

type ServerOption func(*options)

func CustomCodec

func CustomCodec(c Codec) ServerOption

type ServerStream

type ServerStream interface {
	Stream
}

type ServiceDesc

type ServiceDesc struct {
	Index       uint8
	ServiceName string
	// The pointer to the service interface. Used to check whether the user
	// provided implementation satisfies the interface requirements.
	HandlerType interface{}
	Methods     []MethodDesc
	Streams     []StreamDesc
	Metadata    interface{}
}

ServiceDesc represents an RPC service's specification.

type Stream

type Stream interface {
	// Context returns the context for this stream.
	Context() context.Context
	// SendMsg blocks until it sends m, the stream is done or the stream
	// breaks.
	// On error, it aborts the stream and returns an RPC status on client
	// side. On server side, it simply returns the error to the caller.
	// SendMsg is called by generated code. Also Users can call SendMsg
	// directly when it is really needed in their use cases.
	// It's safe to have a goroutine calling SendMsg and another goroutine calling
	// recvMsg on the same stream at the same time.
	// But it is not safe to call SendMsg on the same stream in different goroutines.
	SendMsg(m interface{}) error
	// RecvMsg blocks until it receives a message or the stream is
	// done. On client side, it returns io.EOF when the stream is done. On
	// any other error, it aborts the stream and returns an RPC status. On
	// server side, it simply returns the error to the caller.
	// It's safe to have a goroutine calling SendMsg and another goroutine calling
	// recvMsg on the same stream at the same time.
	// But it is not safe to call RecvMsg on the same stream in different goroutines.
	RecvMsg(m interface{}) error
}

Stream defines the common interface a client or server stream has to satisfy.

type StreamDesc

type StreamDesc struct {
	Index      uint8
	StreamName string
	Handler    StreamHandler

	ServerStreams bool
	ClientStreams bool
}

type StreamHandler

type StreamHandler func(srv interface{}, stream ServerStream) error

Directories

Path Synopsis
cmd
protoc-gen-yarpc/generator
The code generator for the plugin for the Google protocol buffer compiler.
The code generator for the plugin for the Google protocol buffer compiler.
protoc-gen-yarpc/yarpc
Package yarpc outputs yarpc service descriptions in Go code.
Package yarpc outputs yarpc service descriptions in Go code.
Package codes is a generated protocol buffer package.
Package codes is a generated protocol buffer package.
Package status is a generated protocol buffer package.
Package status is a generated protocol buffer package.
test
foo
Package foo is a generated protocol buffer package.
Package foo is a generated protocol buffer package.
Package yarpcproto is a generated protocol buffer package.
Package yarpcproto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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