greentic-distributor-client
WIT-based client for the greentic:distributor-api@1.0.0 world. Provides:
DistributorClientasync trait for resolving components, querying pack status, and warming packs.WitDistributorClientadapter that translates DTOs togreentic-interfaces-guestdistributor-api bindings; useGeneratedDistributorApiBindingson WASM targets to call the distributor imports.- Optional HTTP runtime client behind the
http-runtimefeature for JSON endpoints that mirror the runtime API.
Uses DTOs from greentic-types.
Usage
use ;
use json;
let bindings = default;
let client = new;
let resp = client.resolve_component.await?;
println!;
if let Some = resp.secret_requirements.as_ref
GeneratedDistributorApiBindings calls the distributor imports on WASM targets. On non-WASM targets it returns an error; consumers can provide their own bindings implementation for testing.
secret_requirements is present when talking to distributor versions that support it; otherwise it is None. When requirements are returned, run greentic-secrets init --pack <pack-id> ahead of time so secrets are available to the runtime.
HTTP runtime client (feature http-runtime)
Enable the feature and construct HttpDistributorClient:
[]
= { = "0.4", = ["http-runtime"] }
use ;
use json;
let config = DistributorClientConfig ;
let client = new?;
let resp = client.resolve_component.await?;
println!;
if let Some = resp.secret_requirements.as_ref
Fetch typed pack status (includes secret requirements):
let status = client
.get_pack_status_v2
.await?;
println!;
Using greentic-config-types (host-resolved config)
Resolve configuration in your host binary with greentic-config and map it into the distributor client with DistributorClientConfig::from_greentic:
use GreenticConfig;
use ;
let cfg: GreenticConfig = /* resolved in the host via greentic-config */;
let tenant = new;
let mut client_cfg = from_greentic
.with_base_url; // host still provides the endpoint/auth
// pass client_cfg to your chosen DistributorClient implementation
Local dev distributor
Use the companion greentic-distributor-dev crate to serve packs/components from a local directory, useful for greentic-dev and conformance tests:
use ;
use ;
let dev_source = new;
let sources = new;
let pack_bytes = sources.fetch_pack;
println!;
Repo maintenance
- Enable GitHub's "Allow auto-merge" setting for the repository.
- Configure branch protection with the required checks you want enforced before merges.