Add Job System (#656)

* Add Job System

* Remove testing stuff

* changelog

* plugin work

* Convert a couple more jobs

* simplify callback

* assert

* Logging changes and rendezvous perf

* changelog

* sb segment viewed job

* clear cache, and few changes

* Lint fix

* a couple more jobs

* reduce rendezvous in web server

* refactor

* Lint fix

* no message

* test shutdown

* comment

* free fields

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2025-06-17 20:13:48 -04:00
1 parent 45983a67af
commit d70a07049a
74 files changed
+1090 -298

No files matched your search

@@ -0,0 +1,31 @@
import "pkg:/source/utils/Logging.bs"
@job("ClearCacheJob")
function ExecuteJob() as void
fs = CreateObject("roFileSystem")
if fs = invalid
JobError("Failed to create roFileSystem object")
return
end if
ClearVolume(fs, "tmp:/")
ClearVolume(fs, "cachefs:/")
end function
function ClearVolume(fs as object, volume as string)
items = fs.GetDirectoryListing(volume)
for each item in items
fullpath = volume + item
' Skip logs directory
if fullpath = "cachefs:/logs"
continue for
end if
if not fs.Delete(fullpath)
LogError("Failed to delete:", fullpath)
end if
end for
LogInfo("Cleared:", volume)
end function
@@ -48,9 +48,7 @@ class LongPoller
LogInfo(`Sending long polling GET ${url}`, "ID:", socket.GetID())
#if DEBUG
? `======== curl command ========\n${m.ToCurlCommand()}\n==============================`
#end if
LogDebug(`======== curl command ========\n${m.ToCurlCommand()}\n==============================`)
message = `GET ${urlObject.path} HTTP/1.1\r\n`
message += `Host: ${urlObject.host}\r\n`
@@ -1,3 +1,4 @@
import "pkg:/source/utils/AssertUtils.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
@@ -156,9 +157,7 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
#if DEBUG
if userPrefs.__version <> m.top.__version
throw "Preferences version mismatch. Expected: " + m.top.__version + ", found: " + userPrefs.__version
end if
Assert.AreEqual(m.top.__version, userPrefs.__version, "Preferences version mismatch.")
#end if
return isDirty
end function
@@ -1,7 +1,9 @@
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
@asynctask
function SponsorBlockSegmentViewedTask(input as object)
@job("SponsorBlockSegmentViewedJob")
function ExecuteJob()
input = JobGetInput()
segmentId = input.segmentId
service = new SponsorBlock.SponsorBlockService()