generation-aware playback statuses

This commit is contained in:
Dmitry Sergeev
2026-09-01 18:03:18 +03:00
parent 7a19fe0dad
commit 9bc08109fc
12 changed files with 210 additions and 41 deletions
+13
View File
@@ -1,6 +1,7 @@
package playback
import (
"context"
"fmt"
"time"
)
@@ -27,6 +28,7 @@ const (
type Status struct {
Unit Unit
State State
Generation uint64
Attempt int
FailedAttempts int
RetryIn time.Duration
@@ -35,6 +37,17 @@ type Status struct {
type StatusObserver func(Status)
type generationContextKey struct{}
func withGeneration(ctx context.Context, generation uint64) context.Context {
return context.WithValue(ctx, generationContextKey{}, generation)
}
func generationFromContext(ctx context.Context) uint64 {
generation, _ := ctx.Value(generationContextKey{}).(uint64)
return generation
}
func (u Unit) String() string {
switch u {
case UnitVideo: