mrpc

package module
v0.0.0-...-062a4ee Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 14 Imported by: 0

README

mrpc

mrpc 一种rpc协议实现

Documentation

Overview

Package mrpc is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithOneway

func CtxWithOneway(ctx context.Context) context.Context

func ReadMsg

func ReadMsg(conn net.Conn) ([]byte, error)

Types

type Client

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

func NewClient

func NewClient(addr string, opts ...ClientOption) (*Client, error)

func (*Client) InitService

func (c *Client) InitService(service Service) error

InitService 为GetById之类的函数类型字段赋值

func (*Client) Invoke

func (c *Client) Invoke(ctx context.Context, req *message.Request) (*message.Response, error)

type ClientOption

type ClientOption func(client *Client)

func ClientWithSerializer

func ClientWithSerializer(sl serialize.Serializer) ClientOption

type GetByIdReq

type GetByIdReq struct {
	Id int
}

type GetByIdResp

type GetByIdResp struct {
	Msg string
}

type MockProxy

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

MockProxy is a mock of Proxy interface.

func NewMockProxy

func NewMockProxy(ctrl *gomock.Controller) *MockProxy

NewMockProxy creates a new mock instance.

func (*MockProxy) EXPECT

func (m *MockProxy) EXPECT() *MockProxyMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProxy) Invoke

func (m *MockProxy) Invoke(ctx context.Context, req *message.Request) (*message.Response, error)

Invoke mocks base method.

type MockProxyMockRecorder

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

MockProxyMockRecorder is the mock recorder for MockProxy.

func (*MockProxyMockRecorder) Invoke

func (mr *MockProxyMockRecorder) Invoke(ctx, req interface{}) *gomock.Call

Invoke indicates an expected call of Invoke.

type MockService

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

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockService) Name

func (m *MockService) Name() string

Name mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) Name

func (mr *MockServiceMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

type Proxy

type Proxy interface {
	Invoke(ctx context.Context, req *message.Request) (*message.Response, error)
}

type Server

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

func NewServer

func NewServer() *Server

func (*Server) Invoke

func (s *Server) Invoke(ctx context.Context, req *message.Request) (*message.Response, error)

func (*Server) RegisterSerializer

func (s *Server) RegisterSerializer(sl serialize.Serializer)

func (*Server) RegisterService

func (s *Server) RegisterService(service Service)

func (*Server) Start

func (s *Server) Start(network, addr string) error

type Service

type Service interface {
	Name() string
}

type UserService

type UserService struct {
	GetById      func(ctx context.Context, req *GetByIdReq) (*GetByIdResp, error) // 一个GetById方法
	GetByIdProto func(ctx context.Context, req *gen.GetByIdReq) (*gen.GetByIdResp, error)
}

func (UserService) Name

func (u UserService) Name() string

type UserServiceServer

type UserServiceServer struct {
	Err error
	Msg string
}

func (*UserServiceServer) GetById

func (u *UserServiceServer) GetById(ctx context.Context, req *GetByIdReq) (*GetByIdResp, error)

func (*UserServiceServer) GetByIdProto

func (u *UserServiceServer) GetByIdProto(ctx context.Context, req *gen.GetByIdReq) (*gen.GetByIdResp, error)

func (*UserServiceServer) Name

func (u *UserServiceServer) Name() string

type UserServiceServerTimeout

type UserServiceServerTimeout struct {
	Err error
	Msg string
	// contains filtered or unexported fields
}

func (*UserServiceServerTimeout) GetById

func (*UserServiceServerTimeout) Name

func (u *UserServiceServerTimeout) Name() string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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