0.3.1 • Published 4 years ago

@arkie-ai/job-manager-client v0.3.1

Weekly downloads
11
License
ISC
Repository
gitlab
Last release
4 years ago

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)
0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago