gate

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 25 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gate

type Gate struct {
	component.Base
	// contains filtered or unexported fields
}

func NewGate

func NewGate(opts ...Option) *Gate

NewGate 创建一个网关服务器组件实例 @param opts ...Option 配置项 @return @1 *Gate 网关服务器组件实例

func (*Gate) Close added in v2.2.3

func (g *Gate) Close()

Close 关闭节点 切换状态为Hang并刷新服务实例状态,随后等待所有在线的客户端会话自然退出(优雅等待语义)

func (*Gate) Destroy

func (g *Gate) Destroy()

Destroy 销毁组件 依次解注册服务实例、停止网络服务器与链接服务器,并取消组件上下文

func (*Gate) Init

func (g *Gate) Init()

Init 初始化组件 校验实例ID及必要组件(服务器、定位器、服务注册器)是否注入。

func (*Gate) Name

func (g *Gate) Name() string

Name 获取组件名称 @return @1 string 组件名称

func (*Gate) Start

func (g *Gate) Start()

Start 启动组件 依次启动网络服务器与内网链接服务器、注册服务实例、监听用户定位与集群实例,并打印组件信息

type Option

type Option func(o *options)

Option 网关配置项 @param o *options 配置对象

func WithAddr added in v2.3.0

func WithAddr(addr string) Option

WithAddr 设置监听地址 @param addr string 监听地址

func WithContext

func WithContext(ctx context.Context) Option

WithContext 设置上下文 @param ctx context.Context 上下文

func WithDispatch added in v2.3.0

func WithDispatch(dispatch cluster.Dispatch) Option

WithDispatch 设置无状态路由消息分发策略 @param dispatch cluster.Dispatch 分发策略

func WithExpose added in v2.3.0

func WithExpose(expose bool) Option

WithExpose 设置是否将内部通信地址暴露到公网 @param expose bool 是否暴露到公网

func WithID

func WithID(id string) Option

WithID 设置实例ID @param id string 实例ID

func WithLinkerCallTimeout added in v2.6.0

func WithLinkerCallTimeout(callTimeout time.Duration) Option

WithLinkerCallTimeout 设置RPC调用超时时间 @param callTimeout time.Duration 调用超时时间

func WithLinkerCommandQueueSize added in v2.6.0

func WithLinkerCommandQueueSize(commandQueueSize int32) Option

WithLinkerCommandQueueSize 设置消息队列大小 @param commandQueueSize int32 消息队列大小

func WithLinkerCommandWriteTimeout added in v2.6.0

func WithLinkerCommandWriteTimeout(commandWriteTimeout time.Duration) Option

WithLinkerCommandWriteTimeout 设置写入超时时间 @param commandWriteTimeout time.Duration 写入超时时间

func WithLinkerConnNum added in v2.6.0

func WithLinkerConnNum(connNum int) Option

WithLinkerConnNum 设置连接数 @param connNum int 连接数

func WithLinkerDialRetryTimes added in v2.6.0

func WithLinkerDialRetryTimes(dialRetryTimes int) Option

WithLinkerDialRetryTimes 设置内部RPC拨号重试次数 @param dialRetryTimes int 拨号重试次数

func WithLinkerDialTimeout added in v2.6.0

func WithLinkerDialTimeout(dialTimeout time.Duration) Option

WithLinkerDialTimeout 设置内部RPC拨号超时时间 @param dialTimeout time.Duration 拨号超时时间

func WithLinkerFaultRecoveryTime added in v2.6.0

func WithLinkerFaultRecoveryTime(faultRecoveryTime time.Duration) Option

WithLinkerFaultRecoveryTime 设置内部RPC故障恢复时间 @param faultRecoveryTime time.Duration 故障恢复时间

func WithLocator

func WithLocator(locator locate.Locator) Option

WithLocator 设置用户定位器 @param locator locate.Locator 用户定位器

func WithMetadata added in v2.3.0

func WithMetadata(metadata map[string]string) Option

WithMetadata 设置元数据 @param metadata map[string]string 元数据

func WithName

func WithName(name string) Option

WithName 设置实例名称 @param name string 实例名称

func WithRegistry

func WithRegistry(r registry.Registry) Option

WithRegistry 设置服务注册器 @param r registry.Registry 服务注册器

func WithServer

func WithServer(server network.Server) Option

WithServer 设置服务器 @param server network.Server 服务器

Jump to

Keyboard shortcuts

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