mesh

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HookHandler added in v2.1.0

type HookHandler func(proxy *Proxy)

type Mesh

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

func NewMesh

func NewMesh(opts ...Option) *Mesh

func (*Mesh) Destroy

func (m *Mesh) Destroy()

Destroy 销毁网关服务器

func (*Mesh) Init

func (m *Mesh) Init()

Init 初始化节点

func (*Mesh) Name

func (m *Mesh) Name() string

Name 组件名称

func (*Mesh) Proxy

func (m *Mesh) Proxy() *Proxy

Proxy 获取节点代理

func (*Mesh) Start

func (m *Mesh) Start()

Start 启动

type Option

type Option func(o *options)

func WithCodec

func WithCodec(codec encoding.Codec) Option

WithCodec 设置编解码器

func WithContext

func WithContext(ctx context.Context) Option

WithContext 设置上下文

func WithEncryptor

func WithEncryptor(encryptor crypto.Encryptor) Option

WithEncryptor 设置消息加密器

func WithLocator

func WithLocator(locator locate.Locator) Option

WithLocator 设置定位器

func WithName

func WithName(name string) Option

WithName 设置实例名称

func WithRegistry

func WithRegistry(r registry.Registry) Option

WithRegistry 设置服务注册器

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 设置RPC调用超时时间

func WithTransporter

func WithTransporter(transporter transport.Transporter) Option

WithTransporter 设置消息传输器

type Proxy

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

func (*Proxy) AddHookListener added in v2.1.0

func (p *Proxy) AddHookListener(hook cluster.Hook, handler HookHandler)

AddHookListener 添加钩子监听器

func (*Proxy) AddServiceProvider

func (p *Proxy) AddServiceProvider(name string, desc interface{}, provider interface{})

AddServiceProvider 添加服务提供者

func (*Proxy) AskGate added in v2.1.0

func (p *Proxy) AskGate(ctx context.Context, gid string, uid int64) (string, bool, error)

AskGate 检测用户是否在给定的网关上

func (*Proxy) AskNode added in v2.1.0

func (p *Proxy) AskNode(ctx context.Context, uid int64, name, nid string) (string, bool, error)

AskNode 检测用户是否在给定的节点上

func (*Proxy) BindGate

func (p *Proxy) BindGate(ctx context.Context, gid string, cid, uid int64) error

BindGate 绑定网关

func (*Proxy) BindNode

func (p *Proxy) BindNode(ctx context.Context, uid int64, name, nid string) error

BindNode 绑定节点 单个用户可以绑定到多个节点服务器上,相同名称的节点服务器只能绑定一个,多次绑定会到相同名称的节点服务器会覆盖之前的绑定。 绑定操作会通过发布订阅方式同步到网关服务器和其他相关节点服务器上。

func (*Proxy) Broadcast

func (p *Proxy) Broadcast(ctx context.Context, args *cluster.BroadcastArgs) error

Broadcast 推送广播消息

func (*Proxy) Deliver added in v2.1.0

func (p *Proxy) Deliver(ctx context.Context, args *cluster.DeliverArgs) error

Deliver 投递消息给节点处理

func (*Proxy) Disconnect

func (p *Proxy) Disconnect(ctx context.Context, args *cluster.DisconnectArgs) error

Disconnect 断开连接

func (*Proxy) FetchGateList

func (p *Proxy) FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)

FetchGateList 拉取网关列表

func (*Proxy) FetchNodeList

func (p *Proxy) FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)

FetchNodeList 拉取节点列表

func (*Proxy) GetID added in v2.1.0

func (p *Proxy) GetID() string

GetID 获取当前实例ID

func (*Proxy) GetIP

func (p *Proxy) GetIP(ctx context.Context, args *cluster.GetIPArgs) (string, error)

GetIP 获取客户端IP

func (*Proxy) GetName added in v2.1.0

func (p *Proxy) GetName() string

GetName 获取当前实例名称

func (*Proxy) IsOnline added in v2.1.0

func (p *Proxy) IsOnline(ctx context.Context, args *cluster.IsOnlineArgs) (bool, error)

IsOnline 检测是否在线

func (*Proxy) LocateGate

func (p *Proxy) LocateGate(ctx context.Context, uid int64) (string, error)

LocateGate 定位用户所在网关

func (*Proxy) LocateNode

func (p *Proxy) LocateNode(ctx context.Context, uid int64, name string) (string, error)

LocateNode 定位用户所在节点

func (*Proxy) Multicast

func (p *Proxy) Multicast(ctx context.Context, args *cluster.MulticastArgs) error

Multicast 推送组播消息

func (*Proxy) NewMeshClient added in v2.1.0

func (p *Proxy) NewMeshClient(target string) (transport.Client, error)

NewMeshClient 新建微服务客户端 target参数可分为两种模式: 服务直连模式: direct://127.0.0.1:8011 服务发现模式: discovery://service_name

func (*Proxy) Push

func (p *Proxy) Push(ctx context.Context, args *cluster.PushArgs) error

Push 推送消息

func (*Proxy) Stat

func (p *Proxy) Stat(ctx context.Context, kind session.Kind) (int64, error)

Stat 统计会话总数

func (*Proxy) UnbindGate

func (p *Proxy) UnbindGate(ctx context.Context, uid int64) error

UnbindGate 解绑网关

func (*Proxy) UnbindNode

func (p *Proxy) UnbindNode(ctx context.Context, uid int64, name, nid string) error

UnbindNode 解绑节点 解绑时会对对应名称的节点服务器进行解绑,解绑时会对解绑节点ID进行校验,不匹配则解绑失败。 解绑操作会通过发布订阅方式同步到网关服务器和其他相关节点服务器上。

Jump to

Keyboard shortcuts

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