@arkie-ai/job-manager-client
v0.3.1
Published
Client for arkie job-manager service
Downloads
18
Readme
job-manager-client
Client for arkie job manager
Usage
npm install --save @arkie-ai/job-manager-client
// or yarn add @arkie-ai/job-manager-client
导入依赖并初始化:
const {JobManagerClient, SubscriptionType} = require("@arkie-ai/job-manager-client");
const client = new JobManagerClient({
endpoint: 'http://localhost:8080/api/v1/job-manager/',
wsEndpoint: 'ws://localhost:8080/',
token: '登录后获取的 token'
});
创建作业
client.createJob({
name: 'test_job',
maxTasks: 3
}).then(console.log).catch(console.error)
获取作业详情
client.getJob('job id').then(console.log).catch(console.error)
创建任务
client.createTask({
"topic": "test",
"priority": 3,
"jobId": "job id",
"name": "task test5",
"attempts": 3,
"delay": 0,
"processor": "http",
"callbackUrl": "http://foo.bar",
"processorOptions": {
"url": "https://httpbin.org/post",
"headers": {
"content-type": "application/json"
},
"method": "post"
}
}).then(console.log).catch(console.error)
获取任务详情
client.getTask('task id').then(console.log).catch(console.error)
订阅任务回调
client.on(SubscriptionType.TASK_CALLBACK, (ret) => {
console.log(ret)
})
client.subscribe(SubscriptionType.TASK_CALLBACK, { topics: ['xxx'] }).then(console.log)