Module

computeRun

Prepare data for runCompute(@async)

Parameters:
Name Type Attributes Description
store store

restaf store

session rafObject

current compute service session

src string

code to execute

macros object <optional>

macros as a json

timeout number <optional>

long polling timeout in seconds

checkStatus function <optional>

callback to check on status

userContext object <optional>

this is passed to the statusHandler

computeSummary object. Job Status is computeSummary.SASJobStatus

promise
Example
The job status will be one of these  completed|warning|error|failed
  Typical call:
     let computeSummary = await computeRun(store,computeSession, src, args);

  Advanced call: If you want to track the job status pass a checkStatus function with some context
 
     const checkStatus = (state, context) => {
         console.log('state', state);
         console.log('context ', context);
        // do something useful - like in an UI display status for user
        
        // To stop waiting on job completion return a state value like 'exit' or any string
        // the value has to be something other than the state passed in.
        // this will force the code to stop waiting on the server and return to the app.
        // It is upto your app to take appropriate actions(like cancelling the job)
        // Below is a trivial example
        context.counter = context.counter + 1;
		if (state === 'running' && context.counter > 5) {
			context.realState = state;
			state = 'exit';
        }
        return state;
     } // return true if you want to stop waiting on the job. Does not cancel the job
 
===============================================
A simple example

    async function runtest(store, logonPayload) {
        let computeSession = await restaflib.computeSetup(store, null, logonPayload);
        let macros = {
            data: 'sashelp.cars'
        };
        let src = `
                ods html style=barrettsblue;  
                proc print data=&data;run;
                ods html close; 
                run;
                `;
 
        let computeSummary = await restaflib.computeRun(
            store,
            computeSession,
            src,
            macros
        );
        console.log('Job Status: ', computeSummary.SASJobStatus);

         let log = await restaflib.computeResults(store, computeSummary, "log");
        let ods = await restaflib.computeResults(store, computeSummary, "ods");
        return 'done';

    }