book

package
v0.0.0-...-67066b3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package book is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	Genre_name = map[int32]string{
		0: "mystery",
		1: "horror",
		2: "comedy",
		3: "fiction",
	}
	Genre_value = map[string]int32{
		"mystery": 0,
		"horror":  1,
		"comedy":  2,
		"fiction": 3,
	}
)

Enum value maps for Genre.

View Source
var BookService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "book.BookService",
	HandlerType: (*BookServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateBook",
			Handler:    _BookService_CreateBook_Handler,
		},
		{
			MethodName: "GetBook",
			Handler:    _BookService_GetBook_Handler,
		},
		{
			MethodName: "DeleteBook",
			Handler:    _BookService_DeleteBook_Handler,
		},
		{
			MethodName: "UpdateBook",
			Handler:    _BookService_UpdateBook_Handler,
		},
		{
			MethodName: "GetBooks",
			Handler:    _BookService_GetBooks_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ListBooks",
			Handler:       _BookService_ListBooks_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "BooksCost",
			Handler:       _BookService_BooksCost_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "TopRatedBook",
			Handler:       _BookService_TopRatedBook_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "book/book_service.proto",
}

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

View Source
var File_book_author_proto protoreflect.FileDescriptor
View Source
var File_book_book_proto protoreflect.FileDescriptor
View Source
var File_book_book_service_proto protoreflect.FileDescriptor

Functions

func RegisterBookServiceHandler

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

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

func RegisterBookServiceHandlerClient

func RegisterBookServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client BookServiceClient) error

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

func RegisterBookServiceHandlerFromEndpoint

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

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

func RegisterBookServiceHandlerServer

func RegisterBookServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server BookServiceServer) error

RegisterBookServiceHandlerServer registers the http handlers for service BookService to "mux". UnaryRPC :call BookServiceServer 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 RegisterBookServiceHandlerFromEndpoint instead.

func RegisterBookServiceServer

func RegisterBookServiceServer(s grpc.ServiceRegistrar, srv BookServiceServer)

Types

type Author

type Author struct {
	Name       string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Popularity int32  `protobuf:"varint,2,opt,name=popularity,proto3" json:"popularity,omitempty"`
	// contains filtered or unexported fields
}

func (*Author) Descriptor deprecated

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

Deprecated: Use Author.ProtoReflect.Descriptor instead.

func (*Author) GetName

func (x *Author) GetName() string

func (*Author) GetPopularity

func (x *Author) GetPopularity() int32

func (*Author) ProtoMessage

func (*Author) ProtoMessage()

func (*Author) ProtoReflect

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

func (*Author) Reset

func (x *Author) Reset()

func (*Author) String

func (x *Author) String() string

type Book

type Book struct {
	Id     string  `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name   string  `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Genre  Genre   `protobuf:"varint,4,opt,name=genre,proto3,enum=book.Genre" json:"genre,omitempty"`
	Author *Author `protobuf:"bytes,5,opt,name=author,proto3" json:"author,omitempty"`
	Rating int32   `protobuf:"varint,6,opt,name=rating,proto3" json:"rating,omitempty"`
	Price  float64 `protobuf:"fixed64,7,opt,name=price,proto3" json:"price,omitempty"`
	// contains filtered or unexported fields
}

func (*Book) Descriptor deprecated

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

Deprecated: Use Book.ProtoReflect.Descriptor instead.

func (*Book) GetAuthor

func (x *Book) GetAuthor() *Author

func (*Book) GetGenre

func (x *Book) GetGenre() Genre

func (*Book) GetId

func (x *Book) GetId() string

func (*Book) GetName

func (x *Book) GetName() string

func (*Book) GetPrice

func (x *Book) GetPrice() float64

func (*Book) GetRating

func (x *Book) GetRating() int32

func (*Book) ProtoMessage

func (*Book) ProtoMessage()

func (*Book) ProtoReflect

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

func (*Book) Reset

func (x *Book) Reset()

func (*Book) String

func (x *Book) String() string

type BookServiceClient

