Skip to content

feat(gateway): implement IntelligenceClient HTTP integration #10

@rsalus

Description

@rsalus

Note for implementers: The design outlined here is a guideline, not a strict specification. Feel free to pivot from the suggested approach if you discover a better solution during implementation. Update the issue with your rationale when deviating significantly.

Summary

Replace the stub IntelligenceClient with production HTTP calls to the Intelligence service /analyze endpoint.

Context

The current implementation returns hardcoded mock data. Production implementation must:

  1. Serialize ClinicalBundle to JSON
  2. POST to /analyze endpoint with timeout handling
  3. Deserialize response to PAFormData
  4. Handle errors gracefully

Dependencies

Issue Relationship
#9 Blocked by - data contracts must be stable

Tasks

Core Implementation

  • Inject HttpClient via IHttpClientFactory
  • Serialize ClinicalBundle to JSON
  • POST to {BaseUrl}/analyze
  • Deserialize response to PAFormData

Resilience (Polly)

  • Retry policy (exponential backoff, max 3)
  • Circuit breaker (threshold: 5, 30s break)
  • Timeout policy (30s default)

Error Handling

  • Handle HttpRequestException
  • Handle timeout scenarios
  • Handle non-2xx status codes
  • Log errors with correlation ID

Testing

  • Unit tests with mocked HttpMessageHandler
  • Test retry and circuit breaker behavior

Files

File Action
apps/gateway/Gateway.API/Services/IntelligenceClient.cs Modify
apps/gateway/Gateway.API/Configuration/IntelligenceOptions.cs Reference
apps/gateway/Gateway.API.Tests/Services/IntelligenceClientTests.cs Create

Design References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions