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
- type Metrics
- type Options
- type Plugin
- func (p *Plugin) CancelJobRun(ctx context.Context, r *sourcev1.CancelJobRunRequest) (*sourcev1.CancelJobRunResponse, error)
- func (p *Plugin) Close()
- func (p *Plugin) Configured() Settings
- func (p *Plugin) FetchImage(ctx context.Context, r *sourcev1.FetchImageRequest, send plugin.ImageSendFunc) error
- func (p *Plugin) GetFilters(ctx context.Context, r *sourcev1.GetFiltersRequest) (*sourcev1.GetFiltersResponse, error)
- func (p *Plugin) GetInfo(context.Context, *sourcev1.GetInfoRequest) (*sourcev1.GetInfoResponse, error)
- func (p *Plugin) GetJob(ctx context.Context, r *sourcev1.GetJobRequest) (*sourcev1.GetJobResponse, error)
- func (p *Plugin) GetJobRun(ctx context.Context, r *sourcev1.GetJobRunRequest) (*sourcev1.GetJobRunResponse, error)
- func (p *Plugin) GetNetworkProfile(ctx context.Context, r *sourcev1.GetNetworkProfileRequest) (*sourcev1.GetNetworkProfileResponse, error)
- func (p *Plugin) GetPackage(ctx context.Context, r *sourcev1.GetPackageRequest) (*sourcev1.GetPackageResponse, error)
- func (p *Plugin) GetSeries(ctx context.Context, r *sourcev1.GetSeriesRequest) (*sourcev1.GetSeriesResponse, error)
- func (p *Plugin) GetSettings(ctx context.Context, r *sourcev1.GetSettingsRequest) (*sourcev1.GetSettingsResponse, error)
- func (p *Plugin) GetSettingsSchema(ctx context.Context, r *sourcev1.GetSettingsSchemaRequest) (*sourcev1.GetSettingsSchemaResponse, error)
- func (p *Plugin) GetSource(ctx context.Context, r *sourcev1.GetSourceRequest) (*sourcev1.GetSourceResponse, error)
- func (p *Plugin) Health(ctx context.Context, _ *sourcev1.HealthRequest) (*sourcev1.HealthResponse, error)
- func (p *Plugin) IconHandler() http.Handler
- func (p *Plugin) InstallPackage(ctx context.Context, r *sourcev1.InstallPackageRequest) (*sourcev1.InstallPackageResponse, error)
- func (p *Plugin) Latest(ctx context.Context, r *sourcev1.LatestRequest) (*sourcev1.LatestResponse, error)
- func (p *Plugin) ListChapters(ctx context.Context, r *sourcev1.ListChaptersRequest) (*sourcev1.ListChaptersResponse, error)
- func (p *Plugin) ListJobRuns(ctx context.Context, r *sourcev1.ListJobRunsRequest) (*sourcev1.ListJobRunsResponse, error)
- func (p *Plugin) ListJobs(ctx context.Context, r *sourcev1.ListJobsRequest) (*sourcev1.ListJobsResponse, error)
- func (p *Plugin) ListOrigins(ctx context.Context, _ *sourcev1.ListOriginsRequest) (*sourcev1.ListOriginsResponse, error)
- func (p *Plugin) ListPackages(ctx context.Context, r *sourcev1.ListPackagesRequest) (*sourcev1.ListPackagesResponse, error)
- func (p *Plugin) ListPages(ctx context.Context, r *sourcev1.ListPagesRequest) (*sourcev1.ListPagesResponse, error)
- func (p *Plugin) ListSources(ctx context.Context, r *sourcev1.ListSourcesRequest) (*sourcev1.ListSourcesResponse, error)
- func (p *Plugin) Metrics() *Metrics
- func (p *Plugin) PackageIconHandler() http.Handler
- func (p *Plugin) Popular(ctx context.Context, r *sourcev1.PopularRequest) (*sourcev1.PopularResponse, error)
- func (p *Plugin) RefreshOrigin(ctx context.Context, r *sourcev1.RefreshOriginRequest) (*sourcev1.RefreshOriginResponse, error)
- func (p *Plugin) ReloadPackage(ctx context.Context, r *sourcev1.ReloadPackageRequest) (*sourcev1.ReloadPackageResponse, error)
- func (p *Plugin) ResolveUrl(ctx context.Context, r *sourcev1.ResolveUrlRequest) (*sourcev1.ResolveUrlResponse, error)
- func (p *Plugin) RunJob(ctx context.Context, r *sourcev1.RunJobRequest) (*sourcev1.RunJobResponse, error)
- func (p *Plugin) Search(ctx context.Context, r *sourcev1.SearchRequest) (*sourcev1.SearchResponse, error)
- func (p *Plugin) SetNetworkProfile(ctx context.Context, r *sourcev1.SetNetworkProfileRequest) (*sourcev1.SetNetworkProfileResponse, error)
- func (p *Plugin) SetPackageSettings(ctx context.Context, r *sourcev1.SetPackageSettingsRequest) (*sourcev1.SetPackageSettingsResponse, error)
- func (p *Plugin) SetSettings(ctx context.Context, r *sourcev1.SetSettingsRequest) (*sourcev1.SetSettingsResponse, error)
- func (p *Plugin) SetSourceHealthCheck(ctx context.Context, r *sourcev1.SetSourceHealthCheckRequest) (*sourcev1.SetSourceHealthCheckResponse, error)
- func (p *Plugin) StoreProblem() string
- func (p *Plugin) Synced(ctx context.Context, after time.Time) error
- func (p *Plugin) UninstallPackage(ctx context.Context, r *sourcev1.UninstallPackageRequest) (*sourcev1.UninstallPackageResponse, error)
- func (p *Plugin) UpdatePackage(ctx context.Context, r *sourcev1.UpdatePackageRequest) (*sourcev1.UpdatePackageResponse, error)
- type Settings
- type StoreSetting
Constants ¶
const DefaultURL = "http://mihon-source:8902"
DefaultURL is where mihon-source runs in the usual compose setup.
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.
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 (*Plugin) CancelJobRun ¶
func (p *Plugin) CancelJobRun(ctx context.Context, r *sourcev1.CancelJobRunRequest) (*sourcev1.CancelJobRunResponse, error)
func (*Plugin) Configured ¶
Configured returns the settings in effect (secrets included), for tests and diagnostics.
func (*Plugin) FetchImage ¶
func (p *Plugin) FetchImage(ctx context.Context, r *sourcev1.FetchImageRequest, send plugin.ImageSendFunc) error
FetchImage streams the image from mihon-source. The stream is retried only while nothing has been sent yet.
func (*Plugin) GetFilters ¶
func (p *Plugin) GetFilters(ctx context.Context, r *sourcev1.GetFiltersRequest) (*sourcev1.GetFiltersResponse, error)
func (*Plugin) GetInfo ¶
func (p *Plugin) GetInfo(context.Context, *sourcev1.GetInfoRequest) (*sourcev1.GetInfoResponse, error)
func (*Plugin) GetJob ¶
func (p *Plugin) GetJob(ctx context.Context, r *sourcev1.GetJobRequest) (*sourcev1.GetJobResponse, error)
func (*Plugin) GetJobRun ¶
func (p *Plugin) GetJobRun(ctx context.Context, r *sourcev1.GetJobRunRequest) (*sourcev1.GetJobRunResponse, error)
func (*Plugin) GetNetworkProfile ¶
func (p *Plugin) GetNetworkProfile(ctx context.Context, r *sourcev1.GetNetworkProfileRequest) (*sourcev1.GetNetworkProfileResponse, error)
GetNetworkProfile asks mihon-source which profile a source uses: pushed, its own assignment or default, or none.
func (*Plugin) GetPackage ¶
func (p *Plugin) GetPackage(ctx context.Context, r *sourcev1.GetPackageRequest) (*sourcev1.GetPackageResponse, error)
func (*Plugin) GetSeries ¶
func (p *Plugin) GetSeries(ctx context.Context, r *sourcev1.GetSeriesRequest) (*sourcev1.GetSeriesResponse, error)
func (*Plugin) GetSettings ¶
func (p *Plugin) GetSettings(ctx context.Context, r *sourcev1.GetSettingsRequest) (*sourcev1.GetSettingsResponse, error)
func (*Plugin) GetSettingsSchema ¶
func (p *Plugin) GetSettingsSchema(ctx context.Context, r *sourcev1.GetSettingsSchemaRequest) (*sourcev1.GetSettingsSchemaResponse, error)
func (*Plugin) GetSource ¶
func (p *Plugin) GetSource(ctx context.Context, r *sourcev1.GetSourceRequest) (*sourcev1.GetSourceResponse, error)
func (*Plugin) Health ¶
func (p *Plugin) Health(ctx context.Context, _ *sourcev1.HealthRequest) (*sourcev1.HealthResponse, error)
Health is serving when mihon-source is; degraded when mihon-source is, or when keeping its stores and extensions failed.
func (*Plugin) IconHandler ¶
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 ¶
func (p *Plugin) InstallPackage(ctx context.Context, r *sourcev1.InstallPackageRequest) (*sourcev1.InstallPackageResponse, error)
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 (p *Plugin) Latest(ctx context.Context, r *sourcev1.LatestRequest) (*sourcev1.LatestResponse, error)
func (*Plugin) ListChapters ¶
func (p *Plugin) ListChapters(ctx context.Context, r *sourcev1.ListChaptersRequest) (*sourcev1.ListChaptersResponse, error)
func (*Plugin) ListJobRuns ¶
func (p *Plugin) ListJobRuns(ctx context.Context, r *sourcev1.ListJobRunsRequest) (*sourcev1.ListJobRunsResponse, error)
func (*Plugin) ListJobs ¶
func (p *Plugin) ListJobs(ctx context.Context, r *sourcev1.ListJobsRequest) (*sourcev1.ListJobsResponse, error)
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 (p *Plugin) ListOrigins(ctx context.Context, _ *sourcev1.ListOriginsRequest) (*sourcev1.ListOriginsResponse, error)
func (*Plugin) ListPackages ¶
func (p *Plugin) ListPackages(ctx context.Context, r *sourcev1.ListPackagesRequest) (*sourcev1.ListPackagesResponse, error)
func (*Plugin) ListPages ¶
func (p *Plugin) ListPages(ctx context.Context, r *sourcev1.ListPagesRequest) (*sourcev1.ListPagesResponse, error)
func (*Plugin) ListSources ¶
func (p *Plugin) ListSources(ctx context.Context, r *sourcev1.ListSourcesRequest) (*sourcev1.ListSourcesResponse, error)
func (*Plugin) PackageIconHandler ¶
PackageIconHandler serves GET /v1/packages/{packageId}/icon: the installed extension's icon, or the icon its store lists.
func (*Plugin) Popular ¶
func (p *Plugin) Popular(ctx context.Context, r *sourcev1.PopularRequest) (*sourcev1.PopularResponse, error)
func (*Plugin) RefreshOrigin ¶
func (p *Plugin) RefreshOrigin(ctx context.Context, r *sourcev1.RefreshOriginRequest) (*sourcev1.RefreshOriginResponse, error)
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 ¶
func (p *Plugin) ReloadPackage(ctx context.Context, r *sourcev1.ReloadPackageRequest) (*sourcev1.ReloadPackageResponse, error)
ReloadPackage reloads an installed extension from its file in mihon-source.
func (*Plugin) ResolveUrl ¶
func (p *Plugin) ResolveUrl(ctx context.Context, r *sourcev1.ResolveUrlRequest) (*sourcev1.ResolveUrlResponse, error)
func (*Plugin) RunJob ¶
func (p *Plugin) RunJob(ctx context.Context, r *sourcev1.RunJobRequest) (*sourcev1.RunJobResponse, error)
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 (p *Plugin) Search(ctx context.Context, r *sourcev1.SearchRequest) (*sourcev1.SearchResponse, error)
func (*Plugin) SetNetworkProfile ¶
func (p *Plugin) SetNetworkProfile(ctx context.Context, r *sourcev1.SetNetworkProfileRequest) (*sourcev1.SetNetworkProfileResponse, error)
SetNetworkProfile forwards the host's profile for a source to mihon-source, which applies it to the source's requests.
func (*Plugin) SetPackageSettings ¶
func (p *Plugin) SetPackageSettings(ctx context.Context, r *sourcev1.SetPackageSettingsRequest) (*sourcev1.SetPackageSettingsResponse, error)
SetPackageSettings sets an installed package's languages in mihon-source.
func (*Plugin) SetSettings ¶
func (p *Plugin) SetSettings(ctx context.Context, r *sourcev1.SetSettingsRequest) (*sourcev1.SetSettingsResponse, error)
func (*Plugin) SetSourceHealthCheck ¶
func (p *Plugin) SetSourceHealthCheck(ctx context.Context, r *sourcev1.SetSourceHealthCheckRequest) (*sourcev1.SetSourceHealthCheckResponse, error)
SetSourceHealthCheck turns mihon-source's scheduled checks of a source on or off, and returns the source.
func (*Plugin) StoreProblem ¶
StoreProblem is the last reconcile's problem, for tests and Health.
func (*Plugin) UninstallPackage ¶
func (p *Plugin) UninstallPackage(ctx context.Context, r *sourcev1.UninstallPackageRequest) (*sourcev1.UninstallPackageResponse, error)
UninstallPackage removes the package; one that isn't installed is a no-op.
func (*Plugin) UpdatePackage ¶
func (p *Plugin) UpdatePackage(ctx context.Context, r *sourcev1.UpdatePackageRequest) (*sourcev1.UpdatePackageResponse, error)
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 ¶
StoreSetting is one store to keep added.