primus.runtime.async_score_processor.handler module
Isolated Lambda handler for the reusable asynchronous scoring service.
This implementation intentionally lives outside score-processor-lambda.
That directory remains the compatibility boundary for the existing production
processor until its workload is retired after cutover.
This handler processes scoring jobs from SQS. It can be invoked: 1. SQS event source trigger - automatic trigger from SQS queue (batch_size=1) 2. Fan-out Lambda - processes specific message passed in event 3. Manual invocation - polls queue for 1 message
The handler: - For SQS event source: Extracts message from event.Records[0], SQS handles deletion - For fan-out invocation: Processes message from event payload, manually deletes - For manual invocation: Polls SQS queue for ONE scoring job message, manually deletes - Retrieves the ScoringJob from DynamoDB - Performs scoring using Primus scorecard system - Creates ScoreResult in DynamoDB - Sends response to PRIMUS_RESPONSE_WORKER_QUEUE_URL - On success: Message deleted (automatically for SQS trigger, manually for others) - On failure: Exception raised to return message to queue (SQS will retry → DLQ)
- Environment Variables:
PRIMUS_SCORING_WORKER_REQUEST_STANDARD_QUEUE_URL: SQS queue URL PRIMUS_RESPONSE_WORKER_QUEUE_URL: Response queue URL PRIMUS_ACCOUNT_KEY: Primus account key
- class primus.runtime.async_score_processor.handler.LambdaJobProcessor
Bases:
objectProcesses a single scoring job for Lambda execution
Initialize the Lambda job processor
- __init__()
Initialize the Lambda job processor
- async initialize()
Initialize by resolving account ID
- async poll_sqs_once()
Poll SQS queue for ONE message
- Returns:
Dict with job details and receipt_handle if found, None otherwise
- async process_job(scoring_job_id, item_id, scorecard_id, score_id, receipt_handle)
Process a scoring job
This is adapted from ProcessScoreWorker.process_job()
- async primus.runtime.async_score_processor.handler.async_handler(event, context)
Async Lambda handler
- primus.runtime.async_score_processor.handler.configure_lambda_logging()
Configure deterministic root logging for Lambda runtime.
- primus.runtime.async_score_processor.handler.lambda_handler(event, context)
Lambda entry point - wraps async handler