Documentation
¶
Overview ¶
Package meta connects the server to the Panelarr metadata service, which the library needs: every work is created from one of its entries. It keeps the connection settings, checks that the service is usable and wraps the catalogue calls.
Index ¶
- Variables
- func CoverOf(images []*metadatav1.Image) *metadatav1.Image
- func RatingName(r metadatav1.ContentRating) string
- func StatusName(s metadatav1.EntryStatus) string
- func TypeName(t metadatav1.EntryType) string
- func Unreachable(err error) bool
- type BadFilterError
- type BadJobParamsError
- type BadRequestError
- type Check
- type Client
- type Conn
- type DuplicateQuery
- type Error
- type JobDisabledError
- type JobRunningError
- type Provider
- type ProviderUnavailableError
- type Query
- type Service
- func (s *Service) Assignments(ctx context.Context) ([]*metav1.Assignment, error)
- func (s *Service) Browse(ctx context.Context, q Query, v Viewer) (*metav1.BrowseResponse, error)
- func (s *Service) CancelJobRun(ctx context.Context, runID string) (*metav1.JobRunSummary, error)
- func (s *Service) Check(ctx context.Context, fresh bool) Check
- func (s *Service) Client() (*Client, error)
- func (s *Service) ConfirmDuplicate(ctx context.Context, id int64, keep, note string) (*metav1.DuplicatePair, string, error)
- func (s *Service) CoverURL(ctx context.Context, id string, v Viewer) (string, error)
- func (s *Service) DismissDuplicate(ctx context.Context, id int64, note string) (*metav1.DuplicatePair, error)
- func (s *Service) Duplicate(ctx context.Context, id int64) (*metav1.DuplicatePair, error)
- func (s *Service) Duplicates(ctx context.Context, q DuplicateQuery) (*metav1.ListDuplicatesResponse, error)
- func (s *Service) GetEntry(ctx context.Context, id, language string, v Viewer) (*metav1.Entry, error)
- func (s *Service) Health(ctx context.Context) (*metav1.GetHealthResponse, error)
- func (s *Service) HideUnknown(ctx context.Context) bool
- func (s *Service) Job(ctx context.Context, id string) (*metav1.Job, error)
- func (s *Service) JobRun(ctx context.Context, runID string) (*metav1.JobRun, error)
- func (s *Service) JobRuns(ctx context.Context, id string, status metav1.JobRunStatus, pageSize int32, ...) ([]*metav1.JobRunSummary, string, error)
- func (s *Service) Jobs(ctx context.Context) ([]*metav1.Job, error)
- func (s *Service) Judge(ctx context.Context) (*metav1.DecisionJudgeSettings, error)
- func (s *Service) Load(ctx context.Context) error
- func (s *Service) Providers(ctx context.Context) ([]*metav1.Provider, error)
- func (s *Service) PushProfile(ctx context.Context, provider string, p *metadatav1.NetworkProfile) error
- func (s *Service) PutJudge(ctx context.Context, st *metav1.DecisionJudgeSettings) (*metav1.DecisionJudgeSettings, error)
- func (s *Service) PutSearchEngine(ctx context.Context, st *metav1.SearchEngineSettings) (*metav1.SearchEngineSettings, *metav1.SearchEngineStatus, error)
- func (s *Service) ReadyCheck(ctx context.Context) error
- func (s *Service) RefreshEntry(ctx context.Context, id string) (*metav1.RefreshEntryResponse, error)
- func (s *Service) ReopenDuplicate(ctx context.Context, id int64) (*metav1.DuplicatePair, error)
- func (s *Service) ResetJudge(ctx context.Context) (*metav1.DecisionJudgeSettings, error)
- func (s *Service) ResetSearchEngine(ctx context.Context) (*metav1.SearchEngineSettings, *metav1.SearchEngineStatus, error)
- func (s *Service) RunJob(ctx context.Context, id string, params map[string]string) (*metav1.JobRunSummary, error)
- func (s *Service) RunSync(ctx context.Context, provider, kind string) (string, error)
- func (s *Service) Save(ctx context.Context, conn Conn) (Check, error)
- func (s *Service) Search(ctx context.Context, q Query, v Viewer) (*metav1.SearchResponse, error)
- func (s *Service) SearchEngine(ctx context.Context) (*metav1.SearchEngineSettings, *metav1.SearchEngineStatus, error)
- func (s *Service) SetHTTPClient(hc *http.Client)
- func (s *Service) Status(ctx context.Context) Status
- func (s *Service) SyncRun(ctx context.Context, id string) (*metav1.SyncRun, error)
- func (s *Service) SyncRuns(ctx context.Context, provider string, pageSize int32, token string) ([]*metav1.SyncRun, string, error)
- func (s *Service) TestJudge(ctx context.Context, st *metav1.DecisionJudgeSettings) (*metav1.TestDecisionJudgeResponse, error)
- func (s *Service) TestSearchEngine(ctx context.Context, st *metav1.SearchEngineSettings) (bool, string, error)
- type Status
- type Viewer
Constants ¶
This section is empty.
Variables ¶
var ( ErrPairNotFound = errors.New("meta: no such duplicate pair") // ErrPairDecided is a decision a pair's state doesn't allow (e.g. // reopening a confirmed pair). ErrPairDecided = errors.New("meta: the pair can't take that decision now") )
Duplicate review errors.
var ( ErrJobNotFound = errors.New("meta: no such job or run") ErrJobNotRunning = errors.New("meta: the run has finished") ErrJobNotCancelable = errors.New("meta: this job can't be cancelled") )
Job errors.
var ( ErrNotConfigured = errors.New("meta: not connected") ErrManagedByEnv = errors.New("meta: the connection is set by PANELARR_META_URL and can't be changed here") ErrCheckFailed = errors.New("meta: the metadata service can't be used with these settings") ErrInvalidURL = errors.New("meta: the URL must be http(s)://host[:port]") )
Errors callers map to responses.
var ErrNotFound = errors.New("meta: entry not found")
ErrNotFound is an entry that doesn't exist or that the viewer may not see.
var ErrRunNotFound = errors.New("meta: no such sync run")
ErrRunNotFound is a sync run meta doesn't know.
Functions ¶
func CoverOf ¶
func CoverOf(images []*metadatav1.Image) *metadatav1.Image
CoverOf picks an entry's cover: the first cover image, else the first image.
func RatingName ¶
func RatingName(r metadatav1.ContentRating) string
RatingName turns an entry's rating into the API's name: safe, suggestive, erotic, pornographic or unknown.
func StatusName ¶
func StatusName(s metadatav1.EntryStatus) string
func TypeName ¶
func TypeName(t metadatav1.EntryType) string
TypeName and StatusName turn entry types and statuses into the API's names ("manga", "releasing"), or "" when unknown.
func Unreachable ¶
Unreachable reports whether err means the metadata service couldn't be reached at all (no answer: connection refused, DNS, timeout), as opposed to the service answering with an error.
Types ¶
type BadFilterError ¶
type BadFilterError struct{ Field, Value string }
BadFilterError is a filter value the catalogue doesn't know.
func (*BadFilterError) Error ¶
func (e *BadFilterError) Error() string
type BadJobParamsError ¶
type BadJobParamsError struct{ Reason string }
BadJobParamsError is a run meta refused for its params.
func (*BadJobParamsError) Error ¶
func (e *BadJobParamsError) Error() string
type BadRequestError ¶
type BadRequestError struct{ Reason string }
BadRequestError is a request meta refused, with its reason.
func (*BadRequestError) Error ¶
func (e *BadRequestError) Error() string
type Check ¶
type Check struct {
Configured bool
Reachable bool
KeyValid bool
AdminScope bool
Providers []Provider
// Ready: reachable, an admin key, and a provider with entries. Until
// then the server is degraded and nothing can be added.
Ready bool
// Problem says what to do when not ready.
Problem string
CheckedAt time.Time
}
Check is the result of checking the metadata service.
type Client ¶
type Client struct {
Meta metav1connect.MetaServiceClient
Admin metav1connect.MetaAdminServiceClient
Clients metav1connect.MetaClientsServiceClient
Jobs metav1connect.MetaJobsServiceClient
// Integrations takes network profiles pushed by the server.
Integrations metav1connect.MetaIntegrationsServiceClient
// Duplicates is the duplicate entries review.
Duplicates metav1connect.MetaDuplicatesServiceClient
}
Client talks to one metadata service over gRPC, the canonical wire for Panelarr services.
type Conn ¶
type Conn struct {
// URL is the service's base URL, e.g. "http://meta:8901".
URL string
// APIKey is a key with the admin scope.
APIKey string
}
Conn is how to reach the metadata service.
type DuplicateQuery ¶
type DuplicateQuery struct {
Status metav1.DuplicateStatus
MinScore float64
JudgedOnly bool
PageSize int32
PageToken string
}
DuplicateQuery narrows the review list.
type Error ¶
Error is a failed call to the metadata service, so callers that also talk to source plugins can tell whose error it is.
type JobDisabledError ¶
type JobDisabledError struct{ Reason string }
JobDisabledError is a job that can't run now, and why.
func (*JobDisabledError) Error ¶
func (e *JobDisabledError) Error() string
type JobRunningError ¶
type JobRunningError struct{ RunID string }
JobRunningError is a job that is running already.
func (*JobRunningError) Error ¶
func (e *JobRunningError) Error() string
type ProviderUnavailableError ¶
type ProviderUnavailableError struct {
}
ProviderUnavailableError is the metadata service answering that one of its provider plugins can't be reached. The service itself is fine.
func (*ProviderUnavailableError) Error ¶
func (e *ProviderUnavailableError) Error() string
type Query ¶
type Query struct {
Text string
Types []string
Statuses []string
Genres []string
YearFrom int32
YearTo int32
Sort string // popularity, rating, updated, year, title, relevance
Reverse bool
Language string
PageSize int32
PageToken string
}
Query is a catalogue search or browse.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds the connection to the metadata service.
func NewService ¶
NewService returns the service. env, when its URL is set, is the connection and can't be changed in the app.
func (*Service) Assignments ¶
Assignments lists every provider meta has, with the network profile the server pushed to it (password left out) and whether its plugin takes profiles.
func (*Service) CancelJobRun ¶
CancelJobRun cancels a running run.
func (*Service) Check ¶
Check checks the current connection. Without fresh, a recent result is reused.
func (*Service) ConfirmDuplicate ¶
func (s *Service) ConfirmDuplicate(ctx context.Context, id int64, keep, note string) (*metav1.DuplicatePair, string, error)
ConfirmDuplicate merges a pair into one entry (it can't be undone): keep is "a", "b" or empty for the more popular one. It returns the pair and the entry they are now.
func (*Service) CoverURL ¶
CoverURL returns the source URL of an entry's cover, if v may see the entry. Covers seen in recent lists are remembered, so showing a page of results doesn't cost one lookup per cover.
func (*Service) DismissDuplicate ¶
func (s *Service) DismissDuplicate(ctx context.Context, id int64, note string) (*metav1.DuplicatePair, error)
DismissDuplicate records that a pair are different works.
func (*Service) Duplicates ¶
func (s *Service) Duplicates(ctx context.Context, q DuplicateQuery) (*metav1.ListDuplicatesResponse, error)
Duplicates lists suspected duplicate pairs.
func (*Service) GetEntry ¶
func (s *Service) GetEntry(ctx context.Context, id, language string, v Viewer) (*metav1.Entry, error)
GetEntry returns one entry, or ErrNotFound when it doesn't exist or its rating is above what v may see.
func (*Service) HideUnknown ¶
HideUnknown reports whether users are kept from entries and sources without a known content rating.
func (*Service) JobRuns ¶
func (s *Service) JobRuns(ctx context.Context, id string, status metav1.JobRunStatus, pageSize int32, token string) ([]*metav1.JobRunSummary, string, error)
JobRuns lists a job's runs, newest first.
func (*Service) Providers ¶
Providers lists meta's providers with their plugin, health, schedules, record counts and last runs.
func (*Service) PushProfile ¶
func (s *Service) PushProfile(ctx context.Context, provider string, p *metadatav1.NetworkProfile) error
PushProfile gives a provider its network profile; nil removes the pushed one (meta's own settings apply again).
func (*Service) PutJudge ¶
func (s *Service) PutJudge(ctx context.Context, st *metav1.DecisionJudgeSettings) (*metav1.DecisionJudgeSettings, error)
PutJudge saves decision model settings; an empty API key keeps meta's.
func (*Service) PutSearchEngine ¶
func (s *Service) PutSearchEngine(ctx context.Context, st *metav1.SearchEngineSettings) (*metav1.SearchEngineSettings, *metav1.SearchEngineStatus, error)
PutSearchEngine saves search engine settings; an empty API key keeps the stored one.
func (*Service) ReadyCheck ¶
ReadyCheck is the readiness check: it fails while the service isn't ready, which marks the server degraded.
func (*Service) RefreshEntry ¶
func (s *Service) RefreshEntry(ctx context.Context, id string) (*metav1.RefreshEntryResponse, error)
RefreshEntry asks every provider of an entry for fresh data now.
func (*Service) ReopenDuplicate ¶
ReopenDuplicate takes back a dismissal.
func (*Service) ResetJudge ¶
ResetJudge forgets the admin's settings (meta's configuration applies).
func (*Service) ResetSearchEngine ¶
func (s *Service) ResetSearchEngine(ctx context.Context) (*metav1.SearchEngineSettings, *metav1.SearchEngineStatus, error)
ResetSearchEngine forgets the admin's settings (meta's configuration applies again).
func (*Service) RunJob ¶
func (s *Service) RunJob(ctx context.Context, id string, params map[string]string) (*metav1.JobRunSummary, error)
RunJob starts one of meta's jobs now.
func (*Service) RunSync ¶
RunSync starts a sync of a provider in the metadata service and returns the run's ID.
func (*Service) Save ¶
Save tests conn and, when the service is reachable and the key has the admin scope, stores it (the key encrypted) and switches to it. A service without provider data is saved too: the check says what's missing.
func (*Service) SearchEngine ¶
func (s *Service) SearchEngine(ctx context.Context) (*metav1.SearchEngineSettings, *metav1.SearchEngineStatus, error)
SearchEngine returns the search engine settings in force and its state.
func (*Service) SetHTTPClient ¶
SetHTTPClient replaces the HTTP client (tests).
func (*Service) SyncRuns ¶
func (s *Service) SyncRuns(ctx context.Context, provider string, pageSize int32, token string) ([]*metav1.SyncRun, string, error)
SyncRuns lists sync runs, newest first, of one provider or all.
func (*Service) TestJudge ¶
func (s *Service) TestJudge(ctx context.Context, st *metav1.DecisionJudgeSettings) (*metav1.TestDecisionJudgeResponse, error)
TestJudge asks the model about a made-up pair without saving.
func (*Service) TestSearchEngine ¶
func (s *Service) TestSearchEngine(ctx context.Context, st *metav1.SearchEngineSettings) (bool, string, error)
TestSearchEngine tries search engine settings without saving them.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package metatest runs a fake metadata service for tests: the real gRPC API over cleartext HTTP/2, with keys, providers and entries set by the test.
|
Package metatest runs a fake metadata service for tests: the real gRPC API over cleartext HTTP/2, with keys, providers and entries set by the test. |