Skip to content

networknt/light-example-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

light-example-rs

Rust example applications for Light-Fabric.

Demo Workflow Orchestration APIs

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 /health
demo-offer-decision-api com.networknt.demo.offer-decision-1.0.0 8086 GET /offers, POST /offer-decisions, 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.

Run Locally

From the repository root:

cargo run -p demo-customer-profile-api
cargo run -p demo-offer-decision-api

Smoke 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: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"}'

OpenAPI Specifications

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

Config-Server And Controller

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:8435

Set 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.

Docker Images

Prerequisites for publishing:

  • Docker daemon running
  • docker login completed for the target Docker Hub namespace

Build both Docker images locally:

./build.sh 0.1.0 --local

Publish both images to Docker Hub:

./build.sh 0.1.0

The 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.

GitHub Binary Release

Prerequisites for publishing:

  • GitHub CLI gh installed and authenticated
  • rustup installed
  • musl-tools and pkg-config installed for the x86_64-unknown-linux-musl target

Build Linux release archives locally:

./release.sh v0.1.0 --local

Create or update a GitHub release with the archives:

./release.sh v0.1.0

The 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/

About

light-rs example applications

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors