feat: add FastAPI integration example#19
Conversation
|
@coderabbitai help |
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a FastAPI example app and README for SmoothAPI retry and circuit-breaker demos, with shared async client setup, demo routes, example dependencies, a package version bump, and a TypeScript JSON module import setting. ChangesFastAPI integration example
Sequence Diagram(s)Retry demo flow sequenceDiagram
participant RetryDemo as "retry_demo()"
participant FetchUnstable as "fetch_unstable_data()"
participant ResilientRetry as "`@resilient_api`(retry_config)"
participant HttpClient as "http_client"
participant Sandbox as "GET {SANDBOX_URL}/unstable-data"
RetryDemo->>FetchUnstable: call
FetchUnstable->>ResilientRetry: wrap request
ResilientRetry->>HttpClient: send GET
HttpClient->>Sandbox: request unstable data
Sandbox-->>HttpClient: JSON body
HttpClient-->>ResilientRetry: httpx response
ResilientRetry-->>RetryDemo: upstream JSON
Circuit breaker demo flow sequenceDiagram
participant CircuitDemo as "circuit_demo()"
participant FetchFailing as "fetch_failing_data()"
participant ResilientCircuit as "`@resilient_api`(circuit_config)"
participant HttpClient as "http_client"
participant Sandbox as "GET {SANDBOX_URL}/always-fail"
CircuitDemo->>FetchFailing: call
FetchFailing->>ResilientCircuit: wrap request
ResilientCircuit->>HttpClient: send GET
HttpClient->>Sandbox: request failing data
Sandbox-->>HttpClient: error response
alt httpx.Response returned
ResilientCircuit-->>CircuitDemo: httpx.Response
CircuitDemo->>CircuitDemo: return status_code and result.json()
else fallback data returned
ResilientCircuit-->>CircuitDemo: fallback payload
CircuitDemo->>CircuitDemo: return fallback result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Action performedReview finished.
|
…nfig Co-authored-by: aaishmeen <chowdharyaaiishmeen@gmail.com>
|
@AryanSharma48 is attempting to deploy a commit to the aryansharma48's projects Team on Vercel. A member of the Team first needs to authorize it. |
Description
This PR adds a FastAPI integration example under
examples/fastapito demonstrate how SmoothAPI can be integrated into a FastAPI application.The example showcases the library's core resilience features, including retry handling, circuit breaker behavior, and fallback responses, while using the existing sandbox server for demonstration. It also includes a
README.mdwith setup instructions and arequirements.txtfile for installing the required dependencies.Affected files:
examples/fastapi/main.pyexamples/fastapi/README.mdexamples/fastapi/requirements.txtFixes #10
Summary by CodeRabbit
New Features
Bug Fixes