Build way-node / Test, Build, Push (push) Failing after 14s
- Go module: github.com/cedar2025/xboard-node → github.com/viaeon/way-node(307 处 import 同步) - cmd/xboard-node/ → cmd/way-node/ - install.sh: APP_NAME / INSTALL_ROOT(/etc/way-node) / BINARY_PATH / SERVICE_NAME 全部更名, 下载源与 Documentaion 指向 git.viaeon.com/admin/way-node - Makefile / Dockerfile 产物与镜像路径更名 - README 全篇重写链接 - 新增 .gitea/workflows/build.yml:容器内跑测试 + 交叉编译 + 构建镜像推 git.viaeon.com/admin/way-node 构建全程在 golang:1.26 容器里,不依赖 runner 宿主装 Go - 禁用 .github/workflows/ci.yml(依赖 ghcr.io 与 GITHUB_TOKEN,Gitea 上跑不通) 保留:xbctl 工具名(不含旧品牌)、go.sum 里上游依赖哈希
88 lines
1.8 KiB
Go
88 lines
1.8 KiB
Go
package controlplane
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/viaeon/way-node/internal/model"
|
|
)
|
|
|
|
type EventType string
|
|
|
|
const (
|
|
EventSyncConfig EventType = "sync.config"
|
|
EventSyncUsers EventType = "sync.users"
|
|
EventSyncUserDelta EventType = "sync.user.delta"
|
|
EventSyncDevices EventType = "sync.devices"
|
|
)
|
|
|
|
type Event struct {
|
|
Type EventType
|
|
Config *model.NodeSpec
|
|
Users []model.UserSpec
|
|
DeltaAction string
|
|
DeltaUsers []model.UserSpec
|
|
DeviceUsers map[int][]string
|
|
}
|
|
|
|
type StatusChange struct {
|
|
Connected bool
|
|
NeedsResync bool
|
|
}
|
|
|
|
type APIMetrics struct {
|
|
Success uint64
|
|
Failure uint64
|
|
}
|
|
|
|
type Bootstrap struct {
|
|
PushInterval int
|
|
PullInterval int
|
|
Push PushClient
|
|
Config *model.NodeSpec
|
|
Users []model.UserSpec
|
|
Mailbox *NodeMailbox
|
|
}
|
|
|
|
type Snapshot struct {
|
|
Config *model.NodeSpec
|
|
Users []model.UserSpec
|
|
}
|
|
|
|
type ReportPayload struct {
|
|
Traffic map[int][2]int64
|
|
Alive map[int][]string
|
|
Online map[int]int
|
|
CPU float64
|
|
Mem [2]uint64
|
|
Swap [2]uint64
|
|
Disk [2]uint64
|
|
Metrics map[string]interface{}
|
|
}
|
|
|
|
type PushClient interface {
|
|
Run(ctx context.Context)
|
|
IsConnected() bool
|
|
SendDeviceReport(devices map[int][]string)
|
|
}
|
|
|
|
type Source interface {
|
|
Initial(ctx context.Context, metricsFn func() map[string]interface{}, events chan<- Event, statuses chan<- StatusChange) (Bootstrap, error)
|
|
Poll(ctx context.Context) (Snapshot, error)
|
|
Discover(ctx context.Context, metricsFn func() map[string]interface{}, events chan<- Event, statuses chan<- StatusChange) (PushClient, error)
|
|
Metrics() APIMetrics
|
|
SupportsPolling() bool
|
|
SupportsDiscovery() bool
|
|
}
|
|
|
|
type Sink interface {
|
|
Report(payload ReportPayload) error
|
|
ReportDevices(push PushClient, devices map[int][]string)
|
|
SupportsReporting() bool
|
|
SupportsDeviceReports() bool
|
|
}
|
|
|
|
type ControlPlane interface {
|
|
Source
|
|
Sink
|
|
}
|