1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-07 15:06:47 +00:00

feature(manager): add LastOnline feild to worker struct

这个提交包含在:
walkerning
2016-04-25 19:05:04 +08:00
提交者 bigeagle
父节点 401b6a694e
当前提交 00eddc3066
共有 2 个文件被更改,包括 10 次插入6 次删除

查看文件

@@ -19,6 +19,7 @@ type StatusUpdateMsg struct {
// a worker, and sent from the manager to clients. // a worker, and sent from the manager to clients.
type WorkerInfoMsg struct { type WorkerInfoMsg struct {
ID string `json:"id"` ID string `json:"id"`
LastOnline time.Time `json:"last_online"`
} }
type CmdVerb uint8 type CmdVerb uint8

查看文件

@@ -2,11 +2,13 @@ package manager
import ( import (
"fmt" "fmt"
"github.com/gin-gonic/gin"
. "github.com/tuna/tunasync/internal"
"net/http" "net/http"
"sync" "sync"
"time" "time"
"github.com/gin-gonic/gin"
. "github.com/tuna/tunasync/internal"
) )
const ( const (
@@ -22,6 +24,7 @@ const (
type worker struct { type worker struct {
ID string `json:"id"` // worker name ID string `json:"id"` // worker name
Token string `json:"token"` // session token Token string `json:"token"` // session token
LastOnline time.Time `json:"last_online"` // last seen
} }
var ( var (
@@ -62,7 +65,7 @@ func (s *managerServer) listWorkers(c *gin.Context) {
} }
for _, w := range workers { for _, w := range workers {
workerInfos = append(workerInfos, workerInfos = append(workerInfos,
WorkerInfoMsg{w.ID}) WorkerInfoMsg{w.ID, w.LastOnline})
} }
c.JSON(http.StatusOK, workerInfos) c.JSON(http.StatusOK, workerInfos)
} }