Platform Update - App Import Improvements and Async Functions

Brandon Cannaday
Brandon Cannaday | 2 minute read

Today's update further improves application lifecycle management and greatly increases the power of Function Nodes in your Edge Workflows.

Direct Application Import

Application import and export is the foundation for lifecycle management within Losant. To promote changes, you'd export your develop application and import it into your staging or production application. With today's update, that export step is no longer required. You can now directly choose an application that you'd like to import.

losant-import-from-appThe screenshot above shows the updated user interface where "Choose a source application..." has been added as an available import source. When you select this option, the platform will automatically handle the export process for you and then import the result.

This option streamlines the import process and reduces potential errors caused by accidentally importing the wrong export file.

Application Import Log

To further improve the application import experience, we've added a log that displays the details and results of past imports.

losant-app-import-log

One of the most useful aspects of this log is the "Copy Settings to New Request" button. This makes it easy to quickly perform imports using the same settings as a previous import. This is particularly helpful when you're importing a subset of resources since this saves the time of having to recheck every required resource.

Async Functions for Edge Workflows

The Function Node provides the ability perform complex processing that may not be offered by the other, built-in, workflow nodes. A common example is to process raw or binary data. With today's update, the Function Node for Edge Workflows now supports async operations (Promises, setTimeout, setInterval, async, and await).

The primary use case for async operations is for network access. Combined with the ability to extend the Gateway Edge Agent (GEA) with custom modules and libraries, you can now use the Function Node to connect to controllers or perform network operations that are not directly supported by other edge workflow nodes.

For example, nearly every built-in Node.js module is automatically available and the code below uses the built-in DNS module to perform a DNS lookup.

const dns = require('node:dns')

const [address, family] = await new Promise((resolve, reject) => {
    dns.lookup('losant.com', (err, address, family) => {
        if(err) { return reject(err); }
        resolve([address, family]);
    });
});

payload.working = payload.working || {};
payload.working.dns = { address: address, family: family };

The lookup function is asynchronous and prior to today's update, you would not have been able to invoke this function and receive the results. While async operations do open up a world of new possibilities, please keep in mind that the function must still complete within the workflow's timeout period. This means you cannot use async operations to open persistent connections or start any kind of server. If you are using a function node to access something like an industrial controller, you must connect, perform the operation (read PLC tag, etc.), and disconnect, all within a single function node invocation.

Other Updates

As always, this release comes with several minor features and improvements, including:

 

What’s Next?

With every new release, we listen to your feedback. By combining your suggestions with our roadmap, we can continue to improve the platform while maintaining its ease of use. Let us know what you think in the Losant Forums.