printobserver_server/lib.rs
1//! `printobserver-server`.
2//!
3//! Owns: the long-running service: the HTTP surface the clients call, the
4//! `Obico` ingress the failure detector posts to, the supervision loop's
5//! lifecycle, the composition root that chooses which implementation backs
6//! each port, and the one event kind a restart writes — the startup
7//! reconciliation [`reconcile`] alone records.
8//!
9//! May depend on: `printobserver-types`, the three port crates,
10//! `printobserver-core`, and the implementation crates — it is a composition
11//! root, so naming an implementation is its job rather than a violation.
12//!
13//! # The shape of this crate, in four sentences
14//!
15//! [`config`] is the one configuration file and every value it is validated
16//! against. [`operations`] is the whole public API declared once, and [`api`]
17//! builds the router by folding over it, so the set served and the set declared
18//! cannot come apart. [`ingress`] is `Obico`'s own endpoint, which answers
19//! before its handling completes and inside a bound this repository declares,
20//! and admits a post by its shared secret alone; every route beneath the
21//! versioned prefix admits a request by the operator's credential or a live
22//! supervision turn's alone, and holds it to the identity that credential
23//! authenticated. [`turns`] is where each turn's credential is minted and held.
24//! [`watch`] drives the printer watch, and holds the printer's push channel
25//! and the one command the watch sends. [`server`] is the composition root: the one place an implementation crate is
26//! named, and the only file here that knows there is an `OctoPrint` at all.
27//!
28//! # Images are a path, never bytes
29//!
30//! The server, the command-line program and the supervising agent all run on
31//! the one host by design, so an image answer is an absolute path on this
32//! host's own filesystem. No route this server serves answers image bytes, and
33//! no answer renders or encodes them; see [`wire::ImageAnswer`].
34//!
35//! # Restarting loses nothing
36//!
37//! The store and the session directory are the whole of the state, and
38//! [`reconcile`] is what adopts them on start.
39
40pub mod api;
41pub mod config;
42pub mod events;
43pub mod ingress;
44pub mod observation;
45pub mod operations;
46pub mod reconcile;
47pub mod server;
48pub mod turns;
49pub mod watch;
50pub mod wire;
51
52pub use api::{Admission, ApiState, BODY_BOUND, Caller, DRAIN_BOUND, SPOOL_RECENT_EVENTS, router};
53pub use config::{
54 ASSETS_DIRECTORY, ApiCredential, ApiSection, ConfigError, ConfigField, ConfigFile,
55 CredentialVerifier, DEFAULT_INGRESS_ANSWER_BOUND_MS, DEFAULT_OBSERVATION_INTERVAL_S,
56 FAN_VOCABULARY, GENERATED_CREDENTIAL_BYTES, IngressSection, OBICO_POSTING_TIMEOUT_MS,
57 OctoprintSection, REDACTED, SKILL_INSTALL, ServerConfig, SharedSecret, SignInConfig,
58 SpoolsSection, SupervisorSection, VERIFIER_PREFIX, plainly_written,
59};
60pub use events::{DEFAULT_EVENTS_LIMIT, MAX_EVENTS_LIMIT, MAX_EVENTS_WAIT_S, Stored};
61pub use ingress::{IngressState, QUEUE_DEPTH, TOKEN_HEADER, TOKEN_PARAM};
62pub use operations::{
63 Answer, BESIDE_THE_ACTIONS, COMMAND_TAG, CONTEXT_IMAGE_PATH_FIELD, Declared, Effect,
64 IMAGE_PATH_FIELD, INGRESS_PATH, Located, MEDIA_TYPE, Method, OPERATIONS, Operation,
65 PRINTER_LOOK, Parameter, RECOVERY_STATUS, RecoveryActionKind, SpoolCommandKind, VERSION_PREFIX,
66 ValueKind, command_for, operation, printer_wide_of,
67};
68/// The harness identities this program can sign in, as the adapter declares
69/// them: the command-line program reads the table through this crate, which is
70/// the one edge it has to the adapter.
71pub use printobserver_oneharness::{HARNESS_DIRECTORY, HarnessSignIn, SIGN_INS};
72pub use reconcile::{
73 ReconcileStores, Reconciliation, StartupOutcome, StartupReconciliationPayload,
74 UnobservedAccounting, overdue, reconcile,
75};
76pub use server::{
77 API_CREDENTIAL_FILE, API_CREDENTIAL_VERIFIER_FILE, CLIENT_CONFIG_FILE, CONTEXT_PROGRAM,
78 CREDENTIAL_ISSUE, CREDENTIAL_VERIFIER, OperatorCredential, PROMPT_FILE, Ports, Running,
79 SCHEMA_FILE, Server, StartError, TURN_PROMPT, agent_config, context_command,
80 operator_credential, plaintext_credential_warning,
81};
82pub use turns::{GENERATED_TURN_CREDENTIAL_BYTES, TurnBinding, TurnCredentials};
83pub use wire::{
84 ActionAnswer, ActionBody, BodyRefusal, ContextAnswer, ErrorAnswer, EventsAnswer, HistoryAnswer,
85 ImageAnswer, IngressAnswer, LookAnswer, ManifestAnswer, ManifestBody, PreflightAnswer,
86 PrintEnded, PrintsAnswer, RecoveryAnswer, RecoveryStatusAnswer, SpoolAnswer,
87 SpoolCommandAnswer, SpoolsAnswer, StatusAnswer, TimelineAnswer, at_a_glance, claimed_actor,
88 reason_of, recovery_of, spool_command_of,
89};