class PdnsVersionService (View source)

Detects and caches the connected PowerDNS server version so admins can see it in the UI and so error reports include it without a manual lookup.

Cached in the store the caller hands in (the session, in practice) with a 5-minute TTL to avoid an extra API round-trip on every request. Detection failures are swallowed - callers must treat the absence of a cached value as "version unknown", not as an error.

Constants

private SESSION_KEY

private TTL_SECONDS

private RETRY_SECONDS

Methods

__construct(PowerdnsApiClient $apiClient, LoggerInterface|null $logger, SessionInterface $cache)

No description

array|null
detect()

Fetch server info if the cached copy is stale, then return it.

static void
refreshFromConfig(ConfigurationInterface $config, LoggerInterface $logger, SessionInterface $cache)

Refresh the cache from the configured PowerDNS API, at most once a minute per cache. A no-op when no API is configured; failures leave the previous entry in place, so callers never see an error from here.

array|null
getCached()

Return the cached server info without making a network call.

static array|null
getCachedInfo(SessionInterface $cache, bool $allowExpired = false)

Static accessor for the cached server info, for callers that don't want to construct the service just to read what IndexController already detected.

Details

__construct(PowerdnsApiClient $apiClient, LoggerInterface|null $logger, SessionInterface $cache)

No description

Parameters

PowerdnsApiClient $apiClient
LoggerInterface|null $logger
SessionInterface $cache

Where the server info and retry stamp live, the session in practice

array|null detect()

Fetch server info if the cached copy is stale, then return it.

Return Value

array|null

static void refreshFromConfig(ConfigurationInterface $config, LoggerInterface $logger, SessionInterface $cache)

Refresh the cache from the configured PowerDNS API, at most once a minute per cache. A no-op when no API is configured; failures leave the previous entry in place, so callers never see an error from here.

Parameters

ConfigurationInterface $config
LoggerInterface $logger
SessionInterface $cache

Normally the request's session

Return Value

void

array|null getCached()

Return the cached server info without making a network call.

Return Value

array|null

static array|null getCachedInfo(SessionInterface $cache, bool $allowExpired = false)

Static accessor for the cached server info, for callers that don't want to construct the service just to read what IndexController already detected.

Returns null when the cached entry is older than TTL_SECONDS so that capability-driven UI does not silently follow a stale version after a PowerDNS upgrade or downgrade for the rest of the session - callers that get null fall through to detect() and refresh the cache. Pass $allowExpired to read the old entry anyway once that refresh has failed.

Parameters

SessionInterface $cache

Normally the request's session

bool $allowExpired

Return Value

array|null