Skip to content

Commit

Permalink
feat(common-ts): BSV2 Add version to healthz for convenience (ethereu…
Browse files Browse the repository at this point in the history
…m-optimism#2815)

* add version to healthz for convenience

* changeset

Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 21, 2022
1 parent b09bc9b commit 3d1cb72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-ghosts-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/common-ts': minor
---

Add version to healthz for convenience
27 changes: 15 additions & 12 deletions packages/common-ts/src/base-service/base-service-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,19 @@ export abstract class BaseServiceV2<
* @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.
*/
constructor(params: {
name: string
version: string
optionsSpec: OptionsSpec<TOptions>
metricsSpec: MetricsSpec<TMetrics>
options?: Partial<TOptions>
loop?: boolean
loopIntervalMs?: number
port?: number
hostname?: string
}) {
constructor(
private readonly params: {
name: string
version: string
optionsSpec: OptionsSpec<TOptions>
metricsSpec: MetricsSpec<TMetrics>
options?: Partial<TOptions>
loop?: boolean
loopIntervalMs?: number
port?: number
hostname?: string
}
) {
this.loop = params.loop !== undefined ? params.loop : true
this.state = {} as TServiceState

Expand Down Expand Up @@ -404,6 +406,7 @@ export abstract class BaseServiceV2<
app.get('/healthz', async (req, res) => {
return res.json({
ok: this.healthy,
version: this.params.version,
})
})

Expand All @@ -429,7 +432,7 @@ export abstract class BaseServiceV2<
}

return '/invalid_path_not_a_real_route'
}
},
})
)

Expand Down

0 comments on commit 3d1cb72

Please sign in to comment.