mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-16 16:45:07 +00:00
06c364d29a
Five more facts for whatever watches an installation from outside the container, and one seam so a package can add its own. Storage is the one that was about to be wrong. It is summed from the rows that record it, not measured on the volume: measuring the directory was correct until external storage went live and silently stopped being, since an upload that resolves to a bucket leaves nothing on disk to measure. A figure taken from the filesystem freezes while the account keeps filling, and on a managed installation that figure is what a customer is shown and billed against. `by_disk` splits the same sum by where the bytes went, which is the only way to see what is still sitting locally from before a cutover. Trashed files are excluded because they hold no bytes -- File's deleted hook takes them. Health is what a container cannot show from outside. A queue worker dying is invisible to anything watching the process: it is still up, and zips quietly stop building while mail stops going out. Same for a deploy whose migrations failed -- the application answers every request and is a schema behind. An unreachable queue reports null rather than zero, because an unreachable Redis is not an empty queue and reading the second as the first is how a dead worker looks healthy. The two-factor enforcement setting is echoed back the way EnforceTwoFactor reads it, fallback included: reporting a stricter rule than the middleware actually applies would be worse than reporting none. And ResolvingInstallationStatus, so a package can report what core cannot know. The managed storage backend and the version of the package providing it live in cloud-modules, which this repository must not reference, and a platform that writes eight environment variables only ever knows what it asked for. Those came apart once: a bucket provisioned, a token minted, every variable correct, and an image whose copy of the package predated the module that reads them. Files went to local disk with the configuration sitting perfectly right beside them. Two shapes are cast to objects deliberately. An empty PHP array encodes as [], so an installation with no packages -- or holding no files -- would answer a map-shaped field with a list, and a reader unmarshalling it breaks on the day it happens to be empty rather than the day it is written. There is a test for each. Requested by the ProjectSend Cloud control plane, whose storage figure stops growing the moment a tenant's uploads start reaching the bucket.
49 lines
1.9 KiB
PHP
49 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Platform\Installation\Events;
|
|
|
|
/**
|
|
* "What else is worth knowing about this installation?" — asked once,
|
|
* by `projectsend:status`, of whatever packages happen to be installed.
|
|
*
|
|
* Core cannot answer for them. A managed installation's storage backend
|
|
* and the version of the package providing it live in
|
|
* projectsend/cloud-modules, which this repository is public and must
|
|
* not reference; a control plane still has to be able to observe them,
|
|
* and observing is exactly what that command is for.
|
|
*
|
|
* The distinction this exists to preserve: a platform writing eight
|
|
* environment variables knows what it *asked for*. Only the installation
|
|
* knows what actually loaded. Those came apart once — a bucket was
|
|
* provisioned and a token minted while the container ignored both,
|
|
* because its image predated the module that reads them, and the
|
|
* configuration sitting beside the files looked perfectly correct.
|
|
*
|
|
* Listened to by *string* class name from a package, same as every
|
|
* other hook here — see docs/extension-points-architecture.md.
|
|
*/
|
|
final class ResolvingInstallationStatus
|
|
{
|
|
/**
|
|
* What listeners have reported, keyed by name.
|
|
*
|
|
* Scalars and null only: this is serialised to JSON for a reader
|
|
* that is not this application, and a shape it has to walk is a
|
|
* shape it has to be taught. Null is a real answer — "asked, and
|
|
* the thing is not here" — and it must survive to the document
|
|
* rather than being dropped, for the reason the whole file's null
|
|
* handling exists: absent and "nothing to report" are different
|
|
* facts, and a reader that cannot tell them apart guesses.
|
|
*
|
|
* @var array<string, string|int|bool|null>
|
|
*/
|
|
public array $facts = [];
|
|
|
|
public function report(string $key, string|int|bool|null $value): void
|
|
{
|
|
$this->facts[$key] = $value;
|
|
}
|
|
}
|