Documentation
¶
Overview ¶
Package releasepolicy evaluates the same bounded, declarative rules for playback, release search and unsaved previews. No client or UI dependencies.
Index ¶
- func Better(a, b Result) bool
- func ChannelSourceAllowed(r core.Release, duration time.Duration, renditionKbps int) bool
- func Conflict(rules []core.ReleaseRule) string
- func ConflictWith(rules []core.ReleaseRule, lookup FieldLookup) string
- func Equivalent(a, b Result) bool
- func IsExternalFieldID(id string) bool
- func UsesOriginalAudio(rules []core.ReleaseRule) bool
- type Context
- type Explanation
- type FieldLookup
- type FieldSpec
- type Policy
- type Result
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Better ¶
Better gives explicit fallback tiers precedence, then ordered preferences. Equal policy results leave TRaSH, health and source routing order untouched.
func ChannelSourceAllowed ¶
ChannelSourceAllowed is the owner's hard source envelope for virtual TV. Network headroom never admits 4K, remuxes or disc images. Ordinary encodes reserve 25% of the rendition budget for variable bitrate and cheap playout. Unknown individual file size is checked again after opening a pack/link.
func Conflict ¶
func Conflict(rules []core.ReleaseRule) string
Conflict describes required rules that cannot be true of one release. Empty means no such conflict. Disabled rules, exceptions and fallbacks are left alone: those can still be satisfied.
func ConflictWith ¶ added in v0.3.3
func ConflictWith(rules []core.ReleaseRule, lookup FieldLookup) string
ConflictWith is Conflict with a caller-supplied field table; it is what the console-served descriptors declare as single-value that decides a conflict, so plugin single-value fields conflict the same way.
func Equivalent ¶
Equivalent reports the same fallback tier and the same ordered preference vector. Health racing may overtake only an equivalent candidate; a fallback must not pass a still-valid primary.
func IsExternalFieldID ¶ added in v0.3.3
IsExternalFieldID reports whether id is plugin-namespaced ("plugin:<id>/<key>"), the shape every plugin rule field takes.
func UsesOriginalAudio ¶
func UsesOriginalAudio(rules []core.ReleaseRule) bool
UsesOriginalAudio reports whether evaluation of these rules needs the catalogue original language. Disabled rules do not.
Types ¶
type Context ¶
type Context struct {
OriginalLanguage string
ExternalMatch func(core.Release, core.ReleaseCondition) (bool, bool)
}
Context is evidence that belongs to the title, not the release. OriginalLanguage is the catalogue title's original language (Title.Language) when the caller has that title. An empty value means the comparison is unavailable. It is never a guessed language, and it is not part of the profile selection hash or the search cache key.
type Explanation ¶
type FieldLookup ¶ added in v0.3.3
FieldLookup resolves a condition field id to its spec. The resolver builds one from the descriptor registry; nil means the built-in table.
type FieldSpec ¶ added in v0.3.3
type FieldSpec struct {
ID string
// ValueClass: text, choice, language, number or none
// (extend.RuleValue* values, kept as strings to avoid a cycle).
ValueClass string
Operators []string
DefaultOperator string
SingleValue bool
// External marks a plugin-contributed field: it compiles when its
// descriptor is registered and evaluates Unknown until the plugin
// hot path (WS9h) supplies matches.
External bool
}
FieldSpec describes one rule field for validation and for the extend descriptor registry (WS1a). The console renders its condition picker from descriptors built on these specs, so this table is the one Go source for which fields exist and how their values validate.
func BuiltinFields ¶ added in v0.3.3
func BuiltinFields() []FieldSpec
BuiltinFields returns the built-in rule fields in console picker order.
func LookupBuiltinField ¶ added in v0.3.3
LookupBuiltinField is the default FieldLookup.
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
func Compile ¶
func Compile(rules []core.ReleaseRule) (*Policy, error)
Compile validates rules against the built-in field table. Plugin-namespaced fields compile structurally (operator and value shape) and evaluate Unknown; see CompileWith for registry-checked compilation.
func CompileWith ¶ added in v0.3.3
func CompileWith(rules []core.ReleaseRule, lookup FieldLookup) (*Policy, error)
CompileWith is Compile with a caller-supplied field table, built by the resolver from the descriptor registry so registered plugin fields compile under their declared operators and value class. A nil lookup uses the built-in table. Behaviour for built-in fields is identical either way.
type Result ¶
type Result struct {
Rejected bool `json:"rejected"`
Unknown bool `json:"unknown"`
Fallback int `json:"fallback"`
Preferences []int `json:"preferences"`
Explanations []Explanation `json:"explanations"`
}
func (Result) PreferRule ¶ added in v0.3.0
PreferRule returns 1 when the prefer rule with id matched, 0 otherwise.