-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtypes.go
More file actions
116 lines (98 loc) · 3.91 KB
/
Copy pathtypes.go
File metadata and controls
116 lines (98 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
import (
"sync"
)
type contextKey string
const (
cacheOnlyModeKey contextKey = "cacheOnlyMode"
rateLimitTypeKey contextKey = "rateLimitType"
apiKeyRequiredForFreshKey contextKey = "apiKeyRequiredForFresh"
apiKeyAuthenticatedKey contextKey = "apiKeyAuthenticated"
apiKeyInvalidKey contextKey = "apiKeyInvalid"
)
// NoLyricsSentinel is stored as TTML content to permanently mark a track as having no lyrics.
// Unlike negative cache entries (which expire), this is stored in the positive cache and persists indefinitely.
const NoLyricsSentinel = "__NO_LYRICS__"
// InFlightRequest tracks concurrent requests for the same query
type InFlightRequest struct {
wg sync.WaitGroup
result string
score float64
language string
isRTL bool
err error
}
// CachedLyrics stores lyrics with track metadata
type CachedLyrics struct {
TTML string `json:"ttml"`
TrackDurationMs int `json:"trackDurationMs"`
Score float64 `json:"score,omitempty"`
Language string `json:"language,omitempty"`
IsRTL bool `json:"isRTL,omitempty"`
}
// NegativeCacheEntry stores info about failed lyrics lookups
type NegativeCacheEntry struct {
Reason string `json:"reason"`
Timestamp int64 `json:"timestamp"`
ReleaseDate string `json:"releaseDate,omitempty"` // Track release date if known (ISO 8601)
HasTimeSyncedLyricsKnown bool `json:"hasTimeSyncedLyricsKnown,omitempty"` // true if hasTimeSyncedLyrics was present in API response
}
// SongMetadata stores rich metadata about a song for future querying and proxy revalidation
type SongMetadata struct {
CacheKey string `json:"cacheKey"`
// External identifiers
VideoIDs []string `json:"videoIds,omitempty"`
AppleTrackID string `json:"appleTrackId,omitempty"`
ISRC string `json:"isrc,omitempty"`
// Key parsed fields (indexed for lookups)
TrackName string `json:"trackName"`
ArtistName string `json:"artistName"`
AlbumName string `json:"albumName,omitempty"`
DurationMs int `json:"durationMs,omitempty"`
ReleaseDate string `json:"releaseDate,omitempty"`
// Raw Apple Music attributes JSON for future querying
RawAttributes string `json:"rawAttributes,omitempty"`
// Timestamps
FirstSeen int64 `json:"firstSeen"`
LastUpdated int64 `json:"lastUpdated"`
}
// MigrationJobStatus represents the status of an async migration job
type MigrationJobStatus string
const (
JobStatusPending MigrationJobStatus = "pending"
JobStatusRunning MigrationJobStatus = "running"
JobStatusCompleted MigrationJobStatus = "completed"
JobStatusFailed MigrationJobStatus = "failed"
)
// MigrationJob tracks an async cache migration
type MigrationJob struct {
ID string `json:"id"`
Status MigrationJobStatus `json:"status"`
StartedAt int64 `json:"started_at"`
CompletedAt int64 `json:"completed_at,omitempty"`
Recompress bool `json:"recompress"`
Progress MigrationProgress `json:"progress"`
Result *MigrationResult `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
// MigrationProgress tracks migration progress
type MigrationProgress struct {
TotalKeys int `json:"total_keys"`
ProcessedKeys int `json:"processed_keys"`
Percent int `json:"percent"`
}
// MigrationResult contains the final migration results
type MigrationResult struct {
Migrated int `json:"migrated"`
Recompressed int `json:"recompressed"`
Deleted int `json:"deleted"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
BytesSaved int64 `json:"bytes_saved"`
MigratedKeys []string `json:"migrated_keys,omitempty"`
}
// migrationJobs stores active and completed migration jobs
var migrationJobs = struct {
sync.RWMutex
jobs map[string]*MigrationJob
}{jobs: make(map[string]*MigrationJob)}