[BACK-PROC-06] Integrating B2B Ingestion with AuthService and Publishing Product Lists to Kafka
Product Ingestion Process Service
NoteTask Brief
- Repository / Component:
product_process_service(Go). - Stack: Go, gRPC/HTTP Client, Apache Kafka.
- Task Type: Backend (Integration & Queues).
- Status: Ready for Implementation
Task Description
It is necessary to refactor the current B2B product ingestion endpoint that receives product data from partner stores. You must remove the hardcoded token validation, configure a synchronous request to the AuthService to verify the partner, and upon success, push the incoming JSON product list into a Kafka topic for asynchronous processing by a background worker.
Step-by-Step Instructions
- Removing Hardcoded Verification: Completely remove verification checks such as
if token == "hardcoded_token"from the codebase. - Integrating the Network Client: Set up a gRPC/HTTP client to communicate with the
AuthService. Invoke theValidateStoreTokenmethod, forwarding the token extracted from the request header (Authorization: Bearer <b2b_token>). - Handling the Authorization Response:
- If the
AuthServicereturns an error or a refusal, instantly abort the operation and return a structured error response to the partner store (referencing the previous task: mapping to gRPC code 16 or HTTP 401).
- If the
- JSON Validation and Kafka Publication (Pipeline):
- Upon successful authorization, parse the incoming product array sent by the store.
- Construct a DTO message for the message queue, enriching it with the retrieved
store_idmetadata. - Publish (
Produce) the message to the Kafka topic namedb2b_products_intake. The message must be transmitted strictly in JSON Lines or a structured JSON format.