xgrpc

package
v1.0.1-0...-e52dcc8 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_jupiter_proto_hugotransmission_proto protoreflect.FileDescriptor

Functions

func ChickRequest

func ChickRequest(req *HugoRequest) error

ChickRequest 校验请求信息

func ChickResponse

func ChickResponse(out *HugoResponse) error

ChickResponse 检查返回信息

func StreamInterceptorChain

func StreamInterceptorChain(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor

StreamInterceptorChain returns stream interceptors chain. 流拦截器链

func UnaryInterceptorChain

func UnaryInterceptorChain(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor

UnaryInterceptorChain returns interceptors chain. 一元拦截器链

Types

type Bar

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

func (*Bar) Descriptor deprecated

func (*Bar) Descriptor() ([]byte, []int)

Deprecated: Use Bar.ProtoReflect.Descriptor instead.

func (*Bar) ProtoMessage

func (*Bar) ProtoMessage()

func (*Bar) ProtoReflect

func (x *Bar) ProtoReflect() protoreflect.Message

func (*Bar) Reset

func (x *Bar) Reset()

func (*Bar) String

func (x *Bar) String() string

type Config

type Config struct {
	Name string `properties:"brian.rpc.server.name"`
	Host string `properties:"brian.rpc.server.host"`
	Port int    `properties:"brian.rpc.server.port"`
	// Network network type, tcp4 by default
	Network string `properties:"brian.rpc.server.Network"`
	// DisableTrace disbale Trace Interceptor, false by default
	//禁用跟踪器默认为true
	DisableTrace bool `properties:"brian.rpc.server.DisableTrace"`
	// DisableMetric disable Metric Interceptor, false by default
	//禁用监听器默认为true
	DisableMetric bool `properties:"brian.rpc.server.DisableMetric"`
	// SlowQueryThresholdInMilli, request will be colored if cost over this threshold value
	SlowQueryThresholdInMilli int64 `properties:"brian.rpc.server.timeout"`

	Weight float64 `properties:"brian.rpc.server.registry.weight"`
	// contains filtered or unexported fields
}

*

*
* Copyright (C) @2020 hugo network Co. Ltd
* @description
* @updateRemark
* @author               hugo
* @updateUser
* @createDate           2020/8/4 3:17 下午
* @updateDate           2020/8/4 3:17 下午
* @version              1.0

* TODO 日志需要单独处理 Grpc 的配置结构体

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig represents default config User should construct config base on DefaultConfig grpc默认的配置 用户不做调整则使用默认的配置

func RawConfig

func RawConfig() *Config

RawConfig ...

func StdConfig

func StdConfig() *Config

hugo Standard HTTP Server config

func (Config) Address

func (config Config) Address() string

Address ... 用来获取组装完成的服务地址

func (*Config) Build

func (config *Config) Build() *Server

Build ...

type HugoRequest

type HugoRequest struct {

	//请求id
	RequestId string `protobuf:"bytes,1,opt,name=requestId,proto3" json:"requestId,omitempty"`
	//接口名称
	InterfaceName string `protobuf:"bytes,2,opt,name=interfaceName,proto3" json:"interfaceName,omitempty"`
	//方法名称
	MethodName string `protobuf:"bytes,3,opt,name=methodName,proto3" json:"methodName,omitempty"`
	//方法参数 repeated 定义类似集合
	//map<string, Bar>  parameters = 4;
	//参数类型 repeated 定义类似集合
	//repeated string paramTypes =5;
	//map<string, Bar>  paramTypes = 5;
	//方法参数 repeated 定义类似集合
	Parameters []string `protobuf:"bytes,4,rep,name=parameters,proto3" json:"parameters,omitempty"`
	//参数类型 repeated 定义类似集合
	ParamTypes []string `protobuf:"bytes,5,rep,name=paramTypes,proto3" json:"paramTypes,omitempty"`
	// contains filtered or unexported fields
}

设置默认的请求数据传输

func (*HugoRequest) Descriptor deprecated

func (*HugoRequest) Descriptor() ([]byte, []int)

Deprecated: Use HugoRequest.ProtoReflect.Descriptor instead.

func (*HugoRequest) GetInterfaceName

func (x *HugoRequest) GetInterfaceName() string

func (*HugoRequest) GetMethodName

func (x *HugoRequest) GetMethodName() string

func (*HugoRequest) GetParamTypes

func (x *HugoRequest) GetParamTypes() []string

func (*HugoRequest) GetParameters

func (x *HugoRequest) GetParameters() []string

func (*HugoRequest) GetRequestId

func (x *HugoRequest) GetRequestId() string

func (*HugoRequest) ProtoMessage

func (*HugoRequest) ProtoMessage()

func (*HugoRequest) ProtoReflect

func (x *HugoRequest) ProtoReflect() protoreflect.Message

func (*HugoRequest) Reset

func (x *HugoRequest) Reset()

func (*HugoRequest) String

func (x *HugoRequest) String() string

type HugoResponse

type HugoResponse struct {

	//请求id
	RequestId string `protobuf:"bytes,1,opt,name=requestId,proto3" json:"requestId,omitempty"`
	//返回的结果默认是200,成功
	Code int32 `protobuf:"zigzag32,2,opt,name=code,proto3" json:"code,omitempty"`
	//消息默认是成功
	Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
	//数据默认是null
	Data string `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the greetings 设置默认的返回

func (*HugoResponse) Descriptor deprecated

func (*HugoResponse) Descriptor() ([]byte, []int)

Deprecated: Use HugoResponse.ProtoReflect.Descriptor instead.

func (*HugoResponse) GetCode

func (x *HugoResponse) GetCode() int32

func (*HugoResponse) GetData

func (x *HugoResponse) GetData() string

func (*HugoResponse) GetMessage

func (x *HugoResponse) GetMessage() string

func (*HugoResponse) GetRequestId

func (x *HugoResponse) GetRequestId() string

func (*HugoResponse) ProtoMessage

func (*HugoResponse) ProtoMessage()

func (*HugoResponse) ProtoReflect

func (x *HugoResponse) ProtoReflect() protoreflect.Message

func (*HugoResponse) Reset

func (x *HugoResponse) Reset()

func (*HugoResponse) String

func (x *HugoResponse) String() string

type Server

type Server struct {
	*grpc.Server

	*Config
	// contains filtered or unexported fields
}

Server ... grpc 服务的结构体

func (*Server) GracefulStop

func (s *Server) GracefulStop(ctx context.Context) error

GracefulStop implements server.Server interface it will stop grpc server gracefully 优雅的停止服务,服务接口 将优雅的停止grpc服务

func (*Server) Info

func (s *Server) Info(group, cluster string) *server.ServiceInfo

Info returns server info, used by governor and consumer balancer 初始化服务信息

func (*Server) Register

func (s *Server) Register(in interface{}, srv interface{})

写一个服务注册的方法 srv 服务的实现 in 服务的接口

func (*Server) Serve

func (s *Server) Serve() error

Server implements server.Server interface. 服务,实现服务和接口

func (*Server) Stop

func (s *Server) Stop() error

Stop implements server.Server interface it will terminate grpc server immediately 停止具体服务。服务接口 将立即停止grpc服务

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