generation-aware playback statuses
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user