Make External API Dependency Healthy Again
with Contracts
by
Dolganov Sergey @ Evil Martians
Why?
Over and Over Again
Ideal World
Example
Ossert:
- 4 APIs already depends
- Storage per quarter
- Non-incremential storage
Twitter API:
- Public data for last week only
Non-Increment al
Per Quarter Storage
Layout (for Ossert)
Incremental
Per Week
Storage
twitter gem
Failed
Requests
Recovery
Just Fire and Forget
App Life Cycle
Prevention
Test Coverage
Issue
Release
Diagnostics
Metrics, Alerts, Customers Feedback
What If ...
Risk Is a Human Life?
Car Diagnostics
Car Computer Diagnostics
Design for Testing
Design for Testing
-
Recognize State
-
Capture Statistics
-
Record Debugging Data
How to Determine State in the App?
Design by Contracts
-
What does a contract expect?
-
What does a contract guarantee?
-
What does a contract maintain?
PORO Contract
Under Microscope
Design for Testing
-
Recognize State
-
Capture Statistics
-
Record Debugging Data
Recognize State
Capture Statistics
+
Structured
Logs
Record Debugging Data
Tracing
Sampling
blood_contracts gem
"Rails" for Contracts
Contract is a test that runs all the time in production
App Life Cycle
Prevention
+ Contract Coverage
Issue
+ Contract Exceptions
Release
Diagnostics
+ Contract Stats & Samples
Why?
Ruby encourages us:
-
to express our ideas
-
to experiment
-
to learn by doing
-
to understand complex things
-
to share