Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions PROVISIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ The provisioning document is a JSON document with the project at the root.
"name": "<<job-name>>",
"body": "<<job-body>>",
"adaptor": "<<adaptor-name>>",
"enabled": true
}
"enabled": true,
},
// ... more jobs
],
"triggers": [
{
"id": "<<trigger-id>>",
"name": "<<trigger-name>>",
"type": "webhook"
}
"type": "webhook",
},
// ... more triggers
],
"edges": [
{
"id": "<<edge-id>>",
"source_trigger_id": "<<trigger-id>>",
"target_job_id": "<<job-id>>"
}
"target_job_id": "<<job-id>>",
},
// ... more edges
]
}
],
},
// ... more workflows
]
],
}
```

Expand Down Expand Up @@ -96,11 +96,11 @@ Example:
"jobs": [
{
"id": "<<job-id>>",
"delete": true // <== delete this job
}
]
}
]
"delete": true, // <== delete this job
},
],
},
],
}
```

Expand Down Expand Up @@ -149,9 +149,9 @@ Using the example above a state file might look like this:
"workflow-one": {
"id": "f206aa85-4fce-492e-94eb-ffd32c75d178",
"jobs": {},
"triggers": {}
}
}
"triggers": {},
},
},
}
```

Expand Down
12 changes: 6 additions & 6 deletions WORKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ The OpenFn Runtime used by Lightning is a [Node.js](https://nodejs.org/en/)
application that runs on a server. It is responsible for executing the code that
you write in your OpenFn jobs.

A Runtime Manager is a module or application that processes Runs, which
contains reference to the Workflow, the starting point and the initial data.
A Runtime Manager is a module or application that processes Runs, which contains
reference to the Workflow, the starting point and the initial data.

Runs are enqueued, and Runtime Managers request work to be performed when
they are ready.
Runs are enqueued, and Runtime Managers request work to be performed when they
are ready.

## History

In previous versions of OpenFn products, the server would invoke a NodeJS child
process for each Run that needs to be executed. Deciding which Job to run in a
workflow is decided after each run is completed.

The current approach to executing Runs, is that a worker checks out the
entire run and executes it and all the jobs required.
The current approach to executing Runs, is that a worker checks out the entire
run and executes it and all the jobs required.

The advantage of this approach is a significant reduction in latency of
launching new workers for every Run to be processed.
Expand Down
6 changes: 2 additions & 4 deletions priv/runtime/logger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function generateRandomString(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
Expand All @@ -13,15 +14,13 @@ function generateRandomString(length) {
// Number of bytes you want (1023 in this case)
const numberOfBytes = 1023;


const logInterval = 3000; // Logging interval in milliseconds

// Function to log a message
function logMessage() {
// Generate a random string of the specified length
const randomString = generateRandomString(numberOfBytes);


for (let i = 0; i < randomString.length; i++) {
process.stdout.write(randomString.charAt(i));
}
Expand All @@ -30,7 +29,6 @@ function logMessage() {
process.stdout.write('😀');

process.stdout.write('\n');

}

// Start logging
Expand Down
12 changes: 6 additions & 6 deletions tooling/benchmarking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Execute the following steps to run a benchmark on Lightning:
`webhookURL` is already set to default to the webhook created in the demo
data

If you would like to point at a different instance or webhook url you
can provide it via `WEBHOOK_URL`.
If you would like to point at a different instance or webhook url you can
provide it via `WEBHOOK_URL`.

5. In another terminal (do not stop the Lightning server) run the
`tooling/benchmarking/script.js` file using the following command
Expand Down Expand Up @@ -129,10 +129,10 @@ webhookRequests ✓ [======================================] 00/50 VUs 2m20s 0

## Run load tests for a hypothetical cold chain system

`tooling/benchmarking/sample_cold_chain_monitoring_script.js` contains a k6 script that
can be used to simulate data from a hypothetical cold chain system. It requires a
custom job to be created (an example of which can be found at the top of the
script file).
`tooling/benchmarking/sample_cold_chain_monitoring_script.js` contains a k6
script that can be used to simulate data from a hypothetical cold chain system.
It requires a custom job to be created (an example of which can be found at the
top of the script file).

The test can be excuted as follows (`WEBHOOK_URL` is not optional):

Expand Down
16 changes: 8 additions & 8 deletions tooling/benchmarking/sample_cold_chain_monitoring_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
// attempts.forEach(function (_counter, _index) {
// state.data.records.forEach(function (record, _index) {
// console.log(record);
// });
// });
// });
//
// return new Promise((resolve, reject) => {
// setTimeout(() => {
// resolve(state);
// }, 10000);
// });
//
//
// });
//
//
// The above job will 'process' each of the objects in the array and then
// pause for 10 seconds before proceeding.

import http from 'k6/http';
import { check } from 'k6';

const webhookURL = __ENV.WEBHOOK_URL
const webhookURL = __ENV.WEBHOOK_URL;

export const options = {
discardResponseBodies: true,
Expand Down Expand Up @@ -58,15 +58,15 @@ export function setup() {

for (var i = 0; i < 500; i++) {
let time = base_timestamp + i;
let temperature = base_temperature + i/1000.0;
let temperature = base_temperature + i / 1000.0;

records.push({temperature: temperature, time: time})
records.push({ temperature: temperature, time: time });
}

return {
payload: {
records: records
}
records: records,
},
};
}

Expand Down