Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health check method #74

Open
razor-x opened this issue Apr 4, 2024 · 0 comments
Open

Add health check method #74

razor-x opened this issue Apr 4, 2024 · 0 comments

Comments

@razor-x
Copy link
Member

razor-x commented Apr 4, 2024

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.

@razor-x razor-x added the javascript label Jan 15, 2025 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant