rpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(ctx context.Context, basePath, metadata, serverUrl, serverTag, serverMethod string, args *Args, reply *Reply) (err error)

Call 简易使用方式,直接使用localhost:port的方式,适合开发测试,不建议生产环境使用

basePath: 无用
metadata: 元数据,可以作为调用服务时候的一些辨别参数使用
serverUrl: 服务调用的地址。如:localhost:40000
serviceName: 服务提供方注册的服务名
methodName:  需要使用服务提供方具体的哪一个方法

func GrpcCall

func GrpcCall(ctx context.Context, basePath, clientType, serverHost string, serverPort int, serviceName, methodName string, args *Args, reply *Reply) (err error)

GrpcCall 支持多种etcd、ip、localhost等多种方式,

basePath: 注册中心 命名空间(etcd)
clientType: 注册中心方式(etcd、ip、localhost),默认localhost
serverHost: 如果clientType=ip 则直接使用ip连接
serverPort: 提供服务的端口
serviceName: 服务提供方注册的服务名
methodName:  需要使用服务提供方具体的哪一个方法

func WithRpcServer

func WithRpcServer(ctx context.Context, serviceAddress string, s *server.Server)

WithRpcServer 注册rpc服务

Types

type Args

type Args struct {
	PageNumber int    `json:"pageNumber,omitempty"` //分页-页码
	PageSize   int    `json:"pageSize,omitempty"`   //分页-每页显示数量
	Limit      int    `json:"limit,omitempty"`      //最大返回条数
	ParamsJson []byte `json:"paramsJson,omitempty"` //参数json

}

type Reply

type Reply struct {
	ErrMsg     string `json:"errMsg,omitempty"`     //错误详情
	ResultJson []byte `json:"resultJson,omitempty"` //结果json
}

Jump to

Keyboard shortcuts

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