Skip to content

Commit

Permalink
try add value from to message
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleLollipop committed Jul 17, 2024
1 parent c98c329 commit 750a7e6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions internal/watchdog/dog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package watchdog
import (
"context"
"fmt"
"github.com/golang/glog"
"market/internal/appservice"
"market/internal/constants"
"market/internal/event"
"market/internal/models"
"strconv"
"sync"
"time"

"github.com/golang/glog"
)

type CommonWatchDog struct {
Expand Down Expand Up @@ -238,7 +239,7 @@ func (i *CommonWatchDog) updateStatus(status, progress, op, msg string) {
return
}

GetStatusManager().UpdateModelInstallStatus(i.uid, status, progress, op, msg)
GetStatusManager().UpdateModelInstallStatus(i.uid, status, progress, op, msg, i.from)

i.status, i.progress = status, progress
}
Expand Down
3 changes: 2 additions & 1 deletion internal/watchdog/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"market/internal/appservice"
"market/internal/constants"
"market/internal/event"

//"market/internal/helm"
"market/internal/models"
"sync"
Expand Down Expand Up @@ -452,7 +453,7 @@ func (i *InstallationWatchDog) updateStatus(status, progress, op, msg string) {
return
}

GetStatusManager().UpdateInstallStatus(i.uid, status, progress, op, msg)
GetStatusManager().UpdateInstallStatus(i.uid, status, progress, op, msg, i.from)

i.status, i.progress = status, progress
}
Expand Down
16 changes: 9 additions & 7 deletions internal/watchdog/status_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type InstallOrUpgradeStatus struct {
Status string `json:"status"`
Msg string `json:"message"`
Progress string `json:"progress,omitempty"`
From string `json:"from"`
}

var once sync.Once
Expand All @@ -37,20 +38,20 @@ func GetStatusManager() *StatusManager {
return StatusManagerSvc
}

func (s *StatusManager) UpdateInstallStatus(uid, status, progress, ty, msg string) {
s.broadcastStatus(uid, status, progress, msg, ty)
func (s *StatusManager) UpdateInstallStatus(uid, status, progress, ty, msg string, from string) {
s.broadcastStatus(uid, status, progress, msg, ty, from)
}

func (s *StatusManager) UpdateUpgradeStatus(uid, status, ty, msg string) {
s.broadcastStatus(uid, status, "", msg, ty)
func (s *StatusManager) UpdateUpgradeStatus(uid, status, ty, msg string, from string) {
s.broadcastStatus(uid, status, "", msg, ty, from)
}

func (s *StatusManager) UpdateModelInstallStatus(uid, status, progress, ty, msg string) {
s.broadcastStatus(uid, status, progress, msg, ty)
func (s *StatusManager) UpdateModelInstallStatus(uid, status, progress, ty, msg string, from string) {
s.broadcastStatus(uid, status, progress, msg, ty, from)
}

// call when status changed
func (s *StatusManager) broadcastStatus(uid, status, progress, msg, t string) {
func (s *StatusManager) broadcastStatus(uid, status, progress, msg, t string, from string) {
resp := InstallOrUpgradeResp{
Code: 200,
Data: InstallOrUpgradeStatus{
Expand All @@ -59,6 +60,7 @@ func (s *StatusManager) broadcastStatus(uid, status, progress, msg, t string) {
Status: status,
Progress: progress,
Msg: msg,
From: from,
},
}

Expand Down
5 changes: 3 additions & 2 deletions internal/watchdog/upgrading.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package watchdog
import (
"context"
"fmt"
"github.com/golang/glog"
"market/internal/appservice"
"market/internal/event"
"market/internal/models"
"sync"
"time"

"github.com/golang/glog"
)

type UpgradeWatchDog struct {
Expand Down Expand Up @@ -257,7 +258,7 @@ func (i *UpgradeWatchDog) updateStatus(status, op, msg string) {
return
}

GetStatusManager().UpdateUpgradeStatus(i.uid, status, op, msg)
GetStatusManager().UpdateUpgradeStatus(i.uid, status, op, msg, i.from)

i.status = status
}
Expand Down

0 comments on commit 750a7e6

Please sign in to comment.