master

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidGID         = link.ErrInvalidGID
	ErrInvalidNID         = link.ErrInvalidNID
	ErrInvalidMessage     = link.ErrInvalidMessage
	ErrInvalidArgument    = link.ErrInvalidArgument
	ErrInvalidSessionKind = link.ErrInvalidSessionKind
	ErrNotFoundUserSource = link.ErrNotFoundUserSource
	ErrReceiveTargetEmpty = link.ErrReceiveTargetEmpty
)

Functions

This section is empty.

Types

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 Message

type Message = link.Message

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

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

Broadcast 推送广播消息

func (*Proxy) Deliver

func (p *Proxy) Deliver(ctx context.Context, uid int64, message *Message) error

Deliver 投递消息给节点处理

func (*Proxy) Disconnect

func (p *Proxy) Disconnect(ctx context.Context, uid int64, isForce bool) 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, uid int64) (string, error)

GetIP 获取客户端IP

func (*Proxy) GetMasterID

func (p *Proxy) GetMasterID() string

GetMasterID 获取当前管理节点ID

func (*Proxy) GetMasterName

func (p *Proxy) GetMasterName() string

GetMasterName 获取当前管理节点名称

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

Push 推送消息

Jump to

Keyboard shortcuts

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