feat(config): add events section (session timeout + skip rule thresholds)
This commit is contained in:
@@ -36,3 +36,12 @@ subsonic:
|
|||||||
# apiKey (OpenSubsonic) and falls back to u+t+s token auth.
|
# apiKey (OpenSubsonic) and falls back to u+t+s token auth.
|
||||||
# Env: SMARTMUSIC_SUBSONIC_ALLOW_PLAINTEXT_PASSWORD
|
# Env: SMARTMUSIC_SUBSONIC_ALLOW_PLAINTEXT_PASSWORD
|
||||||
allow_plaintext_password: false
|
allow_plaintext_password: false
|
||||||
|
|
||||||
|
events:
|
||||||
|
# Idle gap (minutes) between play_events that closes a play_session and
|
||||||
|
# starts a new one. Spec §6.
|
||||||
|
session_timeout_minutes: 30
|
||||||
|
# Skip rule (spec §6): a play counts as a SKIP if completion ratio is below
|
||||||
|
# this threshold AND duration played (ms) is below the next threshold.
|
||||||
|
skip_max_completion_ratio: 0.5
|
||||||
|
skip_max_duration_played_ms: 30000
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type Config struct {
|
|||||||
Auth AuthConfig `yaml:"auth"`
|
Auth AuthConfig `yaml:"auth"`
|
||||||
Library LibraryConfig `yaml:"library"`
|
Library LibraryConfig `yaml:"library"`
|
||||||
Subsonic SubsonicConfig `yaml:"subsonic"`
|
Subsonic SubsonicConfig `yaml:"subsonic"`
|
||||||
|
Events EventsConfig `yaml:"events"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
@@ -55,11 +56,23 @@ type SubsonicConfig struct {
|
|||||||
AllowPlaintextPassword bool `yaml:"allow_plaintext_password"`
|
AllowPlaintextPassword bool `yaml:"allow_plaintext_password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventsConfig governs play-event ingestion: session window, skip rule.
|
||||||
|
type EventsConfig struct {
|
||||||
|
SessionTimeoutMinutes int `yaml:"session_timeout_minutes"`
|
||||||
|
SkipMaxCompletionRatio float64 `yaml:"skip_max_completion_ratio"`
|
||||||
|
SkipMaxDurationPlayedMs int `yaml:"skip_max_duration_played_ms"`
|
||||||
|
}
|
||||||
|
|
||||||
func Default() Config {
|
func Default() Config {
|
||||||
return Config{
|
return Config{
|
||||||
Server: ServerConfig{Address: ":4533"},
|
Server: ServerConfig{Address: ":4533"},
|
||||||
Database: DatabaseConfig{URL: ""},
|
Database: DatabaseConfig{URL: ""},
|
||||||
Log: LogConfig{Level: "info", Format: "text"},
|
Log: LogConfig{Level: "info", Format: "text"},
|
||||||
|
Events: EventsConfig{
|
||||||
|
SessionTimeoutMinutes: 30,
|
||||||
|
SkipMaxCompletionRatio: 0.5,
|
||||||
|
SkipMaxDurationPlayedMs: 30000,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user