app/recommendations/ — v2 recommendations API (KServe wrapper)¶
A small Go service introduced in ch.13.08. POSTs to the KServe predictor
(which serves the model from MLflow); publishes each prediction to Kafka
ml.predictions for the drift detector.
What it does¶
- Reads the verified
x-jwt-payloadheader (Istio sets it post JWT verification; ch.13.04) and extracts thetenantclaim. - POSTs the request body to the KServe v1 protocol endpoint
/v1/models/recommender:predict. - Returns the predictions to the caller.
- Async-publishes the prediction event to Kafka
ml.predictionsfor Alibi-Detect to consume.
What it does not do (out of scope)¶
- Embedding cache for hot users.
- Request batching to amortise KServe RPCs.
- A/B test traffic split via feature-flag SDK.
- Streaming response (predictions can be large).
The chapter calls these out; this is a 150-line demonstration.
Build + run¶
cd examples/bookstore-platform/app/recommendations
go vet ./...
go build ./...
docker build -t bookstore-platform/recommendations:dev .
Cross-references¶
- Ch.13.08 — the chapter that introduces this service.
../../ml/inferenceservice.yaml— the KServe predictor this service calls.../../ml/alibi-detect-drift.yaml— the drift detector that consumesml.predictions.../../kafka/topics.yaml—ml.predictionsis implicit (the topic is created on first write; production should add it to topics.yaml).