A Simple Function
Scramjet's Sequence is a simple function that calls other functions in an asynchronous way. It's wrapped up in a tar.gz file and sent to Scramjet's Transform Hub.
In this example the main function calls the getPageFromAPI()
function and returns a string value.
- JavaScript
- TypeScript
- Python
async function getPageFromAPI() {
return "Your result";
}
module.exports = async function (_stream, timeout = 10000) {
await new Promise(res => setTimeout(res, timeout));
return getPageFromAPI();
}
import asyncio
def get_page_from_api():
return "Your result \n"
async def run(self, input):
await asyncio.sleep(10)
return get_page_from_api()
function getPageFromApi(){
return "Your result";
};
export default async function* () {
await new Promise(resolve => setTimeout(resolve, 10000));
yield await getPageFromApi();
}
To create a Sequence, define a function that encapsulates the data processing task you wish to solve. Bundle the function with dependencies into a deployable package (tar.gz). Upload the package to Scramjet Transform Hub or Cloud Platform for deployment. The Sequence will be stored and ready for execution. In the next section we will demonstrate how to simply pack and send a Sequence.