protocol

package
v0.0.0-...-1dd3e1b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserInfoNotFound   = errors.New("未获取到用户信息")
	UserInfoParseError = errors.New("用户信息解析失败")
	DecodeError        = "解析返回数据失败"
)
View Source
var (
	MethodNotFound = errors.New("没有找到对应的方法,请检查您的参数")
)

Functions

func FetchUserInfo

func FetchUserInfo(ctx context.Context) (*auth.CustomClaims, error)

func GetHeader

func GetHeader(ctx context.Context) map[string][]string

func GetHeaderKey

func GetHeaderKey(ctx context.Context, key string) string

func Marshal

func Marshal(out *Response, data interface{})

func RegisterRpcServiceServer

func RegisterRpcServiceServer(s *grpc.Server, srv RpcServiceServer)

func Unmarshal

func Unmarshal(in *Request, data interface{}) error

Types

type Args

type Args struct {
	Version              string   `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	Service              string   `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"`
	Method               string   `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"`
	Args                 []byte   `protobuf:"bytes,4,opt,name=args,proto3" json:"args,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Args) Descriptor

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

func (*Args) GetArgs

func (m *Args) GetArgs() []byte

func (*Args) GetMethod

func (m *Args) GetMethod() string

func (*Args) GetService

func (m *Args) GetService() string

func (*Args) GetVersion

func (m *Args) GetVersion() string

func (*Args) ProtoMessage

func (*Args) ProtoMessage()

func (*Args) Reset

func (m *Args) Reset()

func (*Args) String

func (m *Args) String() string

func (*Args) XXX_DiscardUnknown

func (m *Args) XXX_DiscardUnknown()

func (*Args) XXX_Marshal

func (m *Args) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Args) XXX_Merge

func (dst *Args) XXX_Merge(src proto.Message)

func (*Args) XXX_Size

func (m *Args) XXX_Size() int

func (*Args) XXX_Unmarshal

func (m *Args) XXX_Unmarshal(b []byte) error

type GrpcClient

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

func NewGrpcClient

func NewGrpcClient(version, service, method string) (*GrpcClient, error)

func (*GrpcClient) Close

func (c *GrpcClient) Close() error

func (*GrpcClient) GetConn

func (c *GrpcClient) GetConn() *grpc.ClientConn

func (*GrpcClient) Invoke

func (c *GrpcClient) Invoke(in *Request, ip string, userInfo *auth.CustomClaims, opts ...grpc.CallOption) (*Response, error)

func (*GrpcClient) InvokeWithTimeout

func (c *GrpcClient) InvokeWithTimeout(in *Request, ip string, userInfo *auth.CustomClaims, timeout time.Duration, opts ...grpc.CallOption) (*Response, error)

func (*GrpcClient) NoAuth

func (c *GrpcClient) NoAuth() bool

type Request

type Request struct {
	RequestJson          []byte   `protobuf:"bytes,1,opt,name=requestJson,proto3" json:"requestJson,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func MarshalRequest

func MarshalRequest(data interface{}) (*Request, error)

func (*Request) Descriptor

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

func (*Request) GetRequestJson

func (m *Request) GetRequestJson() []byte

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) Reset

func (m *Request) Reset()

func (*Request) String

func (m *Request) String() string

func (*Request) XXX_DiscardUnknown

func (m *Request) XXX_DiscardUnknown()

func (*Request) XXX_Marshal

func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Request) XXX_Merge

func (dst *Request) XXX_Merge(src proto.Message)

func (*Request) XXX_Size

func (m *Request) XXX_Size() int

func (*Request) XXX_Unmarshal

func (m *Request) XXX_Unmarshal(b []byte) error

type Response

type Response struct {
	Code                 int32    `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Msg                  string   `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
	ResultJson           []byte   `protobuf:"bytes,3,opt,name=resultJson,proto3" json:"resultJson,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func Error

func Error(code int32, msg interface{}, data ...interface{}) *Response

func Success

func Success(data ...interface{}) *Response

func SuccessWithMsg

func SuccessWithMsg(msg string, data ...interface{}) *Response

func (*Response) Build

func (m *Response) Build(code int32, msg interface{}, data ...interface{}) *Response

func (*Response) Descriptor

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

func (*Response) GetCode

func (m *Response) GetCode() int32

func (*Response) GetMsg

func (m *Response) GetMsg() string

func (*Response) GetResultJson

func (m *Response) GetResultJson() []byte

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) Reset

func (m *Response) Reset()

func (*Response) String

func (m *Response) String() string

func (*Response) XXX_DiscardUnknown

func (m *Response) XXX_DiscardUnknown()

func (*Response) XXX_Marshal

func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Response) XXX_Merge

func (dst *Response) XXX_Merge(src proto.Message)

func (*Response) XXX_Size

func (m *Response) XXX_Size() int

func (*Response) XXX_Unmarshal

func (m *Response) XXX_Unmarshal(b []byte) error

type RpcServiceClient

type RpcServiceClient interface {
	Invoke(ctx context.Context, in *Args, opts ...grpc.CallOption) (*Response, error)
}

RpcServiceClient is the client API for RpcService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewRpcServiceClient

func NewRpcServiceClient(cc *grpc.ClientConn) RpcServiceClient

type RpcServiceServer

type RpcServiceServer interface {
	Invoke(context.Context, *Args) (*Response, error)
}

RpcServiceServer is the server API for RpcService service.

Jump to

Keyboard shortcuts

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