rpc

package
v0.0.0-...-18f1ea7 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package rpc is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServiceNil       = errors.New("rpc: nil service is not supported")
	ErrServiceWrongType = errors.New("rpc: only first-level pointer to struct is supported")
)

Functions

func EncodeMsg

func EncodeMsg(data []byte) []byte

func InitClientProxy

func InitClientProxy(network, address string, service Service) error

func ReadMsg

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

Types

type Client

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

func NewClient

func NewClient(network, addr string) (*Client, error)

func (*Client) Invoke

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

func (*Client) Send

func (c *Client) Send(ctx context.Context, data string) (string, error)

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(arg0 context.Context, arg1 *Request) (*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(arg0, arg1 interface{}) *gomock.Call

Invoke indicates an expected call of Invoke.

type Proxy

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

type Request

type Request struct {
	ServiceName string
	MethodName  string
	Arg         []byte
}

type Response

type Response struct {
	Data []byte
}

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 *Request) (*Response, error)

func (*Server) RegisterService

func (s *Server) RegisterService(service Service)

func (*Server) Start

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

type Service

type Service interface {
	Name() string
}

type UserService

type UserService struct {
	GetByID func(ctx context.Context, req *GetByIDReq) (*GetByIDResp, error)
}

func (UserService) Name

func (s UserService) Name() string

type UserServiceServer

type UserServiceServer struct {
}

func (*UserServiceServer) GetByID

func (s *UserServiceServer) GetByID(ctx context.Context, req *GetByIDReq) (*GetByIDResp, error)

func (*UserServiceServer) Name

func (s *UserServiceServer) Name() string

Jump to

Keyboard shortcuts

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