Help us shape the future of Go! Take the 2026 Go Developer Survey

locate

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 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:"insID"`
	// 实例类型
	InsKind string `json:"insKind"`
	// 实例名称
	InsName string `json:"insName"`
}

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