hello

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

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

Go to latest
Published: Jan 6, 2019 License: MIT Imports: 10 Imported by: 0

README

go-hello-grpc

Build Status CodeCov Go Report Card GoDoc Sourcegraph

A simple "Hello World" style gRPC RPC service written in https://golang.org/ using Protocol Buffers for serialization.

This is mostly useful as a template / starting point for your next gRPC micro-service / project. It uses the latest versions of dependencies, Go11Modules and some basic boilerplate ready to go.

For a more detailed guide see:

Pre-requisites

A C Compiler

Make sure you have a C compiler as Protocol Buffers requires CGO.

Please refer to your system documentation or package management software.

Protocol Buffers Compiler

Be sure to install the Protocol Buffers compiler.

On macOS you can use Homebrew to install this with:

brew install protobuf

For other platforms please see the documentation.

Go support for Protocol Buffers
go get -u github.com/golang/protobuf/protoc-gen-go

Usage

Building:

git clone https://github.com/prologic/go-hello-grpc
cd go-hello-grpc
make

Running the Server:

$ ./server
INFO[0008] received: name:"world"

Running the Client:

$ ./client
INFO[0000] Greeting: Hello world

Running Tests:

$ make test
ok  	github.com/prologic/go-hello-grpc	1.044s	coverage: 53.1% of statements

License

go-hello-grpc is licensed under the terms of the MIT License.

See ./LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version release version
	Version = "0.0.1"

	// Build will be overwritten automatically by the build system
	Build = "dev"

	// GitCommit will be overwritten automatically by the build system
	GitCommit = "HEAD"
)

Functions

func FullVersion

func FullVersion() string

FullVersion returns the full version, build and commit hash

func NewClient

func NewClient(addr string) (hello.HelloWorldClient, error)

Types

type Server

type Server struct {
	Addr string
}

func NewServer

func NewServer(addr string) *Server

func (*Server) Greet

func (s *Server) Greet(ctx context.Context, person *common.Person) (*common.Greeting, error)

Greet implements helloworld.GreeterServer

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe sets up a listener and starts serving requests

func (*Server) ListenAndServeTLS

func (s *Server) ListenAndServeTLS(certFile, keyFile string) error

ListenAndServeTLS sets up a TLS listener and starts serving requests

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

Serve starts serving requests with the provided listener

Directories

Path Synopsis
cmd
proto

Jump to

Keyboard shortcuts

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