Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Arregui committed Feb 12, 2024
1 parent 00c956f commit 96db925
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function main(program: Lifecycle.EntryPointParameters<AppComponents
// start ports: db, listeners, synchronizations, etc
await startComponents()

const { nats, config, logs, metrics, publisher, engine } = components
const { nats, config, logs, publisher, engine } = components

const flushFrequency = await config.requireNumber('ARCHIPELAGO_FLUSH_FREQUENCY')
const checkHeartbeatInterval = await config.requireNumber('CHECK_HEARTBEAT_INTERVAL')
Expand Down
28 changes: 22 additions & 6 deletions ws-connector/src/controllers/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ export async function setupRoutes(context: GlobalContext): Promise<Router<Global
}
}

// TODO
// * - GET /health/ready - readyness probe
// * - GET /health/startup - startup probe
// * - GET /health/live - liveness probe

registerWsHandler(context.components)
await registerWsHandler(context.components)

{
const handler = await createStatusHandler(context.components)
Expand All @@ -61,5 +56,26 @@ export async function setupRoutes(context: GlobalContext): Promise<Router<Global
server.app.get(path, handler)
}

// TODO: do I need to implement these?
// * - GET /health/ready - readyness probe
// * - GET /health/startup - startup probe

server.app.any('/health/live', (res, req) => {
const { end, labels } = onRequestStart(metrics, req.getMethod(), '/health/live')
res.writeStatus('200 OK')
res.writeHeader('Access-Control-Allow-Origin', '*')
res.end('alive')
onRequestEnd(metrics, labels, 404, end)
})

server.app.any('/*', (res, req) => {
const { end, labels } = onRequestStart(metrics, req.getMethod(), '')
res.writeStatus('404 Not Found')
res.writeHeader('Access-Control-Allow-Origin', '*')
res.writeHeader('content-type', 'application/json')
res.end(JSON.stringify({ error: 'Not Found' }))
onRequestEnd(metrics, labels, 404, end)
})

return router
}
2 changes: 1 addition & 1 deletion ws-connector/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type BaseComponents = {
}

// components used in runtime
export type AppComponents = BaseComponents & {}
export type AppComponents = BaseComponents

// components used in tests
export type TestComponents = BaseComponents & {
Expand Down

0 comments on commit 96db925

Please sign in to comment.