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 tracker_arc(self, tracker: Arc<dyn Tracker>) -> Self
pub fn tracker_arc(self, tracker: Arc<dyn Tracker>) -> Self
The Tracker port: a cratefield_core::RoutingTracker over the
per-tracker adapters the venture configured, or a test fake.
Unlike every other adapter on this harness, the adapter holds no
credential: which tracker to file into and under whose token are
tenant data, supplied per call by the module that files — see
cratefield_core::Tracker for why that differs from the
Resend/Stripe shape.
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.
Sourcepub fn text_model(self, text_model: impl TextModel + 'static) -> Self
pub fn text_model(self, text_model: impl TextModel + 'static) -> Self
The TextModel port (issue #429): an adapter over the venture’s
vendor of choice for each ModelTier,
or one RoutingTextModel over both tiers. The same pattern as
mailer.
Sourcepub fn text_model_arc(self, text_model: Arc<dyn TextModel>) -> Self
pub fn text_model_arc(self, text_model: Arc<dyn TextModel>) -> Self
text_model for an already-shared adapter.
Sourcepub fn classifier(self, classifier: impl Classifier + 'static) -> Self
pub fn classifier(self, classifier: impl Classifier + 'static) -> Self
The Classifier port (issue #456): a typed, calibrated decision —
“which of these is it, and how sure are you” — from a purpose-built
classifier, a Workers AI binding (on the Workers twin) or an LLM
behind the TextModel port. The same pattern as text_model.
Sourcepub fn classifier_arc(self, classifier: Arc<dyn Classifier>) -> Self
pub fn classifier_arc(self, classifier: Arc<dyn Classifier>) -> Self
classifier for an already-shared adapter.
Sourcepub fn vector_index_arc(self, index: Arc<dyn VectorIndex>) -> Self
pub fn vector_index_arc(self, index: Arc<dyn VectorIndex>) -> Self
The VectorIndex port (issue #561): nearest-neighbour search over
the namespaces a module asks for — in-process
ExactVectorIndex or a hosted
index’s adapter.
Sourcepub fn embedder_arc(self, embedder: Arc<dyn Embedder>) -> Self
pub fn embedder_arc(self, embedder: Arc<dyn Embedder>) -> Self
The Embedder port (issue #561): text into embedding vectors, as
wide as the vector_index wired alongside it expects.
Sourcepub fn custom_hostnames(
self,
custom_hostnames: impl CustomHostnames + 'static,
) -> Self
pub fn custom_hostnames( self, custom_hostnames: impl CustomHostnames + 'static, ) -> Self
The CustomHostnames port (issue #590): a customer’s own hostname
served by a venture. Like mailer, the adapter is built from the
venture’s vendor keys and passed in — the Cloudflare for SaaS
adapter is cratefield-adapter-cloudflare-saas, portable over the
HttpClient port.
Sourcepub fn custom_hostnames_arc(
self,
custom_hostnames: Arc<dyn CustomHostnames>,
) -> Self
pub fn custom_hostnames_arc( self, custom_hostnames: Arc<dyn CustomHostnames>, ) -> Self
custom_hostnames for an already-shared adapter.
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 auth(self, auth: impl Auth + 'static) -> Self
pub fn auth(self, auth: impl Auth + 'static) -> Self
Wires who a request’s credentials speak for (issue #153).
Without one the deployment cannot identify a caller, and a module
that declares Port::Auth is refused composition rather than
mounted and left guessing.
pub fn auth_arc(self, auth: Arc<dyn Auth>) -> Self
Sourcepub fn auth_from_env(self) -> Self
pub fn auth_from_env(self) -> Self
Assembles the Auth port from AUTH_ISSUER and AUTH_CLIENT_ID.
The port is provided either way, matching the Cloudflare runtime:
a venture generated by fz build wires this whenever one of its
tables is not public-read, and the two runtimes answering
differently for the same venture would be a difference between
two deployments of one manifest.
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.