Build Your Own Self-Hosted Thin Client

Overview

The thin client and CLI provide ease of access to the cuOpt service, but these are just references on how to communicate with the cuOpt service. Underlying details of the API have been discussed below if you want to create your own thin client.

Invoking cuOpt Service

Sending cuOpt Request when payload is <= 250KB

This method is used to execute the cuOpt function. The “requestBody” contains a JSON object which will be processed by cuOpt.

You must include a function id and versionId in the url as shown below; this identifies the specific function to invoke.

Example with json data as direct string:

1curl --location 'http://ip:port/cuopt/routes' \
2--header 'Content-Type: application/json' \
3-d 'JSON_DATA'

Example with json data as a file:

1curl --location 'http://ip:port/cuopt/routes' \
2--header 'Content-Type: application/json' \
3--header 'CUOPT-DATA-FILE: data_file_path' \
4-d '{}'

JSON_DATA should follow Open-API spec described for cuOpt input.

cuOpt Result Retrieval

The cuOpt service employs long polling for invocation and result retrieval.

When you make an invocation request, the system will hold your request open for a period of time before returning with either:

> HTTP Status 200 completed result

> HTTP Status 202 polling response

On receipt of a polling response, your client should immediately poll the cuOpt service to retrieve your result. Polling once a second is recommended.

A polling scenario would have the following response for an invocation:

1{
2 "reqId": "ef4c1967-d543-467c-af7e-8c7899d75be8",
3 "status": "pending-evaluation"
4}

Polling for a response:

1curl --location 'http://ip:port/cuopt/routes/{request-id}'

For best performance, it is expected that clients will not close connections until it is determined that no further communication with a server is necessary.