Commit 3d1cb720 authored by Will Cory's avatar Will Cory Committed by GitHub

feat(common-ts): BSV2 Add version to healthz for convenience (#2815)

* add version to healthz for convenience

* changeset
Co-authored-by: default avatarWill Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent b09bc9bc
---
'@eth-optimism/common-ts': minor
---
Add version to healthz for convenience
...@@ -144,17 +144,19 @@ export abstract class BaseServiceV2< ...@@ -144,17 +144,19 @@ export abstract class BaseServiceV2<
* @param params.port Port for the app server. Defaults to 7300. * @param params.port Port for the app server. Defaults to 7300.
* @param params.hostname Hostname for the app server. Defaults to 0.0.0.0. * @param params.hostname Hostname for the app server. Defaults to 0.0.0.0.
*/ */
constructor(params: { constructor(
name: string private readonly params: {
version: string name: string
optionsSpec: OptionsSpec<TOptions> version: string
metricsSpec: MetricsSpec<TMetrics> optionsSpec: OptionsSpec<TOptions>
options?: Partial<TOptions> metricsSpec: MetricsSpec<TMetrics>
loop?: boolean options?: Partial<TOptions>
loopIntervalMs?: number loop?: boolean
port?: number loopIntervalMs?: number
hostname?: string port?: number
}) { hostname?: string
}
) {
this.loop = params.loop !== undefined ? params.loop : true this.loop = params.loop !== undefined ? params.loop : true
this.state = {} as TServiceState this.state = {} as TServiceState
...@@ -404,6 +406,7 @@ export abstract class BaseServiceV2< ...@@ -404,6 +406,7 @@ export abstract class BaseServiceV2<
app.get('/healthz', async (req, res) => { app.get('/healthz', async (req, res) => {
return res.json({ return res.json({
ok: this.healthy, ok: this.healthy,
version: this.params.version,
}) })
}) })
...@@ -429,7 +432,7 @@ export abstract class BaseServiceV2< ...@@ -429,7 +432,7 @@ export abstract class BaseServiceV2<
} }
return '/invalid_path_not_a_real_route' return '/invalid_path_not_a_real_route'
} },
}) })
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment