grpcclient

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

实现文件 基于 grpc 实现的 rpc-client

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrServiceNotAvailable 服务不可用,通常是因为没有查询到中心节点(coordinate)
	ErrServiceNotAvailable = errors.New("caller service not available")

	// ErrConfigConvert 配置转换失败
	ErrConfigConvert = errors.New("convert linker config")

	// ErrCantFindNode 在注册中心找不到对应的服务节点
	ErrCantFindNode = errors.New("can't find service node in center")
)
View Source
var (
	DefaultClientParm = Parm{
		PoolInitNum:  8,
		PoolCapacity: 64,
		PoolIdle:     time.Second * 100,
	}
)

Functions

func BuildWithOption

func BuildWithOption(info meta.ServiceInfo, log *blog.Logger, b balancer.IBalancer, linkcache module.ILinkCache, ps module.IPubsub, opts ...Option) module.IClient

Types

type Option

type Option func(*Parm)

Option config wraps

func AppendStreamInterceptors

func AppendStreamInterceptors(interceptor grpc.StreamClientInterceptor) Option

func AppendUnaryInterceptors

func AppendUnaryInterceptors(interceptor grpc.UnaryClientInterceptor) Option

func WithPoolCapacity

func WithPoolCapacity(num int) Option

WithPoolCapacity 连接池的容量大小

func WithPoolIdle

func WithPoolIdle(second int) Option

WithPoolIdle 连接池的最大闲置时间

func WithPoolInitNum

func WithPoolInitNum(num int) Option

WithPoolInitNum 连接池初始化数量

type Parm

type Parm struct {
	PoolInitNum  int
	PoolCapacity int
	PoolIdle     time.Duration

	UnaryInterceptors  []grpc.UnaryClientInterceptor
	StreamInterceptors []grpc.StreamClientInterceptor
}

Parm 调用器配置项

Jump to

Keyboard shortcuts

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