exframe-cg
v1.0.3
Published
A simple client for deploying and interaction with choreographer models.
Downloads
3
Readme
exframe-cg
A simple client for deploying and interaction with choreographer models.
Usage
const cgClient = require('exframe-cg').cgClient({
serviceUrl: 'http://choreographer.cg:9000',
headerPrefix: 'harmony-',
timeToRetry: 1000,
maxRetryAttempts: 5
});
Configuration Settings
- serviceUrl - The Url and port on which choreographer is listening
- headerPrefix - Prefix to use for http headers
- timeToRetry - default: 1000 number of milliseconds to wait before retrying a model deployment upon failure
- maxRetryAttempts - default: 190 number of times to retry deploying a model before giving up
Client
deploy
Deploys a model to the choreographer.
The deploy method requires a model file path and returns a promise. If the deployment initially fails, the deploy method will retry maxRetryAttempts
times before resolving or rejecting the promise.
cgClient.deploy(context, modelPath)
.then(result => {
console.log(`${modelPath} has been deployed`);
})
.catch(error => {
console.log(error);
});
Arguments:
- modelPath string The file path to the model
deployStub
Deploys a model stub to the choreographer.
The deployStub method requires a model file path and a model name. It returns a promise. If the deployment initially fails, the deployStub method will retry maxRetryAttempts
times before resolving or rejecting the promise.
cgClient.deployStub(context, modelName, stubPath)
.then(result => {
console.log(`${modelName} stub at ${stubPath} has been deployed`);
})
.catch(error => {
console.log(error);
})
Arguments
- modelName string The name of the model being stubbed
- stubPath string The file path to the model stub
start
Starts a model.
The start method requires a modelName and an object that the model instance uses as input data. It returns a promise that resolves with information about the newly created model instance.
cgClient.start(context, modelName, args)
.then(result => {
console.log(`Instance ${result.modelInstanceId} started.`);
})
.catch(error => {
console.log(error);
})
Arguments
- modelName string The name of the model being started
- args object An object containing input data for the model
instance
Gets status information about a model instance.
The instance method requires a model instance id. It returns a promise that resolves with an object containing instance information.
cgClient.instance(context, modelInstanceId)
.then(result => {
console.log(`Model instance ${modelInstanceId} has ${result.completedTasks.length} completed tasks`);
})
.catch(error => {
console.log(error);
})
Arguments
- modelInstanceId string The instance id of the model of interest.
completeTask
Completes a user task.
The completeTask method requires a model instance id and a task name. It takes an object containing user input that the model instance may use to complete the task. It returns a promise that resolves with an object containing model instance information.
cgClient.complete(context, modelInstanceId, taskName, args)
.then(result => {
console.log(`Model instance ${modelInstanceId} has ${result.completedTasks.length} completed tasks`);
})
.catch(error => {
console.log(error);
})
Arguments
- modelInstanceId string The instance id of the model of interest
- taskName string The name of the task to completed
- args object An object containing input data to be consumed by the model instance.
moveToTask
Moves the execution of the model instance back to a specific user task.
The moveToTask method requires a model instance id and a task name. It returns a promises that resolves with an object containing model instance information.
cgClient.moveToTask(context, modelInstanceId, taskName)
.then(result => {
console.log(`Model instance ${modelInstanceId} has ${result.completedTasks.length} completed tasks`);
})
.catch(error => {
console.log(error);
})
Arguments
- modelInstanceId string The instance id of the model of interest
- taskName string The name of the task to move model execution to