rpc

package
v0.0.0-...-7e243a6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockClient

func NewMockClient(ctx context.Context, fun interface{}, s interface{}) (c mockClient, err error)

NewClient fun: pb.RegisterHelloServer(s *grpc.Server, srv HelloServer)

Types

type CliMethod

type CliMethod struct {
	Name   string
	CallID uint16
	// contains filtered or unexported fields
}

func (CliMethod) FuncName

func (m CliMethod) FuncName() string

func (CliMethod) NewReq

func (m CliMethod) NewReq() codec.Msg

func (CliMethod) NewResp

func (m CliMethod) NewResp() codec.Msg

func (CliMethod) ReqType

func (m CliMethod) ReqType() reflect.Type

func (CliMethod) RespType

func (m CliMethod) RespType() reflect.Type

func (CliMethod) SvcInvoke

func (m CliMethod) SvcInvoke(ctx context.Context, req codec.Msg) (resp codec.Msg, err error)

type Client

type Client struct {
	*codec.Codec
	// contains filtered or unexported fields
}

func StartClient

func StartClient(ctx context.Context, rwc io.ReadWriteCloser, fRegisters ...interface{}) (c Client, err error)

StartClient fRegister: pb.RegisterHelloServer(s *grpc.Server, srv HelloServer)

func (Client) Close

func (c Client) Close(ctx context.Context) (err error)

func (Client) Invoke

func (c Client) Invoke(ctx context.Context, method string, req codec.Msg, resp codec.Msg) (err error)

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, method string) (stream *codec.Stream, err error)

Stream 流式调用

type Peer

type Peer struct {
	Client
	Service
}

func StartPeer

func StartPeer(ctx context.Context, rwc io.ReadWriteCloser, service interface{}, fRegisters ...interface{}) (rpc Peer, err error)

StartPeer fRegister: pb.RegisterHelloServer(rpc *grpc.Server, srv HelloServer)

func (Peer) Clone

func (rpc Peer) Clone(ctx context.Context, rwc io.ReadWriteCloser, service interface{}) (out Peer, err error)

func (Peer) Close

func (rpc Peer) Close(ctx context.Context) (err error)

type Service

type Service struct {
	*codec.Codec
	// contains filtered or unexported fields
}

func StartService

func StartService(ctx context.Context, rwc io.ReadWriteCloser, service interface{}, fRegisters ...interface{}) (s Service, err error)

StartService fRegister: pb.RegisterHelloService, service: implementation

func (Service) AllInterfaces

func (s Service) AllInterfaces() (is []SvcMethod)

func (Service) Call

func (s Service) Call(ctx context.Context, methodIdx uint32, req unsafe.Pointer) (resp unsafe.Pointer, err error)

func (Service) Callers

func (s Service) Callers() []codec.Caller

func (Service) Clone

func (s Service) Clone(ctx context.Context, rwc io.ReadWriteCloser, service interface{}) (sNew Service, err error)

func (Service) CloneCallers

func (s Service) CloneCallers(service interface{}) []codec.Caller

func (Service) Close

func (c Service) Close(ctx context.Context) (err error)

func (Service) MethodIdx

func (s Service) MethodIdx(method string) (idx uint32, exist bool)

type SvcMethod

type SvcMethod struct {
	CliMethod
	Func       func(unsafe.Pointer, context.Context, unsafe.Pointer) (unsafe.Pointer, error)
	SvcPointer unsafe.Pointer
}

func (SvcMethod) SvcInvoke

func (m SvcMethod) SvcInvoke(ctx context.Context, req codec.Msg) (resp codec.Msg, err error)

Jump to

Keyboard shortcuts

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