Rust example applications for Light-Fabric.
This repository contains two small light-axum services for the skill and
workflow orchestration demo:
| App | Service id | Default port | Endpoints |
|---|---|---|---|
demo-customer-profile-api |
com.networknt.demo.customer-profile-1.0.0 |
8085 |
GET /customers/{customerId}, GET /customers/{customerId}/preferences, GET /customers/{customerId}/policies, GET /customers/{customerId}/vehicles/{vehicleId}, GET /customers/{customerId}/prior-claims, GET /health |
demo-offer-decision-api |
com.networknt.demo.offer-decision-1.0.0 |
8086 |
GET /offers, POST /offer-decisions, POST /claim-triage, POST /settlement-recommendations, GET /health |
Both apps use LightRuntimeBuilder with AxumTransport, so they can load
configuration from config-server and register with controller through
portal-registry.
Local config defaults keep controller registration disabled so the services can
run without a portal stack. Config-server examples under config-registry/
enable controller registration for a full demo environment.
From the repository root:
cargo run -p demo-customer-profile-api
cargo run -p demo-offer-decision-apiSmoke checks:
curl -s http://127.0.0.1:8085/customers/CUST-1001
curl -s "http://127.0.0.1:8085/customers/CUST-1001/preferences?channel=portal"
curl -s http://127.0.0.1:8085/customers/CUST-1001/policies
curl -s http://127.0.0.1:8085/customers/CUST-1001/vehicles/VEH-1001
curl -s http://127.0.0.1:8085/customers/CUST-1001/prior-claims
curl -s "http://127.0.0.1:8086/offers?segment=premium&state=ON&category=travel"
curl -s -X POST http://127.0.0.1:8086/offer-decisions \
-H 'content-type: application/json' \
-H 'idempotency-key: wf-demo-1001' \
-d '{"customerId":"CUST-1001","offerId":"OFFER-TRAVEL-01","channel":"portal","source":"workflow","reason":"demo"}'
curl -s -X POST http://127.0.0.1:8086/claim-triage \
-H 'content-type: application/json' \
-d '{"claim":{"claimId":"CLM-1001","customerId":"CUST-1001","vehicleId":"VEH-1001","injuryReported":false,"vehicleDrivable":false},"customer":{"customerId":"CUST-1001","segment":"premium","state":"ON"},"policies":{"policies":[{"policyId":"POL-AUTO-1001","status":"active"}]},"vehicle":{"vehicleId":"VEH-1001","covered":true},"priorClaims":{"priorClaimCount":1,"recentClaimCount":0}}'
curl -s -X POST http://127.0.0.1:8086/settlement-recommendations \
-H 'content-type: application/json' \
-H 'idempotency-key: claim-demo-1001' \
-d '{"claim":{"claimId":"CLM-1001","customerId":"CUST-1001"},"coverageReview":{"deductible":500},"triage":{"recommendedPath":"repair","estimatedLoss":3200},"approval":{"decision":"APPROVED"}}'Insurance claim demo records are deterministic:
CUST-1001: active Ontario auto policy, coveredVEH-1001, low/medium risk repair path.CUST-2002: expired policy and uncoveredVEH-2002, review/SIU path.CUST-3003: active policy and covered vehicle, but consent is disabled for customer-info branches.- unknown customers return
404for profile and insurance context endpoints.
Upload these files in the API version form to create endpoint records:
apps/demo-customer-profile-api/openapi.yaml
apps/demo-offer-decision-api/openapi.yaml
The runtime config templates are in each app's config/ directory:
startup.yml
server.yml
portal-registry.yml
client.yml
values.yml
For a full portal demo, publish values equivalent to:
config-registry/demo-customer-profile-api/values.yml
config-registry/demo-offer-decision-api/values.yml
The important values are:
server.enableRegistry: true
server.advertisedAddress: demo-customer-profile-api
portalRegistry.portalUrl: https://controller.lightapi.svc.cluster.local:8438
light-config-server-uri: https://config-server.lightapi.svc.cluster.local:8435Set LIGHT_CONFIG_SERVER_URI and LIGHT_PORTAL_AUTHORIZATION before starting
the apps. LIGHT_CONFIG_SERVER_URI is used during bootstrap to fetch
config-server values, including server.httpPort; LIGHT_PORTAL_AUTHORIZATION
is used for config-server access and controller registration. After startup,
the control panel should show both services in service discovery with
environment demo.
Both apps use the shared light-runtime tracing setup.
RUST_LOG=infocontrols the tracing filter, for exampledemo_customer_profile_api=debug,info.LIGHT_LOG_FORMAT=textcontrols console format; supported values aretextandjson.LIGHT_LOG_ANSI=falsecontrols ANSI color codes in text console output.CUSTOMER_PROFILE_LOG_ANSI=falseandOFFER_DECISION_LOG_ANSI=falseremain legacy ANSI toggles and are used only whenLIGHT_LOG_ANSIis unset.LIGHT_LOG_JSON_FILE_ENABLED=truealso writes JSON Lines logs to a file.LIGHT_LOG_JSON_FILE_DIR=/var/log/light-fabriccontrols the JSON log directory.LIGHT_LOG_JSON_FILE_NAME=demo-customer-profile-api.jsonlordemo-offer-decision-api.jsonloverrides the default service-specific file name.LIGHT_LOG_JSON_FILE_ROTATION=dailysupportsminutely,hourly,daily, andnever.
Because these apps use LightRuntimeBuilder, the runtime logging filter can
also be changed from the control plane through the runtime MCP logging tools
after the services are registered with the controller.
Prerequisites for publishing:
- Docker daemon running
docker logincompleted for the target Docker Hub namespace
Build both Docker images locally:
./build.sh 0.1.0 --localPublish both images to Docker Hub:
./build.sh 0.1.0The default Docker Hub namespace is networknt, producing:
networknt/demo-customer-profile-api:0.1.0
networknt/demo-offer-decision-api:0.1.0
Use DOCKER_ORG or --image-org to publish under another namespace. Use
--app demo-customer-profile-api or --app demo-offer-decision-api to build
one image.
The Docker build context is the parent workspace directory because this repo
uses local path dependencies from ../light-fabric.
Prerequisites for publishing:
- GitHub CLI
ghinstalled and authenticated rustupinstalledmusl-toolsandpkg-configinstalled for thex86_64-unknown-linux-musltarget
Build Linux release archives locally:
./release.sh v0.1.0 --localCreate or update a GitHub release with the archives:
./release.sh v0.1.0The release archives include both binaries plus their config templates:
bin/demo-customer-profile-api
bin/demo-offer-decision-api
config/demo-customer-profile-api/
config/demo-offer-decision-api/