grpc

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package grpc provides opinionated production-ready gRPC server.

It also redirect gRPC log to slog using init function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(opts ...grpc.ServerOption) *grpc.Server

NewServer creates a new gRPC server with the given options.

It wraps grpc.NewServer with built-in interceptors, e.g recovery, log buffering.

func Run

func Run(server *grpc.Server, opts ...Option) func(context.Context) error

Run wraps start/stop of the gRPC server in a single run function with listening on multiple tcp and unix socket address.

It also resister health and reflection services if the services have not registered.

Types

type Option

type Option func(*options)

Option configures the runner for the gRPC server.

func WithAddress

func WithAddress(addresses ...string) Option

WithAddress provides the address listened by the gRPC server. It should be either tcp address like `:8080` or unix socket address like `unix:nilgo.sock`.

By default, it listens on `localhost:8080` or `:${PORT}` if the environment variable exists.

func WithConfigService

func WithConfigService(configs ...*konf.Config) Option

WithConfigService registers the pb.ConfigServiceServer implement to the gRPC server.

It uses the global konf.Config if the configs are not provided.

Directories

Path Synopsis
Package client provides utilities for gRPC client.
Package client provides utilities for gRPC client.
pb

Jump to

Keyboard shortcuts

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