feat: implement configurable background jobs and toggle flags
Introduce environment variables to globally and individually control background jobs: - `WARPBOX_JOBS_ENABLED` to toggle all background workers. - `WARPBOX_CLEANUP_ENABLED` to toggle the expired box cleanup job. - `WARPBOX_THUMBNAIL_ENABLED` to toggle the thumbnail generation job. Refactor background tasks into a dedicated `backend/libs/jobs` package, allowing jobs to be registered, scheduled, and conditionally run based on the new configuration flags. Additionally, update the default maximum upload size in `.env.example` to 16GB and document the new settings in the README.
This commit is contained in:
@@ -32,3 +32,20 @@ func TestParseMegabytesRejectsInvalidValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvBool(t *testing.T) {
|
||||
t.Setenv("WARPBOX_TEST_BOOL", "false")
|
||||
if got := envBool("WARPBOX_TEST_BOOL", true); got {
|
||||
t.Fatalf("envBool() = true, want false")
|
||||
}
|
||||
|
||||
t.Setenv("WARPBOX_TEST_BOOL", "1")
|
||||
if got := envBool("WARPBOX_TEST_BOOL", false); !got {
|
||||
t.Fatalf("envBool() = false, want true")
|
||||
}
|
||||
|
||||
t.Setenv("WARPBOX_TEST_BOOL", "not-a-bool")
|
||||
if got := envBool("WARPBOX_TEST_BOOL", true); !got {
|
||||
t.Fatalf("envBool() did not fall back to true")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user