@blued-core/healthchecks-client
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

healthchecks-client

示例

import { createWrapper, PingClientConfig } from '../src/index'

const config: PingClientConfig = {
  baseURL: '/healthchecks/host',
  checks: {
    test: '/healthchecks/test',
  }
}

const sleep = (ms: number) => new Promise(r => setTimeout(r, ms))

const test = async () => {
  console.log('test start')
  await sleep(1000)
  console.log('test end')
}

(async function main() {
  try {
    const wrapper = createWrapper(config)
    // 第二个参数必须是配置项 checks 中的 key
    await wrapper(test, 'test')()
  } catch (e) {
    console.error('error', e)
  }
})()

// 定时任务中使用
import { scheduleJob } from 'node-schedule'

scheduleJob('1 0 0 * * *', wrapper(test, 'test'))

Readme

Keywords

none

Package Sidebar

Install

npm i @blued-core/healthchecks-client

Weekly Downloads

2

Version

0.1.1

License

ISC

Unpacked Size

10.6 kB

Total Files

6

Last publish

Collaborators

  • chisecc
  • jarvan8888
  • jiasm
  • ryli
  • nieweidong
  • fengcang2020