Skip to main content

Module vtn

Module vtn 

Source
Available on crate feature vtn only.
Expand description

The VTN server.

Vtn::builder assembles storage, authentication and a notification transport into an axum::Router. The builder is a typestate: build() exists only once storage() has been called, so a VTN with no backing store is a compile error rather than a start-up panic.

Configuration, the endpoint surface and deployment shapes: https://hupe1980.github.io/openadr/docs/vtn/.

use openadr::vtn::{Vtn, auth::{StaticTokenAuth}, store::MemoryStorage};
let vtn = Vtn::builder()
    .storage(MemoryStorage::shared())
    .authenticator(std::sync::Arc::new(
        StaticTokenAuth::new("http://localhost:3000/auth/token")
            .with_business_logic("bl-token", "bl".parse()?),
    ))
    .build();
vtn.serve("0.0.0.0:3000").await?;

Re-exports§

pub use dispatch::DispatchConfig;
pub use dispatch::Dispatcher;
pub use error::ApiError;
pub use metrics::Metrics;
pub use retention::Retention;
pub use retention::RetentionConfig;

Modules§

api
HTTP handlers.
auth
Authentication and the OAuth2 scopes the specification defines.
dispatch
Draining the outbox.
error
Turning every failure into the specification’s problem object.
etag
HTTP caching for pollers.
inspector
/_inspect — a read-only view of what this VTN is doing, for the person learning or debugging it.
metrics
GET /metrics — Prometheus exposition.
notify
Push delivery.
openapi
GET /openapi.json — what this VTN serves, as a machine-readable document.
retention
Ageing reports out.
store
Storage: the trait the VTN talks to, and the backends behind it.
tlstls
Serving the VTN over TLS, and deciding who may connect at all.

Structs§

AppState
Everything a handler needs.
NeedsStorage
Marks a builder that has not been given a storage backend yet.
Ready
Marks a builder that is ready to build.
Vtn
A configured VTN.
VtnBuilder
Builds a Vtn.
VtnConfig
How the VTN behaves.