Skip to content

Add health check method #74

Open
Open
@razor-x

Description

@razor-x

Add property that is updated via background polling

const seam = new Seam()
seam.isHealthy // boolean

Allow configuring behavior

const seam = new Seam({
  pollHealth: true
})
seam.isHealthy // false
// first health check happens right away, but needs to wait for at least next tick to update
await sleep(500)
seam.isHealthy // true

```ts
const seam = new Seam({
  pollHealth: {
    pollingInterval: 1000,
    timeout: 5000, // timeout error will set isHealthy false
    onError: (err: Error) => { console.log(err) }
  },
})
seam.isHealthy // false
await sleep(500)
seam.isHealthy // true
const seam = new Seam({
  pollHealth: false
})
seam.isHealthy // false
await seam.updateHealth()
seam.isHealthy // true

By default, { pollHealth: false }.
The seam.isHealthy property should be implemented as a getter and will start false. It should throw if accessed but { pollingInterval: false } or seam.updateHealth was not called at least once.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions