v1

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package v1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	User_Create_FullMethodName   = "/user.v1.User/Create"
	User_Get_FullMethodName      = "/user.v1.User/Get"
	User_ListUser_FullMethodName = "/user.v1.User/ListUser"
)

Variables

View Source
var File_user_v1_user_proto protoreflect.FileDescriptor
View Source
var User_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "user.v1.User",
	HandlerType: (*UserServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Create",
			Handler:    _User_Create_Handler,
		},
		{
			MethodName: "Get",
			Handler:    _User_Get_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ListUser",
			Handler:       _User_ListUser_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "user/v1/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 RegisterUserHandler

func RegisterUserHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterUserHandler registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterUserHandlerClient

func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserClient) error

RegisterUserHandlerClient registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserClient" to call the correct interceptors. This client ignores the HTTP middlewares.

func RegisterUserHandlerFromEndpoint

func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterUserHandlerFromEndpoint is same as RegisterUserHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterUserHandlerServer

func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServer) error

RegisterUserHandlerServer registers the http handlers for service User to "mux". UnaryRPC :call UserServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserHandlerFromEndpoint instead. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.

func RegisterUserServer added in v0.0.14

func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)

Types

type CreateUserRequest

type CreateUserRequest struct {

	// 字段名应该是 lower_snake_case
	Name    string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Email   string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
	Phone   string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone,omitempty"`
	Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
	// contains filtered or unexported fields
}

消息名应该是 PascalCase

func (*CreateUserRequest) Descriptor deprecated

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

Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.

func (*CreateUserRequest) GetAddress

func (x *CreateUserRequest) GetAddress() string

func (*CreateUserRequest) GetEmail

func (x *CreateUserRequest) GetEmail() string

func (*CreateUserRequest) GetName

func (x *CreateUserRequest) GetName() string

func (*CreateUserRequest) GetPhone

func (x *CreateUserRequest) GetPhone() string

func (*CreateUserRequest) ProtoMessage

func (*CreateUserRequest) ProtoMessage()

func (*CreateUserRequest) ProtoReflect added in v0.0.15

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

func (*CreateUserRequest) Reset

func (x *CreateUserRequest) Reset()

func (*CreateUserRequest) String

func (x *CreateUserRequest) String() string

type CreateUserResponse

type CreateUserResponse struct {
	UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateUserResponse) Descriptor deprecated

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

Deprecated: Use CreateUserResponse.ProtoReflect.Descriptor instead.

func (*CreateUserResponse) GetUserId

func (x *CreateUserResponse) GetUserId() int64

func (*CreateUserResponse) ProtoMessage

func (*CreateUserResponse) ProtoMessage()

func (*CreateUserResponse) ProtoReflect added in v0.0.15

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

func (*CreateUserResponse) Reset

func (x *CreateUserResponse) Reset()

func (*CreateUserResponse) String

func (x *CreateUserResponse) String() string

type GetUserRequest

type GetUserRequest struct {
	UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetUserRequest) Descriptor deprecated

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

Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.

func (*GetUserRequest) GetUserId

func (x *GetUserRequest) GetUserId() int64

func (*GetUserRequest) ProtoMessage

func (*GetUserRequest) ProtoMessage()

func (*GetUserRequest) ProtoReflect added in v0.0.15

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

func (*GetUserRequest) Reset

func (x *GetUserRequest) Reset()

func (*GetUserRequest) String

func (x *GetUserRequest) String() string

type GetUserResponse

type GetUserResponse struct {
	UserId  int64  `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Name    string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Email   string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
	Phone   string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
	Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"`
	// contains filtered or unexported fields
}

func (*GetUserResponse) Descriptor deprecated

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

Deprecated: Use GetUserResponse.ProtoReflect.Descriptor instead.

func (*GetUserResponse) GetAddress

func (x *GetUserResponse) GetAddress() string

func (*GetUserResponse) GetEmail

func (x *GetUserResponse) GetEmail() string

func (*GetUserResponse) GetName

func (x *GetUserResponse) GetName() string

func (*GetUserResponse) GetPhone

func (x *GetUserResponse) GetPhone() string

func (*GetUserResponse) GetUserId

func (x *GetUserResponse) GetUserId() int64

func (*GetUserResponse) ProtoMessage

func (*GetUserResponse) ProtoMessage()

func (*GetUserResponse) ProtoReflect added in v0.0.15

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

func (*GetUserResponse) Reset

func (x *GetUserResponse) Reset()

func (*GetUserResponse) String

func (x *GetUserResponse) String() string

type ListUserRequest added in v0.0.20

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

func (*ListUserRequest) Descriptor deprecated added in v0.0.20

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

Deprecated: Use ListUserRequest.ProtoReflect.Descriptor instead.

func (*ListUserRequest) ProtoMessage added in v0.0.20

func (*ListUserRequest) ProtoMessage()

func (*ListUserRequest) ProtoReflect added in v0.0.20

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

func (*ListUserRequest) Reset added in v0.0.20

func (x *ListUserRequest) Reset()

func (*ListUserRequest) String added in v0.0.20

func (x *ListUserRequest) String() string

type UnimplementedUserServer added in v0.0.14

type UnimplementedUserServer struct{}

UnimplementedUserServer should be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedUserServer) Create added in v0.0.14

func (UnimplementedUserServer) Get added in v0.0.14

func (UnimplementedUserServer) ListUser added in v0.0.20

type UnsafeUserServer added in v0.0.14

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 added in v0.0.14

type UserClient interface {
	Create(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error)
	Get(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error)
	ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[UserInfo], 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.

服务名应该PascalCase

func NewUserClient added in v0.0.14

func NewUserClient(cc grpc.ClientConnInterface) UserClient

type UserInfo added in v0.0.20

type UserInfo struct {
	UserId  int64  `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Name    string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Email   string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
	Phone   string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
	Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"`
	// contains filtered or unexported fields
}

func (*UserInfo) Descriptor deprecated added in v0.0.20

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

Deprecated: Use UserInfo.ProtoReflect.Descriptor instead.

func (*UserInfo) GetAddress added in v0.0.20

func (x *UserInfo) GetAddress() string

func (*UserInfo) GetEmail added in v0.0.20

func (x *UserInfo) GetEmail() string

func (*UserInfo) GetName added in v0.0.20

func (x *UserInfo) GetName() string

func (*UserInfo) GetPhone added in v0.0.20

func (x *UserInfo) GetPhone() string

func (*UserInfo) GetUserId added in v0.0.20

func (x *UserInfo) GetUserId() int64

func (*UserInfo) ProtoMessage added in v0.0.20

func (*UserInfo) ProtoMessage()

func (*UserInfo) ProtoReflect added in v0.0.20

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

func (*UserInfo) Reset added in v0.0.20

func (x *UserInfo) Reset()

func (*UserInfo) String added in v0.0.20

func (x *UserInfo) String() string

type UserServer added in v0.0.14

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

服务名应该PascalCase

type User_ListUserClient added in v0.0.20

type User_ListUserClient = grpc.ServerStreamingClient[UserInfo]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type User_ListUserServer added in v0.0.20

type User_ListUserServer = grpc.ServerStreamingServer[UserInfo]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

Jump to

Keyboard shortcuts

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