Skip to main content

Quickstart: Service Invocation

This quickstart showcases how to enable the request-reply pattern using the Service Invocation API.

Prerequisites

Before you proceed, ensure you have the following prereqs installed.

Log in to Catalyst

Authenticate to Diagrid Catalyst using the following command:

diagrid login 

Confirm your organization and user details are correct:

diagrid whoami

Deploy quickstart project

Create a project and bootstrap the necessary resources to begin developing locally with the Service Invocation API. This command:

✔️ Creates a new Catalyst project
✔️ Deploys a Diagrid Pub/Sub Service
✔️ Creates an App IDs: one for the client application and one for the server application
✔️ Clones a quickstart application to your machine
✔️ Scaffolds a dev config file to run the quickstart code with the necessary Catalyst connectivity info

diagrid project quickstart --type invoke --language python

Run sample application

To run the quickstart code locally, you can use the diagrid dev start command. This command:

  • Launches the local quickstart apps: Locates the code directories using the values specified for workDir and launches each application using the respective app command inputs
  • Injects environment variables: Configures the Dapr client to talk to Catalyst using the client App ID API token
  • Establishes private dev tunnel: Creates a private tunnel for the server application on the specified appPort, which will route all traffic destined for the server App ID to the local port where the code is running
  • Streams application logs: Displays connectivity logs along with real-time app feedback directly in the terminal to make API testing simple

For additional details on the Catalyst local development experience, read Develop Locally with Catalyst APIs.

Install .NET dependencies.

dotnet build

Run your applications and connect the server App ID to the local server app using the following command.

diagrid dev start 
tip

Ensure the log Connected App ID "server" to localhost:5002 appears before proceeding to the next section.

Interact with Catalyst APIs

With your applications now successfully running, it's time to test the Service Invocation API. Use the curl command below or take advantage of the REST Client extension using Visual Studio Code with the test.rest file in the root folder of the repo.

Open a new terminal and execute the following curl command:

curl -i -X POST http://localhost:5001/order -H "Content-Type: application/json" -d '{"orderId":1}'

Upon successful execution, the server app should indicate the request was successfully received and the client app logs should output the invocation was successful.

To stop the local applications and disconnect the local app connection for the server App ID, run:

diagrid dev stop

Clean up resources

If you are not going to continue to use this application, you can delete the resoures using the following commands:

diagrid appid delete client 
diagrid appid delete server

If you want to delete the entire Catalyst project, including the managed infrastructure resources, run the diagrid project delete command.