grpc

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Example
package main

import (
	"github.com/goph/fxt"
	fxgrpc "github.com/goph/fxt/grpc"
	"go.uber.org/fx"
)

func main() {
	app := fx.New(
		fx.NopLogger,
		fxt.Bootstrap,
		fx.Provide(
			func() *fxgrpc.Config {
				return fxgrpc.NewConfig(":8080")
			},
			fxgrpc.NewServer,
		),
	)

	if err := app.Err(); err != nil {
		panic(err)
	}

}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Network string
	Addr    string

	// Register the reflection API or not
	ReflectionEnabled bool
}

Config holds a list of options used during the grpc server construction.

func NewConfig

func NewConfig(addr string) *Config

NewConfig returns a new config populated with default values.

type Err

type Err <-chan error

Err accepts an error which causes the application to stop.

func NewServer

func NewServer(params ServerParams) (*grpc.Server, Err)

NewServer creates a new grpc server.

type ServerParams

type ServerParams struct {
	dig.In

	Config            *Config
	StreamInterceptor grpc.StreamServerInterceptor `optional:"true"`
	UnaryInterceptor  grpc.UnaryServerInterceptor  `optional:"true"`
	Logger            log.Logger                   `optional:"true"`
	HealthCollector   healthz.Collector            `optional:"true"`
	Lifecycle         fxt.Lifecycle
}

ServerParams provides a set of dependencies for a grpc server constructor.

Jump to

Keyboard shortcuts

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