feat(web): Processor port + in-flight ProcessingSet on App
Add the seam for immediate web-triggered summarization. Processor is the optional single-video summarize port (nil = queue-only, unchanged behaviour); ProcessingSet is an ephemeral, concurrency-safe set of in-flight (user,video) ids so a status endpoint can show progress until the summary lands. State is deliberately in-memory only — the DB holds the durable truth across restarts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package web
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestProcessingSetAddHasRemove(t *testing.T) {
|
||||
var s ProcessingSet // zero value is usable
|
||||
|
||||
key := processingKey("user-1", "video-1")
|
||||
if s.Has(key) {
|
||||
t.Fatal("fresh set must not report a key as in-flight")
|
||||
}
|
||||
|
||||
s.Add(key)
|
||||
if !s.Has(key) {
|
||||
t.Fatal("Add must mark the key in-flight")
|
||||
}
|
||||
|
||||
// A different user with the same video id is a distinct key.
|
||||
if s.Has(processingKey("user-2", "video-1")) {
|
||||
t.Fatal("keys must be scoped by user")
|
||||
}
|
||||
|
||||
s.Remove(key)
|
||||
if s.Has(key) {
|
||||
t.Fatal("Remove must clear the key")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user