type BookServiceClient interface {
	// unary call
	CreateBook(ctx context.Context, in *CreateBookRequest, opts ...grpc.CallOption) (*CreateBookResponse, error)
	// unary call
	GetBook(ctx context.Context, in *GetBookRequest, opts ...grpc.CallOption) (*GetBookResponse, error)
	// unary call
	DeleteBook(ctx context.Context, in *DeleteBookRequest, opts ...grpc.CallOption) (*DeleteBookResponse, error)
	// unary call
	UpdateBook(ctx context.Context, in *UpdateBookRequest, opts ...grpc.CallOption) (*UpdateBookResponse, error)
	// unary call
	GetBooks(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*GetBooksResponse, error)
	// server streaming
	ListBooks(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (BookService_ListBooksClient, error)
	// client streaming
	BooksCost(ctx context.Context, opts ...grpc.CallOption) (BookService_BooksCostClient, error)
	// client & server streaming
	TopRatedBook(ctx context.Context, opts ...grpc.CallOption) (BookService_TopRatedBookClient, error)
}

BookServiceClient is the client API for BookService 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 BookServiceServer

type BookServiceServer interface {
	// unary call
	CreateBook(context.Context, *CreateBookRequest) (*CreateBookResponse, error)
	// unary call
	GetBook(context.Context, *GetBookRequest) (*GetBookResponse, error)
	// unary call
	DeleteBook(context.Context, *DeleteBookRequest) (*DeleteBookResponse, error)
	// unary call
	UpdateBook(context.Context, *UpdateBookRequest) (*UpdateBookResponse, error)
	// unary call
	GetBooks(context.Context, *EmptyRequest) (*GetBooksResponse, error)
	// server streaming
	ListBooks(*EmptyRequest, BookService_ListBooksServer) error
	// client streaming
	BooksCost(BookService_BooksCostServer) error
	// client & server streaming
	TopRatedBook(BookService_TopRatedBookServer) error
	// contains filtered or unexported methods
}

BookServiceServer is the server API for BookService service. All implementations must embed UnimplementedBookServiceServer for forward compatibility

type BookService_BooksCostClient

type BookService_BooksCostClient interface {
	Send(*BooksCostRequest) error
	CloseAndRecv() (*BooksCostResponse, error)
	grpc.ClientStream
}

type BookService_BooksCostServer

type BookService_BooksCostServer interface {
	SendAndClose(*BooksCostResponse) error
	Recv() (*BooksCostRequest, error)
	grpc.ServerStream
}

type BookService_ListBooksClient

type BookService_ListBooksClient interface {
	Recv() (*GetBookResponse, error)
	grpc.ClientStream
}

type BookService_ListBooksServer

type BookService_ListBooksServer interface {
	Send(*GetBookResponse) error
	grpc.ServerStream
}

type BookService_TopRatedBookClient

type BookService_TopRatedBookClient interface {
	Send(*TopRatedRequest) error
	Recv() (*TopRatedResponse, error)
	grpc.ClientStream
}

type BookService_TopRatedBookServer

type BookService_TopRatedBookServer interface {
	Send(*TopRatedResponse) error
	Recv() (*TopRatedRequest, error)
	grpc.ServerStream
}

type BooksCostRequest

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

func (*BooksCostRequest) Descriptor deprecated

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

Deprecated: Use BooksCostRequest.ProtoReflect.Descriptor instead.

func (*BooksCostRequest) GetId

func (x *BooksCostRequest) GetId() string

func (*BooksCostRequest) ProtoMessage

func (*BooksCostRequest) ProtoMessage()

func (*BooksCostRequest) ProtoReflect

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

func (*BooksCostRequest) Reset

func (x *BooksCostRequest) Reset()

func (*BooksCostRequest) String

func (x *BooksCostRequest) String() string

type BooksCostResponse

type BooksCostResponse struct {
	Cost float64 `protobuf:"fixed64,1,opt,name=cost,proto3" json:"cost,omitempty"`
	// contains filtered or unexported fields
}

func (*BooksCostResponse) Descriptor deprecated

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

Deprecated: Use BooksCostResponse.ProtoReflect.Descriptor instead.

func (*BooksCostResponse) GetCost

func (x *BooksCostResponse) GetCost() float64

func (*BooksCostResponse) ProtoMessage

func (*BooksCostResponse) ProtoMessage()

func (*BooksCostResponse) ProtoReflect

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

func (*BooksCostResponse) Reset

func (x *BooksCostResponse) Reset()

func (*BooksCostResponse) String

func (x *BooksCostResponse) String() string

type CreateBookRequest

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

func (*CreateBookRequest) Descriptor deprecated

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

Deprecated: Use CreateBookRequest.ProtoReflect.Descriptor instead.

func (*CreateBookRequest) GetBook

func (x *CreateBookRequest) GetBook() *Book

func (*CreateBookRequest) ProtoMessage

func (*CreateBookRequest) ProtoMessage()

func (*CreateBookRequest) ProtoReflect

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

func (*CreateBookRequest) Reset

func (x *CreateBookRequest) Reset()

func (*CreateBookRequest) String

func (x *CreateBookRequest) String() string

type CreateBookResponse

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

func (*CreateBookResponse) Descriptor deprecated

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

Deprecated: Use CreateBookResponse.ProtoReflect.Descriptor instead.

func (*CreateBookResponse) GetId

func (x *CreateBookResponse) GetId() string

func (*CreateBookResponse) ProtoMessage

func (*CreateBookResponse) ProtoMessage()

func (*CreateBookResponse) ProtoReflect

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

func (*CreateBookResponse) Reset

func (x *CreateBookResponse) Reset()

func (*CreateBookResponse) String

func (x *CreateBookResponse) String() string

type DeleteBookRequest

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

func (*DeleteBookRequest) Descriptor deprecated

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

Deprecated: Use DeleteBookRequest.ProtoReflect.Descriptor instead.

func (*DeleteBookRequest) GetId

func (x *DeleteBookRequest) GetId() string

func (*DeleteBookRequest) ProtoMessage

func (*DeleteBookRequest) ProtoMessage()

func (*DeleteBookRequest) ProtoReflect

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

func (*DeleteBookRequest) Reset

func (x *DeleteBookRequest) Reset()

func (*DeleteBookRequest) String

func (x *DeleteBookRequest) String() string

type DeleteBookResponse

type DeleteBookResponse struct {
	Book []*Book `protobuf:"bytes,1,rep,name=book,proto3" json:"book,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteBookResponse) Descriptor deprecated

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

Deprecated: Use DeleteBookResponse.ProtoReflect.Descriptor instead.

func (*DeleteBookResponse) GetBook

func (x *DeleteBookResponse) GetBook() []*Book

func (*DeleteBookResponse) ProtoMessage

func (*DeleteBookResponse) ProtoMessage()

func (*DeleteBookResponse) ProtoReflect

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

func (*DeleteBookResponse) Reset

func (x *DeleteBookResponse) Reset()

func (*DeleteBookResponse) String

func (x *DeleteBookResponse) String() string

type EmptyRequest

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

func (*EmptyRequest) Descriptor deprecated

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

Deprecated: Use EmptyRequest.ProtoReflect.Descriptor instead.

func (*EmptyRequest) ProtoMessage

func (*EmptyRequest) ProtoMessage()

func (*EmptyRequest) ProtoReflect

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

func (*EmptyRequest) Reset

func (x *EmptyRequest) Reset()

func (*EmptyRequest) String

func (x *EmptyRequest) String() string

type Genre

type Genre int32
const (
	Genre_mystery Genre = 0
	Genre_horror  Genre = 1
	Genre_comedy  Genre = 2
	Genre_fiction Genre = 3
)

func (Genre) Descriptor

func (Genre) Descriptor() protoreflect.EnumDescriptor

func (Genre) Enum

func (x Genre) Enum() *Genre

func (Genre) EnumDescriptor deprecated

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

Deprecated: Use Genre.Descriptor instead.

func (Genre) Number

func (x Genre) Number() protoreflect.EnumNumber

func (Genre) String

func (x Genre) String() string

func (Genre) Type

func (Genre) Type() protoreflect.EnumType

type GetBookRequest

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

func (*GetBookRequest) Descriptor deprecated

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

Deprecated: Use GetBookRequest.ProtoReflect.Descriptor instead.

func (*GetBookRequest) GetId

func (x *GetBookRequest) GetId() string

func (*GetBookRequest) ProtoMessage

func (*GetBookRequest) ProtoMessage()

func (*GetBookRequest) ProtoReflect

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

func (*GetBookRequest) Reset

func (x *GetBookRequest) Reset()

func (*GetBookRequest) String

func (x *GetBookRequest) String() string

type GetBookResponse

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

func (*GetBookResponse) Descriptor deprecated

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

Deprecated: Use GetBookResponse.ProtoReflect.Descriptor instead.

func (*GetBookResponse) GetBook

func (x *GetBookResponse) GetBook() *Book

func (*GetBookResponse) ProtoMessage

func (*GetBookResponse) ProtoMessage()

func (*GetBookResponse) ProtoReflect

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

func (*GetBookResponse) Reset

func (x *GetBookResponse) Reset()

func (*GetBookResponse) String

func (x *GetBookResponse) String() string

type GetBooksResponse

type GetBooksResponse struct {
	Book []*Book `protobuf:"bytes,1,rep,name=book,proto3" json:"book,omitempty"`
	// contains filtered or unexported fields
}

func (*GetBooksResponse) Descriptor deprecated

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

Deprecated: Use GetBooksResponse.ProtoReflect.Descriptor instead.

func (*GetBooksResponse) GetBook

func (x *GetBooksResponse) GetBook() []*Book

func (*GetBooksResponse) ProtoMessage

func (*GetBooksResponse) ProtoMessage()

func (*GetBooksResponse) ProtoReflect

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

func (*GetBooksResponse) Reset

func (x *GetBooksResponse) Reset()

func (*GetBooksResponse) String

func (x *GetBooksResponse) String() string

type TopRatedRequest

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

func (*TopRatedRequest) Descriptor deprecated

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

Deprecated: Use TopRatedRequest.ProtoReflect.Descriptor instead.

func (*TopRatedRequest) GetBook

func (x *TopRatedRequest) GetBook() *Book

func (*TopRatedRequest) ProtoMessage

func (*TopRatedRequest) ProtoMessage()

func (*TopRatedRequest) ProtoReflect

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

func (*TopRatedRequest) Reset

func (x *TopRatedRequest) Reset()

func (*TopRatedRequest) String

func (x *TopRatedRequest) String() string

type TopRatedResponse

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

func (*TopRatedResponse) Descriptor deprecated

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

Deprecated: Use TopRatedResponse.ProtoReflect.Descriptor instead.

func (*TopRatedResponse) GetBook

func (x *TopRatedResponse) GetBook() *Book

func (*TopRatedResponse) ProtoMessage

func (*TopRatedResponse) ProtoMessage()

func (*TopRatedResponse) ProtoReflect

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

func (*TopRatedResponse) Reset

func (x *TopRatedResponse) Reset()

func (*TopRatedResponse) String

func (x *TopRatedResponse) String() string

type UnimplementedBookServiceServer

type UnimplementedBookServiceServer struct {
}

UnimplementedBookServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedBookServiceServer) BooksCost

func (UnimplementedBookServiceServer) CreateBook

func (UnimplementedBookServiceServer) DeleteBook

func (UnimplementedBookServiceServer) GetBook

func (UnimplementedBookServiceServer) GetBooks

func (UnimplementedBookServiceServer) ListBooks

func (UnimplementedBookServiceServer) TopRatedBook

func (UnimplementedBookServiceServer) UpdateBook

type UnsafeBookServiceServer

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

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

type UpdateBookRequest

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

func (*UpdateBookRequest) Descriptor deprecated

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

Deprecated: Use UpdateBookRequest.ProtoReflect.Descriptor instead.

func (*UpdateBookRequest) GetBook

func (x *UpdateBookRequest) GetBook() *Book

func (*UpdateBookRequest) ProtoMessage

func (*UpdateBookRequest) ProtoMessage()

func (*UpdateBookRequest) ProtoReflect

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

func (*UpdateBookRequest) Reset

func (x *UpdateBookRequest) Reset()

func (*UpdateBookRequest) String

func (x *UpdateBookRequest) String() string

type UpdateBookResponse

type UpdateBookResponse struct {
	Book []*Book `protobuf:"bytes,1,rep,name=book,proto3" json:"book,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateBookResponse) Descriptor deprecated

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

Deprecated: Use UpdateBookResponse.ProtoReflect.Descriptor instead.

func (*UpdateBookResponse) GetBook

func (x *UpdateBookResponse) GetBook() []*Book

func (*UpdateBookResponse) ProtoMessage

func (*UpdateBookResponse) ProtoMessage()

func (*UpdateBookResponse) ProtoReflect

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

func (*UpdateBookResponse) Reset

func (x *UpdateBookResponse) Reset()

func (*UpdateBookResponse) String

func (x *UpdateBookResponse) String() string

Jump to

Keyboard shortcuts

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