Skip to main content

Crate printobserver_server

Crate printobserver_server 

Source
Expand description

printobserver-server.

Owns: the long-running service: the HTTP surface the clients call, the Obico ingress the failure detector posts to, the supervision loop’s lifecycle, the composition root that chooses which implementation backs each port, and the one event kind a restart writes — the startup reconciliation [reconcile] alone records.

May depend on: printobserver-types, the three port crates, printobserver-core, and the implementation crates — it is a composition root, so naming an implementation is its job rather than a violation.

§The shape of this crate, in four sentences

config is the one configuration file and every value it is validated against. operations is the whole public API declared once, and api builds the router by folding over it, so the set served and the set declared cannot come apart. ingress is Obico’s own endpoint, which answers before its handling completes and inside a bound this repository declares, and admits a post by its shared secret alone; every route beneath the versioned prefix admits a request by the operator’s credential or a live supervision turn’s alone, and holds it to the identity that credential authenticated. turns is where each turn’s credential is minted and held. watch drives the printer watch, and holds the printer’s push channel and the one command the watch sends. server is the composition root: the one place an implementation crate is named, and the only file here that knows there is an OctoPrint at all.

§Images are a path, never bytes

The server, the command-line program and the supervising agent all run on the one host by design, so an image answer is an absolute path on this host’s own filesystem. No route this server serves answers image bytes, and no answer renders or encodes them; see wire::ImageAnswer.

§Restarting loses nothing

The store and the session directory are the whole of the state, and [reconcile] is what adopts them on start.

Re-exports§

pub use api::Admission;
pub use api::ApiState;
pub use api::BODY_BOUND;
pub use api::Caller;
pub use api::DRAIN_BOUND;
pub use api::SPOOL_RECENT_EVENTS;
pub use api::router;
pub use config::ASSETS_DIRECTORY;
pub use config::ApiCredential;
pub use config::ApiSection;
pub use config::ConfigError;
pub use config::ConfigField;
pub use config::ConfigFile;
pub use config::CredentialVerifier;
pub use config::DEFAULT_INGRESS_ANSWER_BOUND_MS;
pub use config::DEFAULT_OBSERVATION_INTERVAL_S;
pub use config::FAN_VOCABULARY;
pub use config::GENERATED_CREDENTIAL_BYTES;
pub use config::IngressSection;
pub use config::OBICO_POSTING_TIMEOUT_MS;
pub use config::OctoprintSection;
pub use config::REDACTED;
pub use config::SKILL_INSTALL;
pub use config::ServerConfig;
pub use config::SharedSecret;
pub use config::SignInConfig;
pub use config::SpoolsSection;
pub use config::SupervisorSection;
pub use config::VERIFIER_PREFIX;
pub use config::plainly_written;
pub use events::DEFAULT_EVENTS_LIMIT;
pub use events::MAX_EVENTS_LIMIT;
pub use events::MAX_EVENTS_WAIT_S;
pub use events::Stored;
pub use ingress::IngressState;
pub use ingress::QUEUE_DEPTH;
pub use ingress::TOKEN_HEADER;
pub use ingress::TOKEN_PARAM;
pub use operations::Answer;
pub use operations::BESIDE_THE_ACTIONS;
pub use operations::COMMAND_TAG;
pub use operations::CONTEXT_IMAGE_PATH_FIELD;
pub use operations::Declared;
pub use operations::Effect;
pub use operations::IMAGE_PATH_FIELD;
pub use operations::INGRESS_PATH;
pub use operations::Located;
pub use operations::MEDIA_TYPE;
pub use operations::Method;
pub use operations::OPERATIONS;
pub use operations::Operation;
pub use operations::PRINTER_LOOK;
pub use operations::Parameter;
pub use operations::RECOVERY_STATUS;
pub use operations::SpoolCommandKind;
pub use operations::VERSION_PREFIX;
pub use operations::ValueKind;
pub use operations::command_for;
pub use operations::operation;
pub use operations::printer_wide_of;
pub use reconcile::ReconcileStores;
pub use reconcile::Reconciliation;
pub use reconcile::StartupOutcome;
pub use reconcile::StartupReconciliationPayload;
pub use reconcile::UnobservedAccounting;
pub use reconcile::overdue;
pub use reconcile::reconcile;
pub use server::API_CREDENTIAL_FILE;
pub use server::API_CREDENTIAL_VERIFIER_FILE;
pub use server::CLIENT_CONFIG_FILE;
pub use server::CONTEXT_PROGRAM;
pub use server::CREDENTIAL_ISSUE;
pub use server::CREDENTIAL_VERIFIER;
pub use server::OperatorCredential;
pub use server::PROMPT_FILE;
pub use server::Ports;
pub use server::Running;
pub use server::SCHEMA_FILE;
pub use server::Server;
pub use server::StartError;
pub use server::TURN_PROMPT;
pub use server::agent_config;
pub use server::context_command;
pub use server::operator_credential;
pub use server::plaintext_credential_warning;
pub use turns::GENERATED_TURN_CREDENTIAL_BYTES;
pub use turns::TurnBinding;
pub use turns::TurnCredentials;
pub use wire::ActionAnswer;
pub use wire::ActionBody;
pub use wire::BodyRefusal;
pub use wire::ContextAnswer;
pub use wire::ErrorAnswer;
pub use wire::EventsAnswer;
pub use wire::HistoryAnswer;
pub use wire::ImageAnswer;
pub use wire::IngressAnswer;
pub use wire::LookAnswer;
pub use wire::ManifestAnswer;
pub use wire::ManifestBody;
pub use wire::PreflightAnswer;
pub use wire::PrintEnded;
pub use wire::PrintsAnswer;
pub use wire::RecoveryAnswer;
pub use wire::RecoveryStatusAnswer;
pub use wire::SpoolAnswer;
pub use wire::SpoolCommandAnswer;
pub use wire::SpoolsAnswer;
pub use wire::StatusAnswer;
pub use wire::TimelineAnswer;
pub use wire::at_a_glance;
pub use wire::claimed_actor;
pub use wire::reason_of;
pub use wire::recovery_of;
pub use wire::spool_command_of;

Modules§

api
The HTTP surface, built by folding over the declared operations.
config
The one configuration file a running supervisor reads, and its validation.
events
The event log, followed in the order it was stored.
ingress
The one endpoint Obico’s webhook notification plugin posts to.
observation
The driver that gives every active print its periodic observation.
operations
The public operations this server serves, declared once.
reconcile
What a supervisor adopts when it starts.
server
The composition root: the one place an implementation crate is named.
turns
The credentials supervision turns authenticate with, held in memory alone.
watch
The drivers of the printer watch.
wire
The JSON a caller sends and the JSON this server answers with.

Structs§

HarnessSignIn
The harness identities this program can sign in, as the adapter declares them: the command-line program reads the table through this crate, which is the one edge it has to the adapter. One harness identity this program can sign in.

Enums§

RecoveryActionKind
One recovery action, named without its fields: what a grant names and what a refusal of an ungranted request names.

Constants§

HARNESS_DIRECTORY
The harness identities this program can sign in, as the adapter declares them: the command-line program reads the table through this crate, which is the one edge it has to the adapter. The directory under the state directory every identity’s own directory is kept in.
MAX_LOOK_WAIT_S
The longest wait one look takes, which a refusal’s advice is held to. The longest one look may wait for something to happen, in seconds.
SIGN_INS
The harness identities this program can sign in, as the adapter declares them: the command-line program reads the table through this crate, which is the one edge it has to the adapter. Every harness identity this program can sign in, and there is no other.