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. greentic-distCLI (featuredist-cli) for resolving/pulling components into a shared cache, plus a libraryDistClientAPI for pack/runner integration.
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!;
greentic-dist CLI (feature dist-cli)
Build with the CLI feature to get the greentic-dist binary:
Commands:
resolve <REF>: print digest (use--jsonfor structured output).pull <REF>: ensure cached; prints path. Use--lock <pack.lock>to pull all components from a lockfile.cache ls|rm|gc: list/remove/gc cache entries.auth login <target>: stub for future store/repo auth.
Control cache location with --cache-dir or GREENTIC_DIST_CACHE_DIR; defaults to ${XDG_CACHE_HOME:-~/.cache}/greentic/components/<sha256>/component.wasm. Set GREENTIC_SILENCE_DEPRECATION_WARNINGS=1 to silence the temporary greentic-distributor-client shim binary warning.
Exit codes:
0success2invalid input (bad ref/lockfile/missing args)3not found (cache miss)4offline blocked (network needed)5auth required/not implemented (repo://, store://)10internal error
Library API (feature dist-client)
Use DistClient to reuse the same resolution and cache logic programmatically. The dist-client feature also includes the OCI pack fetcher APIs (fetch_pack, OciPackFetcher):
use ;
let client = new;
let resolved = client.ensure_cached.await?;
println!;
Integration examples
- Resolve a ref:
greentic-dist resolve oci://ghcr.io/greentic-ai/components/hello-world:1 - Pull everything from a lockfile:
greentic-dist pull --lock pack.lock.json - Offline workflow:
greentic-dist pull --lock pack.lock.jsonthengreentic-runner run mypack.gtpack --offline
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.