grpc

package
v0.0.0-...-f382dc8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Ok = &pb.Error{Code: pb.ErrCode_ERR_CODE_OK, Msg: "ok"}

	ErrUnknown = &pb.Error{Code: pb.ErrCode_ERR_CODE_UNKNOWN, Msg: "未知错误"}

	ErrArgsInvalid = &pb.Error{Code: pb.ErrCode_ERR_CODE_ARGS_INVALID, Msg: "无效的请求参数"}

	ErrBadRequest = &pb.Error{Code: pb.ErrCode_ERR_CODE_BAD_REQUEST, Msg: "请求错误"}

	ErrUnauthorized = &pb.Error{Code: pb.ErrCode_ERR_CODE_UNAUTHORIZED, Msg: "未认证"}

	ErrInternal = &pb.Error{Code: pb.ErrCode_ERR_CODE_INTERNAL, Msg: "系统内部错误"}

	ErrBussiness = &pb.Error{Code: pb.ErrCode_ERR_CODE_BUSINESS, Msg: "业务逻辑错误"}
)

错误列表

Functions

func ErrorToPb

func ErrorToPb(e error) *pb.Error

ErrorToPb ...

func ErrorWithHint

func ErrorWithHint(e *pb.Error, errorNumber uint32, hint string) *pb.Error

ErrorWithHint creates a pb Error with hint message.

func GetAccountFromContext

func GetAccountFromContext(ctx context.Context) string

GetAccountFromContext 从 metadata 中获取 account

func GetEmpIDFromContext

func GetEmpIDFromContext(ctx context.Context) string

GetEmpIDFromContext returns the empId that has been stored in Context, if available. This will return 0 if the user has not logged in. If there is an error attempting to return the empId it will be returned. It's valid for this function to return 0 with no error, which indicates the user has not logged in.

func GetLoginStatusFromContext

func GetLoginStatusFromContext(ctx context.Context) string

GetLoginStatusFromContext returns the empId login status that has been stored in Context

func GetMethodFromContext

func GetMethodFromContext(ctx context.Context) string

GetMethodFromContext 从 metadata 中获取 url_path

func GetURLPathFromContext

func GetURLPathFromContext(ctx context.Context) string

GetURLPathFromContext 从 metadata 中获取 url_path

Types

type GrpcServer

type GrpcServer struct {

	// Embed the unimplemented server
	pb.UnimplementedQMgmtServer
	// contains filtered or unexported fields
}

GrpcServer implements pb.UnimplementedMarsaxlokkServer.

func NewGrpcServer

func NewGrpcServer(r *run.RunTime) *GrpcServer

NewGrpcServer creates a new GrpcServer.

func (*GrpcServer) NginxStatus

func (s *GrpcServer) NginxStatus(_ context.Context, _ *pb.PingRequest) (*pb.PingReply, error)

func (*GrpcServer) Ping

func (*GrpcServer) SayHello

func (s *GrpcServer) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error)

func (*GrpcServer) Serve

func (s *GrpcServer) Serve(address string) error

Serve starts the grpc server.

func (*GrpcServer) Stop

func (s *GrpcServer) Stop()

Stop the grpc server.

func (*GrpcServer) Wait

func (s *GrpcServer) Wait() error

Wait 等待 grpc api 启动的协程执行结束

Directories

Path Synopsis
proto
protoc-gen-openapiv2/internal/genopenapi
Package genopenapi provides a code generator for OpenAPI v2.
Package genopenapi provides a code generator for OpenAPI v2.
qmgmt
Package qmgmt is a reverse proxy.
Package qmgmt is a reverse proxy.

Jump to

Keyboard shortcuts

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