Documentation ¶
Overview ¶
Package operation is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterAppleServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterAppleServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AppleServiceClient) error
- func RegisterAppleServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterAppleServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AppleServiceServer) error
- func RegisterAppleServiceServer(s *grpc.Server, srv AppleServiceServer)
- type AppleServiceClient
- type AppleServiceServer
- type CreateAppleRequest
- func (*CreateAppleRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateAppleRequest) GetName() string
- func (x *CreateAppleRequest) GetSize() api.Apple_Size
- func (*CreateAppleRequest) ProtoMessage()
- func (x *CreateAppleRequest) ProtoReflect() protoreflect.Message
- func (x *CreateAppleRequest) Reset()
- func (x *CreateAppleRequest) String() string
- type DescribeAppleRequest
- func (*DescribeAppleRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DescribeAppleRequest) GetNumber() int32
- func (*DescribeAppleRequest) ProtoMessage()
- func (x *DescribeAppleRequest) ProtoReflect() protoreflect.Message
- func (x *DescribeAppleRequest) Reset()
- func (x *DescribeAppleRequest) String() string
- type DestroyAppleRequest
- func (*DestroyAppleRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DestroyAppleRequest) GetNumber() int32
- func (*DestroyAppleRequest) ProtoMessage()
- func (x *DestroyAppleRequest) ProtoReflect() protoreflect.Message
- func (x *DestroyAppleRequest) Reset()
- func (x *DestroyAppleRequest) String() string
- type ModifyAppleRequest
- func (*ModifyAppleRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ModifyAppleRequest) GetMask() *field_mask.FieldMask
- func (x *ModifyAppleRequest) GetName() string
- func (x *ModifyAppleRequest) GetNumber() int32
- func (x *ModifyAppleRequest) GetSize() api.Apple_Size
- func (*ModifyAppleRequest) ProtoMessage()
- func (x *ModifyAppleRequest) ProtoReflect() protoreflect.Message
- func (x *ModifyAppleRequest) Reset()
- func (x *ModifyAppleRequest) String() string
- type UnimplementedAppleServiceServer
- func (*UnimplementedAppleServiceServer) CreateApple(context.Context, *CreateAppleRequest) (*api.Apple, error)
- func (*UnimplementedAppleServiceServer) DescribeApple(context.Context, *DescribeAppleRequest) (*api.Apple, error)
- func (*UnimplementedAppleServiceServer) DestroyApple(context.Context, *DestroyAppleRequest) (*empty.Empty, error)
- func (*UnimplementedAppleServiceServer) ModifyApple(context.Context, *ModifyAppleRequest) (*api.Apple, error)
- func (*UnimplementedAppleServiceServer) UpdateApple(context.Context, *UpdateAppleRequest) (*api.Apple, error)
- type UpdateAppleRequest
- func (*UpdateAppleRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UpdateAppleRequest) GetName() string
- func (x *UpdateAppleRequest) GetNumber() int32
- func (x *UpdateAppleRequest) GetSize() api.Apple_Size
- func (*UpdateAppleRequest) ProtoMessage()
- func (x *UpdateAppleRequest) ProtoReflect() protoreflect.Message
- func (x *UpdateAppleRequest) Reset()
- func (x *UpdateAppleRequest) String() string
Constants ¶
This section is empty.
Variables ¶
var File_api_operation_operations_proto protoreflect.FileDescriptor
Functions ¶
func RegisterAppleServiceHandler ¶
func RegisterAppleServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterAppleServiceHandler registers the http handlers for service AppleService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterAppleServiceHandlerClient ¶
func RegisterAppleServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AppleServiceClient) error
RegisterAppleServiceHandlerClient registers the http handlers for service AppleService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AppleServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AppleServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "AppleServiceClient" to call the correct interceptors.
func RegisterAppleServiceHandlerFromEndpoint ¶
func RegisterAppleServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterAppleServiceHandlerFromEndpoint is same as RegisterAppleServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterAppleServiceHandlerServer ¶
func RegisterAppleServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AppleServiceServer) error
RegisterAppleServiceHandlerServer registers the http handlers for service AppleService to "mux". UnaryRPC :call AppleServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func RegisterAppleServiceServer ¶
func RegisterAppleServiceServer(s *grpc.Server, srv AppleServiceServer)
Types ¶
type AppleServiceClient ¶
type AppleServiceClient interface { DescribeApple(ctx context.Context, in *DescribeAppleRequest, opts ...grpc.CallOption) (*api.Apple, error) CreateApple(ctx context.Context, in *CreateAppleRequest, opts ...grpc.CallOption) (*api.Apple, error) UpdateApple(ctx context.Context, in *UpdateAppleRequest, opts ...grpc.CallOption) (*api.Apple, error) ModifyApple(ctx context.Context, in *ModifyAppleRequest, opts ...grpc.CallOption) (*api.Apple, error) DestroyApple(ctx context.Context, in *DestroyAppleRequest, opts ...grpc.CallOption) (*empty.Empty, error) }
AppleServiceClient is the client API for AppleService 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 NewAppleServiceClient ¶
func NewAppleServiceClient(cc grpc.ClientConnInterface) AppleServiceClient
type AppleServiceServer ¶
type AppleServiceServer interface { DescribeApple(context.Context, *DescribeAppleRequest) (*api.Apple, error) CreateApple(context.Context, *CreateAppleRequest) (*api.Apple, error) UpdateApple(context.Context, *UpdateAppleRequest) (*api.Apple, error) ModifyApple(context.Context, *ModifyAppleRequest) (*api.Apple, error) DestroyApple(context.Context, *DestroyAppleRequest) (*empty.Empty, error) // contains filtered or unexported methods }
AppleServiceServer is the server API for AppleService service. All implementations must embed UnimplementedAppleServiceServer for forward compatibility
type CreateAppleRequest ¶
type CreateAppleRequest struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Size api.Apple_Size `protobuf:"varint,3,opt,name=size,proto3,enum=api.Apple_Size" json:"size,omitempty"` // contains filtered or unexported fields }
func (*CreateAppleRequest) Descriptor
deprecated
func (*CreateAppleRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateAppleRequest.ProtoReflect.Descriptor instead.
func (*CreateAppleRequest) GetName ¶
func (x *CreateAppleRequest) GetName() string
func (*CreateAppleRequest) GetSize ¶
func (x *CreateAppleRequest) GetSize() api.Apple_Size
func (*CreateAppleRequest) ProtoMessage ¶
func (*CreateAppleRequest) ProtoMessage()
func (*CreateAppleRequest) ProtoReflect ¶
func (x *CreateAppleRequest) ProtoReflect() protoreflect.Message
func (*CreateAppleRequest) Reset ¶
func (x *CreateAppleRequest) Reset()
func (*CreateAppleRequest) String ¶
func (x *CreateAppleRequest) String() string
type DescribeAppleRequest ¶
type DescribeAppleRequest struct { Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` // contains filtered or unexported fields }
为了提供调用接口, 我们新声明了五个消息类型, 需要定义.
func (*DescribeAppleRequest) Descriptor
deprecated
func (*DescribeAppleRequest) Descriptor() ([]byte, []int)
Deprecated: Use DescribeAppleRequest.ProtoReflect.Descriptor instead.
func (*DescribeAppleRequest) GetNumber ¶
func (x *DescribeAppleRequest) GetNumber() int32
func (*DescribeAppleRequest) ProtoMessage ¶
func (*DescribeAppleRequest) ProtoMessage()
func (*DescribeAppleRequest) ProtoReflect ¶
func (x *DescribeAppleRequest) ProtoReflect() protoreflect.Message
func (*DescribeAppleRequest) Reset ¶
func (x *DescribeAppleRequest) Reset()
func (*DescribeAppleRequest) String ¶
func (x *DescribeAppleRequest) String() string
type DestroyAppleRequest ¶
type DestroyAppleRequest struct { Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` // contains filtered or unexported fields }
func (*DestroyAppleRequest) Descriptor
deprecated
func (*DestroyAppleRequest) Descriptor() ([]byte, []int)
Deprecated: Use DestroyAppleRequest.ProtoReflect.Descriptor instead.
func (*DestroyAppleRequest) GetNumber ¶
func (x *DestroyAppleRequest) GetNumber() int32
func (*DestroyAppleRequest) ProtoMessage ¶
func (*DestroyAppleRequest) ProtoMessage()
func (*DestroyAppleRequest) ProtoReflect ¶
func (x *DestroyAppleRequest) ProtoReflect() protoreflect.Message
func (*DestroyAppleRequest) Reset ¶
func (x *DestroyAppleRequest) Reset()
func (*DestroyAppleRequest) String ¶
func (x *DestroyAppleRequest) String() string
type ModifyAppleRequest ¶
type ModifyAppleRequest struct { Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Size api.Apple_Size `protobuf:"varint,3,opt,name=size,proto3,enum=api.Apple_Size" json:"size,omitempty"` Mask *field_mask.FieldMask `protobuf:"bytes,4,opt,name=mask,proto3" json:"mask,omitempty"` // contains filtered or unexported fields }
修改操作: 只需要设定对象需要变更的属性, 对于未指定的属性, 会保留原来的值. grpc中为了支持修改操作, 需要添加额外的FieldMask字段. 不过好在该字段的值不需要用户设定, grpc会自动生成.
func (*ModifyAppleRequest) Descriptor
deprecated
func (*ModifyAppleRequest) Descriptor() ([]byte, []int)
Deprecated: Use ModifyAppleRequest.ProtoReflect.Descriptor instead.
func (*ModifyAppleRequest) GetMask ¶
func (x *ModifyAppleRequest) GetMask() *field_mask.FieldMask
func (*ModifyAppleRequest) GetName ¶
func (x *ModifyAppleRequest) GetName() string
func (*ModifyAppleRequest) GetNumber ¶
func (x *ModifyAppleRequest) GetNumber() int32
func (*ModifyAppleRequest) GetSize ¶
func (x *ModifyAppleRequest) GetSize() api.Apple_Size
func (*ModifyAppleRequest) ProtoMessage ¶
func (*ModifyAppleRequest) ProtoMessage()
func (*ModifyAppleRequest) ProtoReflect ¶
func (x *ModifyAppleRequest) ProtoReflect() protoreflect.Message
func (*ModifyAppleRequest) Reset ¶
func (x *ModifyAppleRequest) Reset()
func (*ModifyAppleRequest) String ¶
func (x *ModifyAppleRequest) String() string
type UnimplementedAppleServiceServer ¶
type UnimplementedAppleServiceServer struct { }
UnimplementedAppleServiceServer must be embedded to have forward compatible implementations.
func (*UnimplementedAppleServiceServer) CreateApple ¶
func (*UnimplementedAppleServiceServer) CreateApple(context.Context, *CreateAppleRequest) (*api.Apple, error)
func (*UnimplementedAppleServiceServer) DescribeApple ¶
func (*UnimplementedAppleServiceServer) DescribeApple(context.Context, *DescribeAppleRequest) (*api.Apple, error)
func (*UnimplementedAppleServiceServer) DestroyApple ¶
func (*UnimplementedAppleServiceServer) DestroyApple(context.Context, *DestroyAppleRequest) (*empty.Empty, error)
func (*UnimplementedAppleServiceServer) ModifyApple ¶
func (*UnimplementedAppleServiceServer) ModifyApple(context.Context, *ModifyAppleRequest) (*api.Apple, error)
func (*UnimplementedAppleServiceServer) UpdateApple ¶
func (*UnimplementedAppleServiceServer) UpdateApple(context.Context, *UpdateAppleRequest) (*api.Apple, error)
type UpdateAppleRequest ¶
type UpdateAppleRequest struct { Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Size api.Apple_Size `protobuf:"varint,3,opt,name=size,proto3,enum=api.Apple_Size" json:"size,omitempty"` // contains filtered or unexported fields }
更新操作: 必须指定对象全部的属性, 对于未指定的属性, 应该将其设定为空或默认值;
func (*UpdateAppleRequest) Descriptor
deprecated
func (*UpdateAppleRequest) Descriptor() ([]byte, []int)
Deprecated: Use UpdateAppleRequest.ProtoReflect.Descriptor instead.
func (*UpdateAppleRequest) GetName ¶
func (x *UpdateAppleRequest) GetName() string
func (*UpdateAppleRequest) GetNumber ¶
func (x *UpdateAppleRequest) GetNumber() int32
func (*UpdateAppleRequest) GetSize ¶
func (x *UpdateAppleRequest) GetSize() api.Apple_Size
func (*UpdateAppleRequest) ProtoMessage ¶
func (*UpdateAppleRequest) ProtoMessage()
func (*UpdateAppleRequest) ProtoReflect ¶
func (x *UpdateAppleRequest) ProtoReflect() protoreflect.Message
func (*UpdateAppleRequest) Reset ¶
func (x *UpdateAppleRequest) Reset()
func (*UpdateAppleRequest) String ¶
func (x *UpdateAppleRequest) String() string