user

package
v0.0.0-...-75a017b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResponseCode_name = map[int32]string{
		0: "RESPONSE_CODE_UNKNOWN",
		1: "SUCCESS",
		2: "BAD_REQUEST",
		3: "INTERNAL_SERVER_ERROR",
		4: "RESOURCE_OCCUPIED",
		5: "RESOURCE_REPEAT",
	}
	ResponseCode_value = map[string]int32{
		"RESPONSE_CODE_UNKNOWN": 0,
		"SUCCESS":               1,
		"BAD_REQUEST":           2,
		"INTERNAL_SERVER_ERROR": 3,
		"RESOURCE_OCCUPIED":     4,
		"RESOURCE_REPEAT":       5,
	}
)

Enum value maps for ResponseCode.

View Source
var User_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "user.User",
	HandlerType: (*UserServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "getUser",
			Handler:    _User_GetUser_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "user.proto",
}

User_ServiceDesc is the grpc.ServiceDesc for User service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterUserServer

func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)

Types

type IdRequest

type IdRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

IdRequest id请求

func (*IdRequest) Descriptor deprecated

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

Deprecated: Use IdRequest.ProtoReflect.Descriptor instead.

func (*IdRequest) GetId

func (x *IdRequest) GetId() string

func (*IdRequest) ProtoMessage

func (*IdRequest) ProtoMessage()

func (*IdRequest) ProtoReflect

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

func (*IdRequest) Reset

func (x *IdRequest) Reset()

func (*IdRequest) String

func (x *IdRequest) String() string

type Response

type Response struct {
	Code   ResponseCode      `protobuf:"varint,1,opt,name=code,proto3,enum=user.ResponseCode" json:"code,omitempty"` // 响应码及信息
	Data   *anypb.Any        `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`                         // 响应数据
	Errors map[string]string ``                                                                                      // 错误信息
	/* 153-byte string literal not displayed */
	// contains filtered or unexported fields
}

Response 基本响应

func (*Response) Descriptor deprecated

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

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetCode

func (x *Response) GetCode() ResponseCode

func (*Response) GetData

func (x *Response) GetData() *anypb.Any

func (*Response) GetErrors

func (x *Response) GetErrors() map[string]string

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) ProtoReflect

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

func (*Response) Reset

func (x *Response) Reset()

func (*Response) String

func (x *Response) String() string

type ResponseCode

type ResponseCode int32

ResponseCode 响应码

const (
	// 枚举必须从0开始
	// 两个枚举都定义UNKNOWN会报错
	ResponseCode_RESPONSE_CODE_UNKNOWN ResponseCode = 0 // 未知
	ResponseCode_SUCCESS               ResponseCode = 1 // 处理成功,可能携带数据
	ResponseCode_BAD_REQUEST           ResponseCode = 2 // 请求参数错误,可能携带错误
	ResponseCode_INTERNAL_SERVER_ERROR ResponseCode = 3 // 处理失败,可能携带错误
	ResponseCode_RESOURCE_OCCUPIED     ResponseCode = 4 // 资源使用中,可能携带错误
	ResponseCode_RESOURCE_REPEAT       ResponseCode = 5 // 资源重复,可能携带错误
)

func (ResponseCode) Descriptor

func (ResponseCode) Enum

func (x ResponseCode) Enum() *ResponseCode

func (ResponseCode) EnumDescriptor deprecated

func (ResponseCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use ResponseCode.Descriptor instead.

func (ResponseCode) Number

func (ResponseCode) String

func (x ResponseCode) String() string

func (ResponseCode) Type

type UnimplementedUserServer

type UnimplementedUserServer struct {
}

UnimplementedUserServer must be embedded to have forward compatible implementations.

func (UnimplementedUserServer) GetUser

type UnsafeUserServer

type UnsafeUserServer interface {
	// contains filtered or unexported methods
}

UnsafeUserServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UserServer will result in compilation errors.

type UserClient

type UserClient interface {
	GetUser(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*Response, error)
}

UserClient is the client API for User service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewUserClient

func NewUserClient(cc grpc.ClientConnInterface) UserClient

type UserServer

type UserServer interface {
	GetUser(context.Context, *IdRequest) (*Response, error)
	// contains filtered or unexported methods
}

UserServer is the server API for User service. All implementations must embed UnimplementedUserServer for forward compatibility

Jump to

Keyboard shortcuts

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