10. Common Uses
In this section, we will cover the common use cases using the sample app provided.
- Debugging services: Send requests to services, verify responses, and identify changes compared to previous responses.
- Observability: View interactions with external APIs.
- Auto-created mocks: Use them for service tests, or when upstream services are unavailable.
- Parallel development: Create mocks when upstream APIs are not yet ready.
As outlined in the previous chapters, the API Studio can be used to send a request to the service in an IDE, observe the behavior of the API, and debug the code. The egress requests from the service in the IDE should be routed back to API Studio. In the API Studio, you have the choice of sending the egress requests either to live services in the cloud, or to the mock services provided by Mesh Dynamics.
- Identify changes as you make code changes: Use the diff capability to identify changes in responses as you make code changes. Save a request together with its response. Run the saved request again after making code changes, and use the diff to identify the impact of the code changes -- for both the API response as well as the egress requests.
- Validate API behavior: Validate API behavior for a variety of conditions and use cases. Simulate corner cases by varying the arguments, and also by creating specific mock behaviors.
- Identify changes from past behavior: Identify differences in API behavior across time either by pinnig and comparing any two saved requests (from the API Catalog or from your collections), or by selecting a saved trace and running the API request against a live service.
API Studio provides full visibility into how the API under development is interacting with external APIs without any additional instrumentation. Just route the egress requests back to the API Studio, and from there to the service in the cloud or the auto-created mocks. You can see the full details of each request and response -- for both the ingress request and the egress requests. You can also compare them with prior stored examples to detect changes in API functionality.
Use auto-created mocks when upstream services in dev cluster are buggy or unavailable. Mesh Dynamics automatically creates mocks for all requests stored in any collection, or captured from the CI pipeline (when Mesh Dynamics agents are deployed). When the upstream stream APIs in the dev cluster are under development or buggy, just switch the egress request configuration to use the mocks created automatically from the requests saved to collections. This eliminates the complete dependence on the availability of stable upstream services in the dev cluster.
API Studio provides complete flexibility over which upstream services are mocked and which are live.
Create mocks when upstream APIs are not yet ready. API Studio unblocks parallel development of services with API dependencies by removing the dependency on the availability of the new/updated upstream APIs. Create API mocks from stored traces based on the contract. Set the egress request configuration to use the hand-crafted mocks until the updated service is available in the dev cluster. Eliminate the dependence on the availability of new/updated upstream services in the dev cluster before validating downstream services.