grpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//默认GRPC链路包接收大小
	DefaultMaxCallRecvMsgSize = 50 * 1024 * 1024
	//GRPC链路包接收大小的设置上限
	MaxMaxCallRecvMsgSize = 500 * 1024 * 1024
)

Variables

This section is empty.

Functions

func IsSuccess

func IsSuccess(code uint32) bool

是否成功错误码

Types

type AsyncRateLimitConnector

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

目前只实现了 RateLimit-Acquire的异步 和 metric-report的异步

func NewAsyncRateLimitConnector

func NewAsyncRateLimitConnector(
	valueCtx model.ValueContext, clientInfo *network.ClientInfo, cfg config.Configuration) *AsyncRateLimitConnector

NewAsyncRateLimitConnector

func (*AsyncRateLimitConnector) Destroy

func (a *AsyncRateLimitConnector) Destroy()

清理

func (*AsyncRateLimitConnector) GetMessageSender

func (a *AsyncRateLimitConnector) GetMessageSender(
	svcKey model.ServiceKey, hashValue uint64) (serverconnector.RateLimitMsgSender, error)

创建流上下文

func (*AsyncRateLimitConnector) OnTaskEvent

func (a *AsyncRateLimitConnector) OnTaskEvent(event model.TaskEvent)

OnTaskEvent 任务事件回调

func (*AsyncRateLimitConnector) Process

func (a *AsyncRateLimitConnector) Process(
	taskKey interface{}, taskValue interface{}, lastProcessTime time.Time) model.TaskResult

定时处理过期任务

func (*AsyncRateLimitConnector) StreamCount

func (a *AsyncRateLimitConnector) StreamCount() int

获取stream的数量,用于测试

type Connector

type Connector struct {
	*plugin.PluginBase
	*common.RunContext
	// contains filtered or unexported fields
}

Connector cl5服务端代理,使用GRPC协议对接

func (*Connector) CreateConnection

func (g *Connector) CreateConnection(
	address string, timeout time.Duration, clientInfo *network.ClientInfo) (network.ClosableConn, error)

创建连接

func (*Connector) DeRegisterServiceHandler

func (g *Connector) DeRegisterServiceHandler(key *model.ServiceEventKey) error

DeRegisterEventHandler 反注册事件监听器 异常场景:当sdk已经退出过程中,则返回error

func (*Connector) DeregisterInstance

func (g *Connector) DeregisterInstance(req *model.InstanceDeRegisterRequest) error

DeregisterInstance 同步反注册服务

func (*Connector) Destroy

func (g *Connector) Destroy() error

Destroy 销毁插件,可用于释放资源

func (*Connector) GetAsyncRateLimitConnector

func (g *Connector) GetAsyncRateLimitConnector() serverconnector.AsyncRateLimitConnector

func (*Connector) GetConnectionManager

func (g *Connector) GetConnectionManager() network.ConnectionManager

获取连接管理器

func (*Connector) Heartbeat

func (g *Connector) Heartbeat(req *model.InstanceHeartbeatRequest) error

Heartbeat 心跳上报

func (*Connector) Init

func (g *Connector) Init(ctx *plugin.InitContext) error

Init 初始化插件

func (*Connector) IsEnable

func (g *Connector) IsEnable(cfg config.Configuration) bool

enable

func (*Connector) Name

func (g *Connector) Name() string

Name 插件名,一个类型下插件名唯一

func (*Connector) RegisterInstance

RegisterInstance 同步注册服务

func (*Connector) RegisterServiceHandler

func (g *Connector) RegisterServiceHandler(svcEventHandler *serverconnector.ServiceEventHandler) error

RegisterServiceHandler 注册服务监听器 异常场景:当key不合法或者sdk已经退出过程中,则返回error

func (*Connector) ReportClient

上报客户端信息 异常场景:当sdk已经退出过程中,则返回error 异常场景:当服务端不可用或者上报失败,则返回error,调用者需进行重试

func (*Connector) Start

func (g *Connector) Start() error

启动插件

func (*Connector) Type

func (g *Connector) Type() common.Type

Type 插件类型

func (*Connector) UpdateServers

func (g *Connector) UpdateServers(key *model.ServiceEventKey) error

更新服务端地址 异常场景:当地址列表为空,或者地址全部连接失败,则返回error,调用者需进行重试

type CounterIdentifier

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

计数器标识

func (CounterIdentifier) String

func (c CounterIdentifier) String() string

ToString输出

type DurationBaseCallBack

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

基于时间段的回调结构

type HostIdentifier

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

节点标识

func (HostIdentifier) String

func (h HostIdentifier) String() string

ToString输出

type InitializeRecord

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

初始化记录

func (*InitializeRecord) Expired

func (ir *InitializeRecord) Expired(nowMilli int64) bool

记录超时

type StreamCounterSet

type StreamCounterSet struct {

	//目标节点信息
	HostIdentifier *HostIdentifier
	// contains filtered or unexported fields
}

同一个节点的counter集合,用于回调

func NewStreamCounterSet

func NewStreamCounterSet(asyncConnector *AsyncRateLimitConnector, identifier *HostIdentifier) *StreamCounterSet

新建流管理器

func (*StreamCounterSet) AdjustTime

func (s *StreamCounterSet) AdjustTime() int64

同步时间

func (*StreamCounterSet) CompareTo

func (s *StreamCounterSet) CompareTo(value interface{}) int

比较两个元素

func (*StreamCounterSet) EnsureDeleted

func (s *StreamCounterSet) EnsureDeleted(value interface{}) bool

删除前进行检查,返回true才删除,该检查是同步操作

func (*StreamCounterSet) Expired

func (s *StreamCounterSet) Expired(nowMilli int64, clearRecords bool) bool

检查是否已经超时

func (*StreamCounterSet) HasInitialized

func (s *StreamCounterSet) HasInitialized(svcKey model.ServiceKey, labels string) bool

是否已经初始化

func (*StreamCounterSet) SendInitRequest

func (s *StreamCounterSet) SendInitRequest(
	initReq *rlimitV2.RateLimitInitRequest, callback serverconnector.ResponseCallBack)

发送初始化请求

func (*StreamCounterSet) SendReportRequest

func (s *StreamCounterSet) SendReportRequest(clientReportReq *rlimitV2.ClientRateLimitReportRequest) error

发送上报请求

Jump to

Keyboard shortcuts

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