harmonytask: remember machine
This commit is contained in:
parent
1a9e3cfd71
commit
98099cc3f8
1
lib/harmony/harmonydb/sql/20231113.sql
Normal file
1
lib/harmony/harmonydb/sql/20231113.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE harmony_task_history ADD COLUMN completed_by_host_and_port varchar(300) NOT NULL;
|
@ -106,6 +106,7 @@ type TaskEngine struct {
|
|||||||
follows map[string][]followStruct
|
follows map[string][]followStruct
|
||||||
lastFollowTime time.Time
|
lastFollowTime time.Time
|
||||||
lastCleanup atomic.Value
|
lastCleanup atomic.Value
|
||||||
|
hostAndPort string
|
||||||
}
|
}
|
||||||
type followStruct struct {
|
type followStruct struct {
|
||||||
f func(TaskID, AddTaskFunc) (bool, error)
|
f func(TaskID, AddTaskFunc) (bool, error)
|
||||||
@ -129,13 +130,14 @@ func New(
|
|||||||
}
|
}
|
||||||
ctx, grace := context.WithCancel(context.Background())
|
ctx, grace := context.WithCancel(context.Background())
|
||||||
e := &TaskEngine{
|
e := &TaskEngine{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
grace: grace,
|
grace: grace,
|
||||||
db: db,
|
db: db,
|
||||||
reg: reg,
|
reg: reg,
|
||||||
ownerID: reg.Resources.MachineID, // The current number representing "hostAndPort"
|
ownerID: reg.Resources.MachineID, // The current number representing "hostAndPort"
|
||||||
taskMap: make(map[string]*taskTypeHandler, len(impls)),
|
taskMap: make(map[string]*taskTypeHandler, len(impls)),
|
||||||
follows: make(map[string][]followStruct),
|
follows: make(map[string][]followStruct),
|
||||||
|
hostAndPort: hostnameAndPort,
|
||||||
}
|
}
|
||||||
e.lastCleanup.Store(time.Now())
|
e.lastCleanup.Store(time.Now())
|
||||||
for _, c := range impls {
|
for _, c := range impls {
|
||||||
|
@ -198,8 +198,8 @@ func (h *taskTypeHandler) recordCompletion(tID TaskID, workStart time.Time, done
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = tx.Exec(`INSERT INTO harmony_task_history
|
_, err = tx.Exec(`INSERT INTO harmony_task_history
|
||||||
(task_id, name, posted, work_start, work_end, result, err)
|
(task_id, name, posted, work_start, work_end, result, by_host_and_port, err)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7)`, tID, h.Name, postedTime, workStart, workEnd, done, result)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)`, tID, h.Name, postedTime, workStart, workEnd, done, h.TaskEngine.hostAndPort, result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("could not write history: %w", err)
|
return false, fmt.Errorf("could not write history: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user