-
Notifications
You must be signed in to change notification settings - Fork 0
/
locator.go
41 lines (35 loc) · 910 Bytes
/
locator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package locate
import (
"context"
)
type Locator interface {
// Get 获取用户定位
Get(ctx context.Context, uid int64, insKind string) (string, error)
// Set 设置用户定位
Set(ctx context.Context, uid int64, insKind string, insID string) error
// Rem 移除用户定位
Rem(ctx context.Context, uid int64, insKind string, insID string) error
// Watch 监听用户定位变化
Watch(ctx context.Context, insKinds ...string) (Watcher, error)
}
type Watcher interface {
// Next 返回用户位置列表
Next() ([]*Event, error)
// Stop 停止监听
Stop() error
}
type Event struct {
// 用户ID
UID int64 `json:"uid"`
// 事件类型
Type EventType `json:"type"`
// 实例ID
InsID string `json:"ins_id"`
// 实例类型
InsKind string `json:"ins_kind"`
}
type EventType int
const (
SetLocation EventType = iota // 设置定位
RemLocation // 移除定位
)