Skip to content

feat(gateway): implement IntelligenceClient HTTP integration #10

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

IssueRelationship
#9Blocked 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

FileAction
apps/gateway/Gateway.API/Services/IntelligenceClient.csModify
apps/gateway/Gateway.API/Configuration/IntelligenceOptions.csReference
apps/gateway/Gateway.API.Tests/Services/IntelligenceClientTests.csCreate

Design References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions