locate

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: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// 用户ID
	UID int64 `json:"uid"`
	// 事件类型
	Type EventType `json:"type"`
	// 实例ID
	InsID string `json:"ins_id"`
	// 实例类型
	InsKind string `json:"ins_kind"`
	// 实例名称
	InsName string `json:"ins_name"`
}

type EventType

type EventType int
const (
	BindGate   EventType = iota + 1 // 绑定网关
	BindNode                        // 绑定节点
	UnbindGate                      // 解绑网关
	UnbindNode                      // 解绑节点
)

type Locator

type Locator interface {
	// Name 获取定位器组件名
	Name() string
	// Watch 监听用户定位变化
	Watch(ctx context.Context, kinds ...string) (Watcher, error)
	// BindGate 绑定网关
	BindGate(ctx context.Context, uid int64, gid string) error
	// BindNode 绑定节点
	BindNode(ctx context.Context, uid int64, name, nid string) error
	// UnbindGate 解绑网关
	UnbindGate(ctx context.Context, uid int64, gid string) error
	// UnbindNode 解绑节点
	UnbindNode(ctx context.Context, uid int64, name string, nid string) error
	// LocateGate 定位用户所在网关
	LocateGate(ctx context.Context, uid int64) (string, error)
	// LocateNode 定位用户所在节点
	LocateNode(ctx context.Context, uid int64, name string) (string, error)
}

type Watcher

type Watcher interface {
	// Next 返回用户位置列表
	Next() ([]*Event, error)
	// Stop 停止监听
	Stop() error
}

Jump to

Keyboard shortcuts

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