pub struct Native { /* private fields */ }Expand description
The native runtime. Adapters are passed in as instances (the same
pattern as the Cloudflare runtime’s .mailer(..)/.captcha(..)):
a Postgres or SQLite Database from the
matching adapter crate, a RedisRateLimiter
and RedisKv over a shared Redis connection
manager, Resend/Turnstile unchanged from the Workers path.
Config — including HARNESS_SECRET for the Signer port — is read
from std::env through the same cratefield_core::Config trait
(EnvConfig), so module keys behave identically on both runtimes.
Implementations§
Source§impl Native
impl Native
pub fn new() -> Self
Sourcepub fn db(self, db: impl Database + 'static) -> Self
pub fn db(self, db: impl Database + 'static) -> Self
The Database port: Postgres (cratefield-adapter-postgres) or
SqliteDatabase (cratefield-adapter-sqlite) — any Database
implementation.
Sourcepub fn rate_limiter(self, limiter: impl RateLimiter + 'static) -> Self
pub fn rate_limiter(self, limiter: impl RateLimiter + 'static) -> Self
The RateLimiter port: RedisRateLimiter in this crate, or a
test fake.
Sourcepub fn rate_limiter_arc(self, limiter: Arc<dyn RateLimiter>) -> Self
pub fn rate_limiter_arc(self, limiter: Arc<dyn RateLimiter>) -> Self
rate_limiter for an already-shared limiter.
Sourcepub fn kv(self, kv: impl KeyValue + 'static) -> Self
pub fn kv(self, kv: impl KeyValue + 'static) -> Self
The KeyValue port: RedisKv in this crate, or a test fake.
Sourcepub fn blob_arc(self, blob: Arc<dyn Blob>) -> Self
pub fn blob_arc(self, blob: Arc<dyn Blob>) -> Self
The Blob port: a directory store (crate::DirBlob) or an
S3-compatible adapter.
Sourcepub fn push_arc(self, push: Arc<dyn Push>) -> Self
pub fn push_arc(self, push: Arc<dyn Push>) -> Self
The Push port: an APNs adapter (cratefield-adapter-apns) or a test
fake. Notifications reach a device over the runtime’s HttpClient.
Sourcepub fn payments_arc(self, payments: Arc<dyn Payments>) -> Self
pub fn payments_arc(self, payments: Arc<dyn Payments>) -> Self
The Payments port: a Stripe adapter (cratefield-adapter-stripe) or a
test fake, over the runtime’s HttpClient.
Sourcepub fn realtime_arc(self, realtime: Arc<dyn Realtime>) -> Self
pub fn realtime_arc(self, realtime: Arc<dyn Realtime>) -> Self
The Realtime port: the in-process room registry
(crate::InProcessRealtime) built from the module’s RoomHandler.
pub fn mailer(self, mailer: impl Mailer + 'static) -> Self
pub fn mailer_arc(self, mailer: Arc<dyn Mailer>) -> Self
pub fn captcha(self, captcha: impl Captcha + 'static) -> Self
pub fn captcha_arc(self, captcha: Arc<dyn Captcha>) -> Self
Sourcepub fn ports(&self) -> Ports
pub fn ports(&self) -> Ports
Resolves the port bundle once per process from the builder and
std::env: config, Signer (from HARNESS_SECRET — warn once
and leave unset when missing, exactly like the Cloudflare
runtime), HttpClient over reqwest, Clock over the system
clock, IdGen, and Defer over tokio::spawn.
Unlike the Workers runtime — which resolves bindings per event —
a native process builds one bundle and shares it: every adapter
here is an Arc, so clone_ports snapshots cheaply.
Trait Implementations§
Source§impl Runtime for Native
impl Runtime for Native
Source§fn provides(&self) -> Vec<Port>
fn provides(&self) -> Vec<Port>
The static set used by Harness::build. Signer is included:
its presence is validated at ports() time (and by fz doctor),
mirroring the Cloudflare runtime.
Source§fn effectively_configured(&self, port: Port) -> bool
fn effectively_configured(&self, port: Port) -> bool
The same production gate the Cloudflare runtime applies
(issue #133), which this runtime never did (issue #143): a
Turnstile adapter that is not hostname-bound, or left fail-open,
cannot protect a production HumanForm route, so the port is
present but not usable. Without this a self-hosted venture booted
past a check its Workers twin refuses. Adapters that do not report
(binding() == None) count as effective when present: presence is
all the runtime can know about them.