node

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

func NewBuilder

func NewBuilder(opts *Options) *Builder

func (*Builder) Build

func (b *Builder) Build(addr string) (*Client, error)

Build 构建客户端

type Client

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

func NewClient

func NewClient(cli *client.Client) *Client

func (*Client) Deliver

func (c *Client) Deliver(ctx context.Context, cid, uid int64, message []byte) error

Deliver 投递消息

func (*Client) GetState

func (c *Client) GetState(ctx context.Context) (cluster.State, error)

GetState 获取状态

func (*Client) SetState

func (c *Client) SetState(ctx context.Context, state cluster.State) error

SetState 设置状态

func (*Client) Trigger

func (c *Client) Trigger(ctx context.Context, event cluster.Event, cid, uid int64) error

Trigger 触发事件

type Options

type Options struct {
	InsID   string       // 实例ID
	InsKind cluster.Kind // 实例类型
}

type Provider

type Provider interface {
	// Trigger 触发事件
	Trigger(ctx context.Context, gid string, cid, uid int64, event cluster.Event) error
	// Deliver 投递消息
	Deliver(ctx context.Context, gid, nid string, cid, uid int64, message []byte) error
	// GetState 获取状态
	GetState() (cluster.State, error)
	// SetState 设置状态
	SetState(state cluster.State) error
}

type Server

type Server struct {
	*server.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr string, provider Provider) (*Server, error)

Jump to

Keyboard shortcuts

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