grpc

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2018 License: MIT Imports: 12 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

func Dial added in v0.16.0

func Dial(config AppClientConfig, options ...grpc.DialOption) (*grpc.ClientConn, error)

Dial creates a client connection.

Types

type AppClientConfig added in v0.7.0

type AppClientConfig struct {
	// Addr is the gRPC connection address.
	Addr string `env:"" required:"true"`

	// Host can be used when the connection address and the certificate hostname differs.
	Host string `env:""`

	// Insecure makes the client use insecure channel.
	Insecure bool `env:""`
}

AppClientConfig can be used in an application config to represent gRPC client connection details. It supports github.com/goph/nest

type Config

type Config struct {
	Network string
	Addr    string

	// Register the reflection API or not
	ReflectionEnabled bool

	// A list of arbitrary server options for the gRPC server
	Options []grpc.ServerOption
}

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
	Logger          log.Logger        `optional:"true"`
	HealthCollector healthz.Collector `optional:"true"`
	Lifecycle       fxt.Lifecycle
}

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

Directories

Path Synopsis
middleware
correlationid/internal/mocks
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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