operation

package
v0.0.0-...-81fab84 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package operation is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
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.

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) DescribeApple

func (*UnimplementedAppleServiceServer) DestroyApple

func (*UnimplementedAppleServiceServer) ModifyApple

func (*UnimplementedAppleServiceServer) UpdateApple

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

Jump to

Keyboard shortcuts

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