plex

package
v2.0.37 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-2.0, GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package plex adapts the shared github.com/cplieger/plexapi client for the exporter. The transport — header-borne token, refuse-all redirects, same-origin path guard, CA pinning, transparent retry with Retry-After honoring, bounded reads — is the library's; this package owns the exporter's construction shape (env-derived CA path, retry counter metric) and re-exports the error types the startup classifier keys on.

Package plex provides the HTTP client used to talk to a Plex Media Server, including retry semantics, the ErrNotFound sentinel, and the HTTPStatusError type used by callers to distinguish 4xx from 5xx responses.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = plexapi.ErrNotFound

ErrNotFound is the library's 404 sentinel, re-exported so call sites and the Plex Pass graceful-degradation path keep reading plex.ErrNotFound.

Functions

This section is empty.

Types

type Client

type Client struct {
	*plexapi.Client
	// contains filtered or unexported fields
}

Client is the exporter's Plex client: the library client plus the cumulative retry counter surfaced as plex_http_retries_total.

func NewClient

func NewClient(serverURL, token, caCertPath string) (*Client, error)

NewClient parses serverURL and returns a Client. When caCertPath is non-empty, the PEM file at that path is pinned as the sole TLS trust anchor (verification stays ON) — the recommended setup for a self-signed Plex. An empty caCertPath uses the OS trust store (right for *.plex.direct and plain http URLs).

func NewClientFromHTTP added in v2.0.30

func NewClientFromHTTP(serverURL, token string, hc *http.Client) (*Client, error)

NewClientFromHTTP builds a Client over a caller-supplied *http.Client — the test-fixture path (httptest servers). No retry transport or counter is installed; Retries() reports 0.

func (*Client) GetContainerSize

func (c *Client) GetContainerSize(ctx context.Context, path string) (int64, error)

GetContainerSize reports the totalSize of the container at path, used for type-filtered library counts. Kept under its historical name; the implementation is the library's ContainerTotalSize.

func (*Client) Retries

func (c *Client) Retries() int64

Retries returns the cumulative number of HTTP retry attempts across all requests on this client (the plex_http_retries_total metric).

type HTTPStatusError

type HTTPStatusError = plexapi.StatusError

HTTPStatusError is the library's non-200 error, aliased so the startup fatal-vs-transient classifier keeps matching with errors.As.

Jump to

Keyboard shortcuts

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