mesh

package
v0.0.0-...-e849032 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastArgs

type BroadcastArgs = link.BroadcastArgs

type DisconnectArgs

type DisconnectArgs = link.DisconnectArgs

type GetIPArgs

type GetIPArgs = link.GetIPArgs

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 Message

type Message = link.Message

type MulticastArgs

type MulticastArgs = link.MulticastArgs

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 WithDecryptor

func WithDecryptor(decryptor crypto.Decryptor) Option

WithDecryptor 设置消息解密器

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) AddServiceProvider

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

AddServiceProvider 添加服务提供者

func (*Proxy) BindGate

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

BindGate 绑定网关

func (*Proxy) BindNode

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

BindNode 绑定节点 单个用户只能被绑定到某一台节点服务器上,多次绑定会直接覆盖上次绑定 绑定操作会通过发布订阅方式同步到网关服务器和其他相关节点服务器上

func (*Proxy) Broadcast

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

Broadcast 推送广播消息

func (*Proxy) Disconnect

func (p *Proxy) Disconnect(ctx context.Context, args *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) GetIP

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

GetIP 获取客户端IP

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) (string, error)

LocateNode 定位用户所在节点

func (*Proxy) Multicast

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

Multicast 推送组播消息

func (*Proxy) NewServiceClient

func (p *Proxy) NewServiceClient(target string) (transport.ServiceClient, error)

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

func (*Proxy) Push

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

Push 推送消息

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, nid string) error

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

type PushArgs

type PushArgs = link.PushArgs

Jump to

Keyboard shortcuts

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