Skip to content

Commit

Permalink
refactor: rename Task to Node in notification handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwlin committed Jan 15, 2025
1 parent 1b70927 commit 2ee8277
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ type TaskerTaskDetail struct {
Hash string `json:"hash"`
}

type TaskNextListDetail struct {
type NodeNextListDetail struct {
TaskID uint64 `json:"task_id"`
Name string `json:"name"`
NextList []string `json:"next_list"`
}

type TaskRecognitionDetail struct {
type NodeRecognitionDetail struct {
TaskID uint64 `json:"task_id"`
RecID uint64 `json:"reco_id"`
Name string `json:"name"`
}

type TaskActionDetail struct {
type NodeActionDetail struct {
TaskID uint64 `json:"task_id"`
NodeID uint64 `json:"node_id"`
Name string `json:"name"`
Expand All @@ -80,9 +80,9 @@ type Notification interface {
OnResourceLoading(notifyType NotificationType, detail ResourceLoadingDetail)
OnControllerAction(notifyType NotificationType, detail ControllerActionDetail)
OnTaskerTask(notifyType NotificationType, detail TaskerTaskDetail)
OnTaskNextList(notifyType NotificationType, detail TaskNextListDetail)
OnTaskRecognition(notifyType NotificationType, detail TaskRecognitionDetail)
OnTaskAction(notifyType NotificationType, detail TaskActionDetail)
OnTaskNextList(notifyType NotificationType, detail NodeNextListDetail)
OnTaskRecognition(notifyType NotificationType, detail NodeRecognitionDetail)
OnTaskAction(notifyType NotificationType, detail NodeActionDetail)
OnUnknownNotification(msg, detailsJSON string)
}

Expand Down Expand Up @@ -112,18 +112,18 @@ func (n *notificationHandler) OnRawNotification(msg, detailsJSON string) {
_ = formJSON([]byte(detailsJSON), &detail)
n.notify.OnTaskerTask(notifyType, detail)
return
case strings.HasPrefix(msg, "Task.NextList"):
var detail TaskNextListDetail
case strings.HasPrefix(msg, "Node.NextList"):
var detail NodeNextListDetail
_ = formJSON([]byte(detailsJSON), &detail)
n.notify.OnTaskNextList(notifyType, detail)
return
case strings.HasPrefix(msg, "Task.Recognition"):
var detail TaskRecognitionDetail
case strings.HasPrefix(msg, "Node.Recognition"):
var detail NodeRecognitionDetail
_ = formJSON([]byte(detailsJSON), &detail)
n.notify.OnTaskRecognition(notifyType, detail)
return
case strings.HasPrefix(msg, "Task.Action"):
var detail TaskActionDetail
case strings.HasPrefix(msg, "Node.Action"):
var detail NodeActionDetail
_ = formJSON([]byte(detailsJSON), &detail)
n.notify.OnTaskAction(notifyType, detail)
return
Expand Down
6 changes: 3 additions & 3 deletions notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ func (t *testNotificationHandlerOnRawNotification) OnControllerAction(notifyType
func (t *testNotificationHandlerOnRawNotification) OnResourceLoading(notifyType NotificationType, detail ResourceLoadingDetail) {
}

func (t *testNotificationHandlerOnRawNotification) OnTaskAction(notifyType NotificationType, detail TaskActionDetail) {
func (t *testNotificationHandlerOnRawNotification) OnTaskAction(notifyType NotificationType, detail NodeActionDetail) {
}

func (t *testNotificationHandlerOnRawNotification) OnTaskNextList(notifyType NotificationType, detail TaskNextListDetail) {
func (t *testNotificationHandlerOnRawNotification) OnTaskNextList(notifyType NotificationType, detail NodeNextListDetail) {
}

func (t *testNotificationHandlerOnRawNotification) OnTaskRecognition(notifyType NotificationType, detail TaskRecognitionDetail) {
func (t *testNotificationHandlerOnRawNotification) OnTaskRecognition(notifyType NotificationType, detail NodeRecognitionDetail) {
}

func (t *testNotificationHandlerOnRawNotification) OnTaskerTask(notifyType NotificationType, detail TaskerTaskDetail) {
Expand Down

0 comments on commit 2ee8277

Please sign in to comment.