rpc

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultClientCallbackWorkers = 1
View Source
const DefaultServerWorkersCount = 1
View Source
const ProtobufContentType = "application/proto"

Variables

View Source
var File_rpc_rpc_proto protoreflect.FileDescriptor

Functions

func WithClientCallMessageExpiration added in v0.6.0

func WithClientCallMessageExpiration(t time.Duration) func(opts *ClientOptions)

func WithClientCallTimeout added in v0.6.0

func WithClientCallTimeout(t time.Duration) func(opts *ClientOptions)

func WithClientCallbackWorkers added in v0.6.0

func WithClientCallbackWorkers(n int) func(opts *ClientOptions)

func WithClientWaitReplies added in v0.6.0

func WithClientWaitReplies(t bool) func(opts *ClientOptions)

func WithServerWorkersCount added in v0.6.0

func WithServerWorkersCount(n int) func(opts *ServerOptions)

Types

type Client

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

func NewClient

func NewClient(producerPool, consumerPool rabbitmq.Pooler, invokeQueueName string, options ...func(opts *ClientOptions)) (*Client, error)

func (*Client) Invoke

func (c *Client) Invoke(ctx context.Context, method string, req interface{}, reply interface{}) error

func (*Client) ServeCallbacks added in v0.4.0

func (c *Client) ServeCallbacks(ctx context.Context) error

ServeCallbacks consumes callbacks from server

type ClientConnInterface

type ClientConnInterface interface {
	// Invoke performs a unary RPC and returns after the response is received
	// into reply.
	Invoke(ctx context.Context, method string, args interface{}, reply interface{}) error
}

ClientConnInterface defines the functions clients need to perform unary RPCs. It is implemented by *ClientConn, and is only intended to be referenced by generated code.

type ClientOptions added in v0.6.0

type ClientOptions struct {
	CallbackWorkers       int
	WaitReplies           bool
	CallMessageExpiration time.Duration
	CallTimeout           time.Duration
}

type MethodDesc

type MethodDesc struct {
	MethodName string
	Handler    methodHandler
}

MethodDesc represents an RPC service's method specification.

type RabbitMQServer added in v0.6.0

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

func NewRabbitMQServer added in v0.5.0

func NewRabbitMQServer(producerPool, consumerPool rabbitmq.Pooler, queue string, options ...func(opts *ServerOptions)) (*RabbitMQServer, error)

func (*RabbitMQServer) RegisterProtoService added in v0.6.0

func (s *RabbitMQServer) RegisterProtoService(serviceDesc *ServiceDesc, impl interface{})

func (*RabbitMQServer) Serve added in v0.6.0

func (s *RabbitMQServer) Serve(ctx context.Context) error

type Request

type Request struct {
	Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	Method  string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	// contains filtered or unexported fields
}

func (*Request) Descriptor deprecated

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

Deprecated: Use Request.ProtoReflect.Descriptor instead.

func (*Request) GetMethod

func (x *Request) GetMethod() string

func (*Request) GetService

func (x *Request) GetService() string

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) ProtoReflect

func (x *Request) ProtoReflect() protoreflect.Message

func (*Request) Reset

func (x *Request) Reset()

func (*Request) String

func (x *Request) String() string

type ServerOptions added in v0.6.0

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

type ServiceDesc

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

ServiceDesc represents an RPC service's specification.

type ServiceInfo added in v0.4.0

type ServiceInfo struct {
	// Contains the implementation for the methods in this service.
	ServiceImpl interface{}
	Methods     map[string]*MethodDesc
	Metadata    interface{}
}

ServiceInfo wraps information about a service. It is very similar to ServiceInfo and is constructed from it for internal purposes.

type ServiceRegistrar

type ServiceRegistrar interface {
	// RegisterProtoService registers a service and its implementation to the
	// concrete type implementing this interface.  It may not be called
	// once the server has started serving.
	// desc describes the service and its methods and handlers. impl is the
	// service implementation which is passed to the method handlers.
	RegisterProtoService(desc *ServiceDesc, impl interface{})
}

ServiceRegistrar wraps a single method that supports service registration. It enables users to pass concrete types other than amqp-rpc.Server to the service registration methods exported by the IDL generated code.

type UnaryHandler

type UnaryHandler func(ctx context.Context, req interface{}) (interface{}, error)

UnaryHandler defines the handler invoked by UnaryServerInterceptor to complete the normal execution of a unary RPC. If a UnaryHandler returns an error, it should be produced by the status package, or else RPC will use codes.Unknown as the status code and err.Error() as the status message of the RPC.

type UnaryServerInfo

type UnaryServerInfo struct {
	// Server is the service implementation the user provides. This is read-only.
	Server interface{}
	// FullMethod is the full RPC method string, i.e., /package.service/method.
	FullMethod string
}

UnaryServerInfo consists of various information about a unary RPC on server side. All per-rpc information may be mutated by the interceptor.

type UnaryServerInterceptor

type UnaryServerInterceptor func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (resp interface{}, err error)

UnaryServerInterceptor provides a hook to intercept the execution of a unary RPC on the server. info contains all the information of this RPC the interceptor can operate on. And handler is the wrapper of the service method implementation. It is the responsibility of the interceptor to invoke handler to complete the RPC.

Jump to

Keyboard shortcuts

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