grpc_server_config

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultPort = 9090
	PkgName     = "grpc_server"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name                       string
	Host                       string        // IP地址,默认0.0.0.0
	Port                       int           // Port端口,默认9090
	Network                    string        // 网络类型,默认tcp4
	EnableMetricInterceptor    bool          // 是否开启监控,默认开启
	EnableTraceInterceptor     bool          // 是否开启链路追踪,默认开启
	EnableSkipHealthLog        bool          // 是否屏蔽探活日志,默认关闭
	SlowLogThreshold           time.Duration // 服务慢日志,默认500ms
	EnableAccessInterceptor    bool          // 是否开启,记录请求数据
	EnableAccessInterceptorReq bool          // 是否开启记录请求参数,默认不开启
	EnableAccessInterceptorRes bool          // 是否开启记录响应参数,默认不开启
	EnableServerReflection     bool          // 是否开启 reflection, 默认开启
	EnableHealth               bool          // 是否开启 grpc health, 默认开启
	MinDeadlineDuration        time.Duration // server handler ctx 最短超时时间, 默认 10s
	MetricSuccessCodes         []string      // metric 监控, 统一将此列表中的 biz code rewrite 成统一成功 code 20000, 默认为空不做操作
	// Deprecated: not affect anything
	EnableSkyWalking bool // 是否额外开启 skywalking, 默认开启

	ServerOptions            []grpc.ServerOption
	StreamInterceptors       []grpc.StreamServerInterceptor
	UnaryInterceptors        []grpc.UnaryServerInterceptor
	PrependUnaryInterceptors []grpc.UnaryServerInterceptor

	EnableFielLogger bool // 将日志输出到文件
	FielLoggerPath   string
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig represents default config User should construct config base on DefaultConfig

func (Config) Address

func (config Config) Address() string

Address ...

func (Config) InitLogger

func (config Config) InitLogger()

Jump to

Keyboard shortcuts

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