transcodding

package
v0.0.0-...-0209dec Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package transcodding is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	SampleRPC_SaveItem_FullMethodName   = "/sample.SampleRPC/SaveItem"
	SampleRPC_GetItem_FullMethodName    = "/sample.SampleRPC/GetItem"
	SampleRPC_UpdateItem_FullMethodName = "/sample.SampleRPC/UpdateItem"
	SampleRPC_DeleteItem_FullMethodName = "/sample.SampleRPC/DeleteItem"
)

Variables

View Source
var File_service_proto protoreflect.FileDescriptor
View Source
var SampleRPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "sample.SampleRPC",
	HandlerType: (*SampleRPCServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "SaveItem",
			Handler:    _SampleRPC_SaveItem_Handler,
		},
		{
			MethodName: "GetItem",
			Handler:    _SampleRPC_GetItem_Handler,
		},
		{
			MethodName: "UpdateItem",
			Handler:    _SampleRPC_UpdateItem_Handler,
		},
		{
			MethodName: "DeleteItem",
			Handler:    _SampleRPC_DeleteItem_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "service.proto",
}

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

Functions

func RegisterSampleRPCHandler

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

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

func RegisterSampleRPCHandlerClient

func RegisterSampleRPCHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SampleRPCClient) error

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

func RegisterSampleRPCHandlerFromEndpoint

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

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

func RegisterSampleRPCHandlerServer

func RegisterSampleRPCHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SampleRPCServer) error

RegisterSampleRPCHandlerServer registers the http handlers for service SampleRPC to "mux". UnaryRPC :call SampleRPCServer 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 RegisterSampleRPCHandlerFromEndpoint instead.

func RegisterSampleRPCServer

func RegisterSampleRPCServer(s grpc.ServiceRegistrar, srv SampleRPCServer)

Types

type DeleteItemReq

type DeleteItemReq struct {
	ItemId uint32 `protobuf:"varint,1,opt,name=item_id,json=itemId,proto3" json:"item_id,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteItemReq) Descriptor deprecated

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

Deprecated: Use DeleteItemReq.ProtoReflect.Descriptor instead.

func (*DeleteItemReq) GetItemId

func (x *DeleteItemReq) GetItemId() uint32

func (*DeleteItemReq) ProtoMessage

func (*DeleteItemReq) ProtoMessage()

func (*DeleteItemReq) ProtoReflect

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

func (*DeleteItemReq) Reset

func (x *DeleteItemReq) Reset()

func (*DeleteItemReq) String

func (x *DeleteItemReq) String() string

type DeleteItemRes

type DeleteItemRes struct {
	Status bool `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteItemRes) Descriptor deprecated

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

Deprecated: Use DeleteItemRes.ProtoReflect.Descriptor instead.

func (*DeleteItemRes) GetStatus

func (x *DeleteItemRes) GetStatus() bool

func (*DeleteItemRes) ProtoMessage

func (*DeleteItemRes) ProtoMessage()

func (*DeleteItemRes) ProtoReflect

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

func (*DeleteItemRes) Reset

func (x *DeleteItemRes) Reset()

func (*DeleteItemRes) String

func (x *DeleteItemRes) String() string

type GetItemReq

type GetItemReq struct {
	ItemId uint32 `protobuf:"varint,1,opt,name=item_id,json=itemId,proto3" json:"item_id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetItemReq) Descriptor deprecated

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

Deprecated: Use GetItemReq.ProtoReflect.Descriptor instead.

func (*GetItemReq) GetItemId

func (x *GetItemReq) GetItemId() uint32

func (*GetItemReq) ProtoMessage

func (*GetItemReq) ProtoMessage()

func (*GetItemReq) ProtoReflect

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

func (*GetItemReq) Reset

func (x *GetItemReq) Reset()

func (*GetItemReq) String

func (x *GetItemReq) String() string

type GetItemRes

type GetItemRes struct {
	Item *Item `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
	// contains filtered or unexported fields
}

func (*GetItemRes) Descriptor deprecated

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

Deprecated: Use GetItemRes.ProtoReflect.Descriptor instead.

func (*GetItemRes) GetItem

func (x *GetItemRes) GetItem() *Item

func (*GetItemRes) ProtoMessage

func (*GetItemRes) ProtoMessage()

func (*GetItemRes) ProtoReflect

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

func (*GetItemRes) Reset

func (x *GetItemRes) Reset()

func (*GetItemRes) String

func (x *GetItemRes) String() string

type Item

type Item struct {
	ItemId  uint32 `protobuf:"varint,1,opt,name=item_id,json=itemId,proto3" json:"item_id,omitempty"`
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Title   string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
	Author  string `protobuf:"bytes,4,opt,name=author,proto3" json:"author,omitempty"`
	// contains filtered or unexported fields
}

func (*Item) Descriptor deprecated

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

Deprecated: Use Item.ProtoReflect.Descriptor instead.

func (*Item) GetAuthor

func (x *Item) GetAuthor() string

func (*Item) GetItemId

func (x *Item) GetItemId() uint32

func (*Item) GetMessage

func (x *Item) GetMessage() string

func (*Item) GetTitle

func (x *Item) GetTitle() string

func (*Item) ProtoMessage

func (*Item) ProtoMessage()

func (*Item) ProtoReflect

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

func (*Item) Reset

func (x *Item) Reset()

func (*Item) String

func (x *Item) String() string

type SampleRPCClient

