mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 16:06:55 +08:00
update: dependencies
This commit is contained in:
57
dag/utils.go
57
dag/utils.go
@@ -1,57 +0,0 @@
|
||||
package dag
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/oarkflow/mq"
|
||||
"github.com/oarkflow/mq/storage"
|
||||
"github.com/oarkflow/mq/storage/memory"
|
||||
)
|
||||
|
||||
type taskNodeStatus struct {
|
||||
node string
|
||||
itemResults storage.IMap[string, mq.Result]
|
||||
status NodeStatus
|
||||
result mq.Result
|
||||
totalItems int
|
||||
}
|
||||
|
||||
func newNodeStatus(node string) *taskNodeStatus {
|
||||
return &taskNodeStatus{
|
||||
node: node,
|
||||
itemResults: memory.New[string, mq.Result](),
|
||||
status: Pending,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *taskNodeStatus) IsDone() bool {
|
||||
return t.itemResults.Size() >= t.totalItems
|
||||
}
|
||||
|
||||
func (t *taskNodeStatus) markAs(rs mq.Result, status NodeStatus) {
|
||||
t.result = rs
|
||||
t.status = status
|
||||
}
|
||||
|
||||
func isDAGNode(node *Node) (*DAG, bool) {
|
||||
switch node := node.processor.(type) {
|
||||
case *DAG:
|
||||
return node, true
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func (tm *TaskManager) updateTS(result *mq.Result) {
|
||||
result.CreatedAt = tm.createdAt
|
||||
result.ProcessedAt = time.Now()
|
||||
result.Latency = time.Since(tm.createdAt).String()
|
||||
}
|
||||
|
||||
func getTopic(ctx context.Context, topic string) string {
|
||||
if index, ok := mq.GetHeader(ctx, "index"); ok && index != "" {
|
||||
topic = index
|
||||
}
|
||||
return topic
|
||||
}
|
Reference in New Issue
Block a user