Documentation
¶
Overview ¶
Package frog defines RPC interface
Index ¶
- Variables
- func CallMethod(meta *RpcMethod, ctx context.Context, request proto.Message, ...) (err error)
- func GenerateServiceDesc(fileDescriptor []byte)
- func GenerateServiceDescName(servName string) string
- func RegisterService(sd *ServiceDesc, service interface{}, register MethodsRegister) (err error)
- type DefaultCall
- type MethodDesc
- type MethodsRegister
- type RpcCall
- type RpcChannel
- type RpcMethod
- type ServiceDesc
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CallMethod ¶
func CallMethod(meta *RpcMethod, ctx context.Context, request proto.Message, response proto.Message) (err error)
CallMethod invokes meta.method with given arguments
func GenerateServiceDesc ¶
func GenerateServiceDesc(fileDescriptor []byte)
GenerateServiceDesc called by generated code to generate ServiceDesc and MethodDesc
func GenerateServiceDescName ¶
GenerateServiceDescName generates service descriptor name with service name
func RegisterService ¶
func RegisterService(sd *ServiceDesc, service interface{}, register MethodsRegister) (err error)
RegisterService registers all rpc methods in service with given register It is called from generated code
Types ¶
type DefaultCall ¶
type DefaultCall struct {
// contains filtered or unexported fields
}
DefaultCall implements RpcCall interface and is enough to deal with most situations.
func NewDefaultCall ¶
func NewDefaultCall(request, response proto.Message) *DefaultCall
func (*DefaultCall) Close ¶
func (c *DefaultCall) Close(err error)
func (*DefaultCall) Done ¶
func (c *DefaultCall) Done() chan struct{}
func (*DefaultCall) Error ¶
func (c *DefaultCall) Error() error
func (*DefaultCall) Request ¶
func (c *DefaultCall) Request() proto.Message
func (*DefaultCall) Response ¶
func (c *DefaultCall) Response() proto.Message
type MethodDesc ¶
type MethodDesc struct { *desc.MethodDescriptorProto // contains filtered or unexported fields }
MethodDesc wraps MethodDescriptorProto and provide more functions
func (*MethodDesc) GetServiceDesc ¶
func (md *MethodDesc) GetServiceDesc() *ServiceDesc
GetServiceDesc returns method's service descriptor
type MethodsRegister ¶
type RpcCall ¶
type RpcCall interface { Request() proto.Message // The request to the rpc Response() proto.Message // The response from rpc Error() error // After completion, the error status. Done() chan struct{} // Strobes when call is complete. }
RpcCall represents an RPC call
type RpcChannel ¶
type RpcChannel interface { // Go invokes the function asynchronously. It returns the RpcCall structure // representing the invocation and will be called by many goroutines simultaneously. Go(method *MethodDesc, ctx context.Context, request proto.Message, response proto.Message) RpcCall }
RpcChannel represents a communication line to a Service which can be used to call that Service's methods. The Service may be running on another machine. Normally, you should not call an RpcChannel directly, but instead construct a stub Service wrapping it. Example:
channel := NewMyRpcChannel("remotehost.example.com:1234") stub := NewMyServiceStub(channel) err := stub.MyMethod(ctx, &request, &response) call := stub.AsyncMyMethod(ctx, &request, &response) <-call.Done()
type RpcMethod ¶
type RpcMethod struct {
// contains filtered or unexported fields
}
RpcMethod represents a rpc method metadata
func (*RpcMethod) Descriptor ¶
func (meta *RpcMethod) Descriptor() *MethodDesc
Descriptor returns method descriptor
func (*RpcMethod) NewRequest ¶
NewInput news a input variance
func (*RpcMethod) NewResponse ¶
NewInput news a output variance
type ServiceDesc ¶
type ServiceDesc struct { *desc.ServiceDescriptorProto // contains filtered or unexported fields }
ServiceDesc wraps ServiceDescriptorProto and provide more functions
func ServiceDescriptor ¶
func ServiceDescriptor(servicename string) *ServiceDesc
ServiceDescriptorProto called by generated code
func (*ServiceDesc) Method ¶
func (sd *ServiceDesc) Method(index int) *MethodDesc
Method returns the i-th method descriptor of service
func (*ServiceDesc) NumMethod ¶
func (sd *ServiceDesc) NumMethod() int
NumMethod returns the number of methods of service