grpc_showcase

package module
v0.0.0-...-f9672d4 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 4 Imported by: 0

README

gRPC Showcase

This is a gRPC best practise repo, which contains:

  • Google API design for gRPC and HTTP REST service
  • protocol buffers code gen via docker image, so you don't need to install all the toolchain
  • best practise for writing a gRPC service
  • multi-stage docker build with distroless image
  • runs on Kubernetes and Istio
  • integrates gRPC health probe protocol
  • gRPC-JSON transcoder in Istio envoy sidecar, so you can call gRPC service via HTTP REST JSON requests
  • cutting edge technology
  • automation all the workflows

Up and Running

You must have a working Kubernetes and Istio environment and config its ingress, simply run,

$ make deploy

Then test the gRPC client(requires Go),

$ go build -o cli ./cmd/cli
$ ./cli -addr=localhost:80 -name=World # replace with your server address
2020/05/05 13:35:48 Greeting: Hello World

Or just play with curl,

$ curl -d '{"name": "World"}' "localhost/v1/say" # replace with your server address
{
 "message": "Hello World"
}

TODO

  • sending arbitrary http request body in addition to JSON
  • replying arbitrary http response body in addition to JSON
  • rich google error status
  • custom error
  • request params validation
  • testing
  • other gRPC features, like api listing, interceptor, etc.

If you have any questions or contributions feel free to file an issue.

Have fun!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LibraryServer

type LibraryServer struct {
	pb.UnimplementedLibraryServer
}

func (*LibraryServer) CreateBook

func (l *LibraryServer) CreateBook(ctx context.Context, req *pb.CreateBookRequest) (*pb.Book, error)

func (*LibraryServer) CreateShelf

func (l *LibraryServer) CreateShelf(ctx context.Context, req *pb.CreateShelfRequest) (*pb.Shelf, error)

func (*LibraryServer) DeleteBook

func (l *LibraryServer) DeleteBook(ctx context.Context, req *pb.DeleteBookRequest) (*empty.Empty, error)

func (*LibraryServer) DeleteShelf

func (l *LibraryServer) DeleteShelf(ctx context.Context, req *pb.DeleteShelfRequest) (*empty.Empty, error)

func (*LibraryServer) GetBook

func (l *LibraryServer) GetBook(ctx context.Context, req *pb.GetBookRequest) (*pb.Book, error)

func (*LibraryServer) GetShelf

func (l *LibraryServer) GetShelf(ctx context.Context, req *pb.GetShelfRequest) (*pb.Shelf, error)

func (*LibraryServer) ListBooks

func (*LibraryServer) ListShelves

func (*LibraryServer) MergeShelves

func (l *LibraryServer) MergeShelves(ctx context.Context, req *pb.MergeShelvesRequest) (*pb.Shelf, error)

func (*LibraryServer) MoveBook

func (l *LibraryServer) MoveBook(ctx context.Context, req *pb.MoveBookRequest) (*pb.Book, error)

func (*LibraryServer) UpdateBook

func (l *LibraryServer) UpdateBook(ctx context.Context, req *pb.UpdateBookRequest) (*pb.Book, error)

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

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