egrpc

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 33 Imported by: 10

Documentation

Index

Constants

View Source
const PackageName = "client.egrpc"

PackageName 设置包名

Variables

View Source
var EnableSRVLookups = false

EnableSRVLookups controls whether the DNS resolver attempts to fetch gRPCLB copy from google.golang.org/grpc@v1.29.1/resolver/dns/dns_resolver.go addresses from SRV records. Must not be changed after init time.

Functions

func DNSRegistry added in v0.5.0

func DNSRegistry(opts ...DNSRegistryOption) eregistry.Registry

DNSRegistry 返回DNS Registry

Types

type Component

type Component struct {
	*grpc.ClientConn
	// contains filtered or unexported fields
}

Component 组件

func (*Component) Error added in v0.5.5

func (c *Component) Error() error

Error 错误信息

type Config

type Config struct {
	Addr                         string        // 连接地址,直连为127.0.0.1:9001,服务发现为etcd:///appname
	BalancerName                 string        // 负载均衡方式,默认round robin
	OnFail                       string        // 失败后的处理方式,panic | error
	DialTimeout                  time.Duration // 连接超时,默认3s
	ReadTimeout                  time.Duration // 读超时,默认1s
	SlowLogThreshold             time.Duration // 慢日志记录的阈值,默认600ms
	EnableBlock                  bool          // 是否开启阻塞,默认开启
	EnableWithInsecure           bool          // 是否开启非安全传输,默认开启
	EnableMetricInterceptor      bool          // 是否开启监控,默认开启
	EnableTraceInterceptor       bool          // 是否开启链路追踪,默认开启
	EnableAppNameInterceptor     bool          // 是否开启传递应用名,默认开启
	EnableTimeoutInterceptor     bool          // 是否开启超时传递,默认开启
	EnableAccessInterceptor      bool          // 是否开启记录请求数据,默认不开启
	EnableAccessInterceptorReq   bool          // 是否开启记录请求参数,默认不开启
	EnableAccessInterceptorRes   bool          // 是否开启记录响应参数,默认不开启
	EnableCPUUsage               bool          // 是否开启CPU利用率,默认开启
	EnableFailOnNonTempDialError bool
	// contains filtered or unexported fields
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig defines grpc client default configuration User should construct config base on DefaultConfig

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container 容器

func DefaultContainer

func DefaultContainer() *Container

DefaultContainer 默认容器

func Load

func Load(key string) *Container

Load 加载配置key

func (*Container) Build

func (c *Container) Build(options ...Option) *Component

Build 构建组件

type DNSRegistryOption added in v0.5.0

type DNSRegistryOption func(c *dnsRegistry)

DNSRegistryOption ...

func WithForceResolveInterval added in v0.5.2

func WithForceResolveInterval(forceResolveInterval time.Duration) DNSRegistryOption

WithForceResolveInterval 指定DNS强制resolve周期

func WithNameWrapper added in v0.5.0

func WithNameWrapper(wrapper func(string) string) DNSRegistryOption

WithNameWrapper 对dns:///SVC-NAME:PORT中的SVC-NAME进行处理,当SVC-NAME为IP时不做任何处理

type Option

type Option func(c *Container)

Option 可选项

func WithAddr added in v0.3.5

func WithAddr(addr string) Option

WithAddr setting grpc server address

func WithBalancerName added in v0.3.5

func WithBalancerName(balancerName string) Option

WithBalancerName setting grpc load balancer name

func WithDebug added in v0.3.5

func WithDebug(enableDebug bool) Option

WithDebug setting if enable debug mode

func WithDialOption

func WithDialOption(opts ...grpc.DialOption) Option

WithDialOption setting grpc dial options

func WithDialTimeout added in v0.3.5

func WithDialTimeout(t time.Duration) Option

WithDialTimeout setting grpc dial timeout

func WithEnableAccessInterceptor added in v0.4.0

func WithEnableAccessInterceptor(enableAccessInterceptor bool) Option

WithEnableAccessInterceptor 开启日志记录

func WithEnableAccessInterceptorReq added in v0.4.0

func WithEnableAccessInterceptorReq(enableAccessInterceptorReq bool) Option

WithEnableAccessInterceptorReq 开启日志请求参数

func WithEnableAccessInterceptorRes added in v0.4.0

func WithEnableAccessInterceptorRes(enableAccessInterceptorRes bool) Option

WithEnableAccessInterceptorRes 开启日志响应记录

func WithOnFail added in v0.3.5

func WithOnFail(onFail string) Option

WithOnFail setting failing mode

func WithReadTimeout added in v0.3.5

func WithReadTimeout(t time.Duration) Option

WithReadTimeout setting grpc read timeout

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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