master

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 17 Imported by: 0

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 Master

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

func NewMaster

func NewMaster(opts ...Option) *Master

func (*Master) Destroy

func (m *Master) Destroy()

Destroy 销毁组件

func (*Master) Init

func (m *Master) Init()

Init 初始化组件

func (*Master) Name

func (m *Master) Name() string

Name 组件名称

func (*Master) Proxy

func (m *Master) Proxy() *Proxy

Proxy 获取管理服代理

func (*Master) Start

func (m *Master) Start()

Start 启动组件

type Option

type Option func(o *options)

func WithCodec

func WithCodec(codec encoding.Codec) Option

WithCodec 设置编解码器

func WithConfigSource

func WithConfigSource(source config.Source) Option

WithConfigSource 设置配置源

func WithContext

func WithContext(ctx context.Context) Option

WithContext 设置上下文

func WithEncryptor

func WithEncryptor(encryptor crypto.Encryptor) Option

WithEncryptor 设置消息加密器

func WithID

func WithID(id string) Option

WithID 设置实例ID

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

func (p *Proxy) Broadcast(ctx context.Context, kind session.Kind, message *cluster.Message) error

Broadcast 推送广播消息

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) GetGateState added in v2.1.0

func (p *Proxy) GetGateState(ctx context.Context, gid string) (cluster.State, error)

GetGateState 获取网关状态

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

GetIP 获取客户端IP

func (*Proxy) GetName added in v2.1.0

func (p *Proxy) GetName() string

GetName 获取当前管理节点名称

func (*Proxy) GetNodeState added in v2.1.0

func (p *Proxy) GetNodeState(ctx context.Context, nid string) (cluster.State, error)

GetNodeState 获取节点状态

func (*Proxy) IsOnline added in v2.1.0

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

IsOnline 检测是否在线

func (*Proxy) LoadConfig

func (p *Proxy) LoadConfig(ctx context.Context, file string) ([]*config.Configuration, error)

LoadConfig 加载配置

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, uids []int64, message *cluster.Message) 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, uid int64, message *cluster.Message) error

Push 推送消息

func (*Proxy) SetGateState added in v2.1.0

func (p *Proxy) SetGateState(ctx context.Context, gid string, state cluster.State) error

SetGateState 设置网关状态

func (*Proxy) SetNodeState added in v2.1.0

func (p *Proxy) SetNodeState(ctx context.Context, nid string, state cluster.State) error

SetNodeState 设置节点状态

func (*Proxy) Stat

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

Stat 统计会话总数

func (*Proxy) StoreConfig

func (p *Proxy) StoreConfig(ctx context.Context, file string, content interface{}) error

StoreConfig 保存配置

Jump to

Keyboard shortcuts

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