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 API credential alone.
22//! [`server`] is the composition root: the one place an implementation crate is
23//! named, and the only file here that knows there is an `OctoPrint` at all.
24//!
25//! # Images are a path, never bytes
26//!
27//! The server, the command-line program and the supervising agent all run on
28//! the one host by design, so an image answer is an absolute path on this
29//! host's own filesystem. No route this server serves answers image bytes, and
30//! no answer renders or encodes them; see [`wire::ImageAnswer`].
31//!
32//! # Restarting loses nothing
33//!
34//! The store and the session directory are the whole of the state, and
35//! [`reconcile`] is what adopts them on start.
36
37pub mod api;
38pub mod config;
39pub mod ingress;
40pub mod operations;
41pub mod reconcile;
42pub mod server;
43pub mod wire;
44
45pub use api::{ApiState, BODY_BOUND, DRAIN_BOUND, router};
46pub use config::{
47 ASSETS_DIRECTORY, ApiCredential, ApiSection, ConfigError, ConfigField, ConfigFile,
48 DEFAULT_INGRESS_ANSWER_BOUND_MS, FAN_VOCABULARY, GENERATED_CREDENTIAL_BYTES, IngressSection,
49 OBICO_POSTING_TIMEOUT_MS, OctoprintSection, REDACTED, SKILL_INSTALL, ServerConfig,
50 SharedSecret, SignInConfig, SupervisorSection, plainly_written,
51};
52pub use ingress::{IngressState, QUEUE_DEPTH, TOKEN_HEADER, TOKEN_PARAM};
53pub use operations::{
54 Answer, BESIDE_THE_ACTIONS, CONTEXT_IMAGE_PATH_FIELD, Declared, Effect, IMAGE_PATH_FIELD,
55 INGRESS_PATH, Located, MEDIA_TYPE, Method, OPERATIONS, Operation, Parameter, VERSION_PREFIX,
56 ValueKind, operation,
57};
58/// The harness identities this program can sign in, as the adapter declares
59/// them: the command-line program reads the table through this crate, which is
60/// the one edge it has to the adapter.
61pub use printobserver_oneharness::{HARNESS_DIRECTORY, HarnessSignIn, SIGN_INS};
62pub use reconcile::{
63 ReconcileStores, Reconciliation, StartupOutcome, StartupReconciliationPayload, overdue,
64 reconcile,
65};
66pub use server::{
67 API_CREDENTIAL_FILE, CLIENT_CONFIG_FILE, CONTEXT_PROGRAM, PROMPT_FILE, Ports, Running,
68 SCHEMA_FILE, Server, StartError, TURN_PROMPT, agent_config, context_command,
69};
70pub use wire::{
71 ActionAnswer, ActionBody, BodyRefusal, ContextAnswer, ErrorAnswer, HistoryAnswer, ImageAnswer,
72 IngressAnswer, ManifestAnswer, ManifestBody, PrintsAnswer, StatusAnswer, reason_of,
73};