Skip to main content

Task App

What is a Task App?

A task app is an app that gets invoked by an API Post request (https://api.corva.ai/v2/tasks) via a frontend app, another backend app with an API key or externally via the API Post url with an API Key.

The task app receives on demand data in the form of events from the body of the API Post request. It receives the event whenever the API Post request is sent.

The task app will sit dormant until it is invoked only when an API Post request is sent. At no other time will the task app be invoked.

Unlike a stream or scheduled app, task apps are NOT assigned to an asset stream.

Task apps execute in their own short-lived Lambdas on AWS. Task apps are best used for data processing, single API requests, or calculations that need to be done once and have the outputs saved to a dataset.

While a frontend app can invoke a task app via an API Post request, the task app does not return data to the frontend app. The task app can communicate processed data by posting the values in a dataset (https://data.corva.ai/api/v1/data/{provider}/{dataset}/) or posting to Corva's Data API subscription endpoint (https://data.corva.ai/api/v1/subscriptions/{provider}/{dataset}/{asset_id}/).

Dev Center task apps are built on AWS Lambda. To learn more about AWS Lambda functions please see Best practices for working with AWS Lambda functions.


When to build a Task App?

Typical use cases for a task app include invoking initial API request for an external/non-Corva API. Invoking Back End app to Back End app in order to either abstract common tasks/functions, farm out computations to new lambdas, or update custom collections. Performing single calculations based on inputs from the UI.

  1. I require processing or calculations of input data from a frontend app, then posted to a dataset

  2. I require the task to run on a separate/new lambda (memory/size concerns)

  3. I require a scheduled, stream or another task app to invoke a task app to execute a function or process data

  4. I require this app to be reusable or invoked by several other apps

  5. I require my external data's well identifiers to be mapped to Corva's well identifiers, then posted to a dataset, a.k.a mapping data

  6. I require one-time, triggered execution

  7. I do not require the app to be attached to an asset stream

  8. I do not require the app to receive real-time data events from Corva

If you require real-time data at one second or 1 foot intervals (or the next available measurement), you should use a Stream App or Scheduled App instead.


What is the difference between a Task App and a Scheduled or Stream App?

A task app receives an event when it is invoked when an API Post is made to the app. A stream or scheduled app receives an event from a drilling rig, frac fleet, wireline unit or drill out unit.


Where to find the data to build a Task App?

The Corva Dev Center Dataset Explorer is an easy way to to see a list of Corva datasets and the data stored in each dataset. An additional option is to utilize Corva's API tools located in the Dev Center Intro page and make a GET API request to your desired dataset.


How to build a Task App?

The following examples will demonstrate the simple building blocks of a task application while utilizing all imported functionalities.

Task app
import { postTask } from "@corva/ui/clients/jsonApi";

export async function createTask({
app_key,
asset_id,
current_user_id,
type,
provider,
min_start_time,
max_start_time,
user_name,
well_name,
}) {
let response;
const body = {
app_key,
asset_id,
properties: {
...(user_name && { user_name }),
...(max_start_time && { max_start_time }),
id: `${current_user_id}`,
...(min_start_time && { min_start_time }),
type,
...(well_name && { well_name }),
},
provider,
};

try {
response = await postTask({ task: body });
} catch (e) {
console.log(e);
response = e;
} finally {
return response;
}
}

Task event – provider, app key, asset_id, company_id, properties objects with custom key values, payload