provider

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package provider resolves effective third-party API keys at lookup time. Precedence, first match wins:

  1. DB override (settings table, set via the Settings UI)
  2. Baked-in default from config.DefaultTMDBKey / DefaultTraktClientID
  3. Empty string — callers should treat this as "no key configured" and return a 503-level error.

See pilot's identically-named package for the originating pattern.

Index

Constants

View Source
const (
	TMDB  = "tmdb"
	Trakt = "trakt"
)

Provider identifiers — used as DB keys in the settings table and as API path segments.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver reads and writes provider API key overrides in the settings table and falls back to the ldflag-baked defaults when no override is set.

func NewResolver

func NewResolver(store Store) *Resolver

NewResolver constructs a Resolver backed by the given settings store.

func (*Resolver) ClearOverride

func (r *Resolver) ClearOverride(ctx context.Context, name string) error

ClearOverride removes any stored override for the named provider.

func (*Resolver) EffectiveKey

func (r *Resolver) EffectiveKey(ctx context.Context, name string) (string, Source, error)

EffectiveKey returns the key that should actually be used for API calls to the named provider. Empty string means "not configured".

func (*Resolver) HasOverride

func (r *Resolver) HasOverride(ctx context.Context, name string) (bool, error)

HasOverride reports whether an override is currently stored.

func (*Resolver) Preview

func (r *Resolver) Preview(ctx context.Context, name string) (string, Source, error)

Preview returns a redacted representation of the effective key.

func (*Resolver) SetOverride

func (r *Resolver) SetOverride(ctx context.Context, name, value string) error

SetOverride persists a user-supplied key as the override.

type Source

type Source string

Source reports where an effective key came from.

const (
	SourceOverride Source = "override"
	SourceDefault  Source = "default"
)

type Store

type Store interface {
	GetSetting(ctx context.Context, key string) (string, error)
	SetSetting(ctx context.Context, arg db.SetSettingParams) error
	DeleteSetting(ctx context.Context, key string) error
}

Store is the subset of the DB queries interface this package needs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL