gripkit

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

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

Go to latest
Published: Mar 29, 2020 License: MIT Imports: 4 Imported by: 5

README

gripkit

gRPC go + web server toolkit. not a replacement but a wrapper to initialize grpc + grpc-web in a single shot.

$ go get -u github.com/roleypoly/gripkit

API

Basic usage is

gk := gripkit.Create(
  // gripkit.WithHTTPOptions(gripkit.HTTPOptions{ Addr: "", TLSCertFile: "", TLSKeyFile: "" }), // HTTP(S) server settings.
  // gripkit.WithGrpcWeb( /* add grpcweb.Options... */ ), // turns on gRPC-Web, options optional.
  // gripkit.WithOptions( /* add grpc.Options... */ ), // adds gRPC options
)

proto.RegisterGreeterService(gk.Server, greeterService) // setup gRPC services based on gk.Server.

err := gk.Serve() // starts HTTP(S) server. If TLSCertFile/TLSKeyFile isn't set, will use HTTP, otherwise HTTPS.
if err != nil {
  panic(err)
}

Documentation

Overview

Package gripkit provides wrappers and helpers for

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gripkit

type Gripkit struct {
	Server *grpc.Server
	// contains filtered or unexported fields
}

func Create

func Create(options ...Option) *Gripkit

func (*Gripkit) Serve

func (gk *Gripkit) Serve() error

type HTTPOptions

type HTTPOptions struct {
	TLSCertPath string
	TLSKeyPath  string
	Addr        string
}

type HealthzOptions

type HealthzOptions struct {
	UseDefault bool
	Handler    http.HandlerFunc

	// Optional IP:Port string, defaults to :10456
	Addr string
}

type Option

type Option func(*options)

func WithDebug

func WithDebug() Option

func WithGrpcWeb

func WithGrpcWeb(opts ...grpcweb.Option) Option

func WithHTTPOptions

func WithHTTPOptions(opts HTTPOptions) Option

func WithHealthz

func WithHealthz(hzOpts *HealthzOptions) Option

WithHealthz adds a custom /healthz handler to the gRPC HTTP server. Pass nil to disable.

func WithOptions

func WithOptions(opts ...grpc.ServerOption) Option

Jump to

Keyboard shortcuts

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