type SampleRPCClient interface {
	SaveItem(ctx context.Context, in *SaveItemReq, opts ...grpc.CallOption) (*SaveItemRes, error)
	GetItem(ctx context.Context, in *GetItemReq, opts ...grpc.CallOption) (*GetItemRes, error)
	UpdateItem(ctx context.Context, in *UpdateItemReq, opts ...grpc.CallOption) (*UpdateItemRes, error)
	DeleteItem(ctx context.Context, in *DeleteItemReq, opts ...grpc.CallOption) (*DeleteItemRes, error)
}

SampleRPCClient is the client API for SampleRPC 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 NewSampleRPCClient

func NewSampleRPCClient(cc grpc.ClientConnInterface) SampleRPCClient

type SampleRPCServer

type SampleRPCServer interface {
	SaveItem(context.Context, *SaveItemReq) (*SaveItemRes, error)
	GetItem(context.Context, *GetItemReq) (*GetItemRes, error)
	UpdateItem(context.Context, *UpdateItemReq) (*UpdateItemRes, error)
	DeleteItem(context.Context, *DeleteItemReq) (*DeleteItemRes, error)
	// contains filtered or unexported methods
}

SampleRPCServer is the server API for SampleRPC service. All implementations must embed UnimplementedSampleRPCServer for forward compatibility

type SaveItemReq

type SaveItemReq struct {
	ItemId  uint32 `protobuf:"varint,1,opt,name=item_id,json=itemId,proto3" json:"item_id,omitempty"`
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Title   string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
	Author  string `protobuf:"bytes,4,opt,name=author,proto3" json:"author,omitempty"`
	// contains filtered or unexported fields
}

func (*SaveItemReq) Descriptor deprecated

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

Deprecated: Use SaveItemReq.ProtoReflect.Descriptor instead.

func (*SaveItemReq) GetAuthor

func (x *SaveItemReq) GetAuthor() string

func (*SaveItemReq) GetItemId

func (x *SaveItemReq) GetItemId() uint32

func (*SaveItemReq) GetMessage

func (x *SaveItemReq) GetMessage() string

func (*SaveItemReq) GetTitle

func (x *SaveItemReq) GetTitle() string

func (*SaveItemReq) ProtoMessage

func (*SaveItemReq) ProtoMessage()

func (*SaveItemReq) ProtoReflect

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

func (*SaveItemReq) Reset

func (x *SaveItemReq) Reset()

func (*SaveItemReq) String

func (x *SaveItemReq) String() string

type SaveItemRes

type SaveItemRes struct {
	Success bool   `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*SaveItemRes) Descriptor deprecated

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

Deprecated: Use SaveItemRes.ProtoReflect.Descriptor instead.

func (*SaveItemRes) GetMessage

func (x *SaveItemRes) GetMessage() string

func (*SaveItemRes) GetSuccess

func (x *SaveItemRes) GetSuccess() bool

func (*SaveItemRes) ProtoMessage

func (*SaveItemRes) ProtoMessage()

func (*SaveItemRes) ProtoReflect

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

func (*SaveItemRes) Reset

func (x *SaveItemRes) Reset()

func (*SaveItemRes) String

func (x *SaveItemRes) String() string

type UnimplementedSampleRPCServer

type UnimplementedSampleRPCServer struct {
}

UnimplementedSampleRPCServer must be embedded to have forward compatible implementations.

func (UnimplementedSampleRPCServer) DeleteItem

func (UnimplementedSampleRPCServer) GetItem

func (UnimplementedSampleRPCServer) SaveItem

func (UnimplementedSampleRPCServer) UpdateItem

type UnsafeSampleRPCServer

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

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

type UpdateItemReq

type UpdateItemReq struct {
	ItemId  uint32 `protobuf:"varint,1,opt,name=item_id,json=itemId,proto3" json:"item_id,omitempty"`
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Title   string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateItemReq) Descriptor deprecated

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

Deprecated: Use UpdateItemReq.ProtoReflect.Descriptor instead.

func (*UpdateItemReq) GetItemId

func (x *UpdateItemReq) GetItemId() uint32

func (*UpdateItemReq) GetMessage

func (x *UpdateItemReq) GetMessage() string

func (*UpdateItemReq) GetTitle

func (x *UpdateItemReq) GetTitle() string

func (*UpdateItemReq) ProtoMessage

func (*UpdateItemReq) ProtoMessage()

func (*UpdateItemReq) ProtoReflect

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

func (*UpdateItemReq) Reset

func (x *UpdateItemReq) Reset()

func (*UpdateItemReq) String

func (x *UpdateItemReq) String() string

type UpdateItemRes

type UpdateItemRes struct {
	Status bool  `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
	Item   *Item `protobuf:"bytes,2,opt,name=item,proto3" json:"item,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateItemRes) Descriptor deprecated

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

Deprecated: Use UpdateItemRes.ProtoReflect.Descriptor instead.

func (*UpdateItemRes) GetItem

func (x *UpdateItemRes) GetItem() *Item

func (*UpdateItemRes) GetStatus

func (x *UpdateItemRes) GetStatus() bool

func (*UpdateItemRes) ProtoMessage

func (*UpdateItemRes) ProtoMessage()

func (*UpdateItemRes) ProtoReflect

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

func (*UpdateItemRes) Reset

func (x *UpdateItemRes) Reset()

func (*UpdateItemRes) String

func (x *UpdateItemRes) String() string

Directories

Path Synopsis
google
api

Jump to

Keyboard shortcuts

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