MCPcopy Create free account
hub / github.com/QuantumNous/new-api / RenewSystemTaskLock

Function RenewSystemTaskLock

model/system_task.go:331–346  ·  view source on GitHub ↗
(taskID string, lockedBy string, lockUntil int64)

Source from the content-addressed store, hash-verified

329}
330
331func RenewSystemTaskLock(taskID string, lockedBy string, lockUntil int64) error {
332 now := common.GetTimestamp()
333 result := DB.Model(&SystemTaskLock{}).
334 Where("task_id = ? AND locked_by = ? AND locked_until >= ?", taskID, lockedBy, now).
335 Updates(map[string]any{
336 "locked_until": lockUntil,
337 "updated_at": now,
338 })
339 if result.Error != nil {
340 return result.Error
341 }
342 if result.RowsAffected == 0 {
343 return ErrSystemTaskLockLost
344 }
345 return nil
346}
347
348func MarkSystemTaskLeaseExpired(taskID string) error {
349 result := DB.Model(&SystemTask{}).

Callers 2

runWithLeaseHeartbeatFunction · 0.92
TestRenewSystemTaskLockFunction · 0.85

Calls 1

GetTimestampFunction · 0.92

Tested by 1

TestRenewSystemTaskLockFunction · 0.68