Design
The CCDS API is designed to assist the Integration Operator with connecting to the data source, creating objects inside the data source, parsing XML, converting dates, and frequently utilizing items when creating a data source.
Namespaces
The JavaScript engine provides access to built-in Adaptive Insights Integration features via the 'adaptive' namespaces or 'ai' (Adaptive Insights) namespace (Alias). This provides separation in a fashion similar to most popular JavaScript libraries like jQuery (https://jquery.com/).
// JavaScript short namespace example. var shortReferenceToBuilder = ai.log.logError('this is a log'); // JavaScript long namespace example. var longReferenceToBuilder = adaptive.log.logError('this is a log');
Beneath the root 'adaptive' or 'ai' namespace, a number of core functions are exposed to allow the JavaScript to interact with the internet and Adaptive Insights Discovery/Integration features. These public JavaScript APIs are modeled using Node.js (https://nodejs.org/) APIs as a guide.
Functions
Functions get and set data to make the API consistent, provide encapsulation, and explicitly allow setters and getters. Functions also provide encapsulation of C# objects to only expose JavaScript language functionality and prevent unnecessary crossing of the JavaScript / C# boundary to improve performance. The getters are prefixed with get and setters are prefixed with set.
var isEnabled= item.getIsEnabled(); item.setIsEnabled(true);
Functions Context
Each function called by a CCDS takes a Context object. The context contains read-only objects to help with the processing.
function importData(context) { var tableId = context.getTableId(); var tables = context.getDataSource().getTables(); var setting = context.getDataSource().getSetting('password'); }
The context is made up of objects passed in from C#. To improve performance, we avoid exposing C# objects in the JavaScript by encapsulating each object in a JavaScript object. This allows managing communication across the JavaScript / C# boundary. For example, when asking the context for tables, the C# object returns wrapped in a JavaScript object. When there is an object hierarchy, we wrap each level in a JavaScript object. When asking for the columns in a table, we return a list of JavaScript wrapped objects.
Limitations
The limits below apply to a running CCDS script process session.
Setting | Description | Default Value | Configurable AppSetting? | Configurable Tenant Setting? |
---|---|---|---|---|
Max Heap Megabytes | Amount of RAM the V8 engine can consume. | 100 | Yes | Yes |
CPU Time Limit | Amount of time the V8 engine can use CPU resources. | 10 minutes | Yes | Yes |
Run Duration Limit | Amount of time the V8 engine can run for regardless of whether it is actively using CPU resources. | 60 minutes | Yes | Yes |
Delay Between Net Calls | 1 second | Yes | Yes | |
Logs Per Second Limit | Maximum number of logs that can be created from script per second. | 5 | Yes | Yes |
Logs Per Hour Limit | Maximum number of logs that can be created from script per hour. | 1000 | Yes | Yes |
Network Usage Limit Megabytes | Maximum megabytes that a script can send and receive over the network. | 5 gigabytes | Yes | Yes |
Milliseconds Between Async Script Service Requests | Used to throttle traffic between Task Service and a script runner process. If the script runner process can keep up with the demand from the Task service, then the wait time drops to 0 milliseconds. | 200 milliseconds | No | No |
Max Script Result Pages Per Request | Number of ‘pages’ of data the Task service can request from a script runner’s repository. | 50 | No | No |
The limits below apply to the CCDS Script Pool Manager.
Setting | Description | Default Value | Configurable AppSetting? | Configurable Tenant Setting? |
---|---|---|---|---|
Max Script Pool Size | Maximum number of concurrently running script processes. | 100 | Yes | No |
Min Script Pool Size | Minimum number of script processes to have running at any one time (used to ‘pre-warm’ script runner processes). | 0 | Yes | No |
Script Pool Wait Timeout | Maximum time a request for a script runner process can be queued for. | 180 seconds | Yes | No |
Max Script Pool Queue Size | Maximum number of waiting requests for a script runner process. | 1000 | No | No |
Size | script runner process. |
Other limits:
-
Without using the ai.https.sax.parser method in your script, there is a limit to the size of an XML file for parsing. The upper size limit is not known, but for reference, it is possible to parse 10mb file with a 100mb heap size. We recommend using ai.https.sax.parser for large files.
-
Scripts cannot access IPs within the Adaptive network.
-
HTTP is not supported, only HTTPS.
Known Issues
-
During importData/importStructure, a datasource will call testConnection. In CCDS, this means two separate script runner processes. It is possible for the first process to be successfully created to run testConnection. The second process to run importData/importStructure may be queued in the Pool Manager and eventually timeout, then fail.
- Sibling flexible settings can have the same display name. Therefore, in scripts that access a setting via getSetting(displayName), only a single instance is returned, and there is no guarantee which one is returned. Users should be prevented from creating sibling flexible settings with the same display name.