mihon

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package mihon is source-mihon: a Panelarr source plugin that serves the sources of a mihon-source instance. Every source API call goes through to mihon-source over gRPC (with retries while it can't be reached), network profiles the host pushes are forwarded, and the extension stores and extensions named in the plugin's configuration are kept in mihon-source.

Index

Constants

View Source
const DefaultURL = "http://mihon-source:8902"

DefaultURL is where mihon-source runs in the usual compose setup.

View Source
const ID = "source-mihon"

ID is the plugin's stable identifier.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics are the plugin's Prometheus metrics. Labels are bounded: the RPC, the status code and the error reason.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics registers the metrics on a registry of their own, with the Go runtime and process collectors.

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler serves the metrics in the Prometheus text format.

type Options

type Options struct {
	Log *slog.Logger
	// Managed says the host started the plugin as a child process, so it
	// can't fetch paths relative to the plugin's address.
	Managed bool
	// Initial is applied as the configuration before serving, e.g. from the
	// environment. The host's SetConfig replaces it.
	Initial map[string]any
	// SyncEvery is how often the stores and extensions are reconciled with
	// mihon-source. Default 15 minutes.
	SyncEvery time.Duration
}

Options configure New.

type Plugin

type Plugin struct {
	*plugin.PluginConfig
	// contains filtered or unexported fields
}

Plugin is source-mihon.

func New

func New(ctx context.Context, opts Options) (*Plugin, error)

New returns the plugin, configured with the defaults (and opts.Initial).

func (*Plugin) Close

func (p *Plugin) Close()

Close stops background work and connections.

func (*Plugin) Configured

func (p *Plugin) Configured() Settings

Configured returns the settings in effect (secrets included), for tests and diagnostics.

func (*Plugin) FetchImage

FetchImage streams the image from mihon-source. The stream is retried only while nothing has been sent yet.

func (*Plugin) GetFilters

func (*Plugin) GetJob

func (*Plugin) GetJobRun

func (*Plugin) GetNetworkProfile

GetNetworkProfile asks mihon-source which profile a source uses: pushed, its own assignment or default, or none.

func (*Plugin) GetPackage

func (*Plugin) GetSeries

func (*Plugin) GetSettings

func (*Plugin) GetSource

func (*Plugin) Health

Health is serving when mihon-source is; degraded when mihon-source is, or when keeping its stores and extensions failed.

func (*Plugin) IconHandler

func (p *Plugin) IconHandler() http.Handler

IconHandler serves GET /v1/sources/{sourceId}/icon, the path mihon-source gives as a source's icon URL, by fetching it from mihon-source. Hosts fetch icon paths relative to the plugin with the plugin's own key.

func (*Plugin) InstallPackage

InstallPackage installs the package from its best offer (or the origin asked for). The version already installed is a no-op; mihon-source keeps a cancelled install all-or-nothing.

func (*Plugin) Latest

func (*Plugin) ListJobRuns

func (*Plugin) ListJobs

ListJobs lists the plugin's jobs, then mihon-source's. When mihon-source can't be reached, only the plugin's are listed.

func (*Plugin) ListOrigins

func (*Plugin) ListPages

func (*Plugin) ListSources

func (*Plugin) Metrics

func (p *Plugin) Metrics() *Metrics

Metrics returns the plugin's metrics.

func (*Plugin) PackageIconHandler

func (p *Plugin) PackageIconHandler() http.Handler

PackageIconHandler serves GET /v1/packages/{packageId}/icon: the installed extension's icon, or the icon its store lists.

func (*Plugin) Popular

func (*Plugin) RefreshOrigin

RefreshOrigin refreshes a store in mihon-source. A store that can't be fetched or used fails with STORE_FETCH_FAILED or STORE_INVALID.

func (*Plugin) ReloadPackage

ReloadPackage reloads an installed extension from its file in mihon-source.

func (*Plugin) ResolveUrl

func (*Plugin) RunJob

RunJob starts a run. mihon-source records its runs as started by the plugin's API client; on_behalf_of only reaches the plugin's own runs.

func (*Plugin) Search

func (*Plugin) SetNetworkProfile

SetNetworkProfile forwards the host's profile for a source to mihon-source, which applies it to the source's requests.

func (*Plugin) SetPackageSettings

SetPackageSettings sets an installed package's languages in mihon-source.

func (*Plugin) SetSettings

func (*Plugin) SetSourceHealthCheck

SetSourceHealthCheck turns mihon-source's scheduled checks of a source on or off, and returns the source.

func (*Plugin) StoreProblem

func (p *Plugin) StoreProblem() string

StoreProblem is the last reconcile's problem, for tests and Health.

func (*Plugin) Synced

func (p *Plugin) Synced(ctx context.Context, after time.Time) error

Synced waits until a reconcile has finished after t, for tests.

func (*Plugin) UninstallPackage

UninstallPackage removes the package; one that isn't installed is a no-op.

func (*Plugin) UpdatePackage

UpdatePackage installs the newest supported offer when it's newer than the installed version; up to date is a no-op.

type Settings

type Settings struct {
	URL    string
	APIKey string
	// Langs are the languages to offer sources in; empty means all.
	Langs      []string
	Stores     []StoreSetting
	Extensions []string
	// HealthInterval is health_checks.interval: "", "off", "default" or a
	// number and unit (m, h, d).
	HealthInterval string
	// HealthSample is health_checks.sample; 0 means all.
	HealthSample int
}

Settings is the configuration in effect.

type StoreSetting

type StoreSetting struct {
	URL         string
	Fingerprint string
}

StoreSetting is one store to keep added.

Jump to

Keyboard shortcuts

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