@platformatic/watt-extra 1.11.0 → 1.11.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.11.0",
3
+ "version": "1.11.1-alpha.0",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -162,9 +162,32 @@ async function healthSignals (app, _opts) {
162
162
  }
163
163
  }
164
164
  runtime.on('application:worker:health:metrics', healthMetricsListener)
165
+ await sendReadyStatus()
165
166
  }
166
167
  app.setupHealthSignals = setupHealthSignals
167
168
 
169
+ async function sendReadyStatus () {
170
+ const scalerUrl = app.instanceConfig?.iccServices?.scaler?.url
171
+ const applicationId = app.instanceConfig?.applicationId
172
+ const runtimeId = app.getRuntimeId()
173
+ const timestamp = Date.now()
174
+ const authHeaders = await app.getAuthorizationHeader()
175
+
176
+ const { statusCode, body } = await request(`${scalerUrl}/ready`, {
177
+ method: 'POST',
178
+ headers: {
179
+ 'Content-Type': 'application/json',
180
+ ...authHeaders
181
+ },
182
+ body: JSON.stringify({ applicationId, runtimeId, timestamp })
183
+ })
184
+
185
+ if (statusCode !== 200) {
186
+ const error = await body.text()
187
+ app.log.error({ error }, 'Failed to send the instance ready status to scaler')
188
+ }
189
+ }
190
+
168
191
  async function sendHealthSignals (rawSignals, batchStartedAt) {
169
192
  const scalerUrl = app.instanceConfig?.iccServices?.scaler?.url
170
193
  const applicationId = app.instanceConfig?.applicationId
@@ -19,6 +19,7 @@ test('should send health signals when service becomes unhealthy', async (t) => {
19
19
 
20
20
  const receivedSignalReqs = []
21
21
  const receivedFlamegraphReqs = []
22
+ let receivedReadyReq = null
22
23
 
23
24
  const getAuthorizationHeader = async (headers) => {
24
25
  return { ...headers, authorization: 'Bearer test-token' }
@@ -28,6 +29,10 @@ test('should send health signals when service becomes unhealthy', async (t) => {
28
29
  applicationId,
29
30
  applicationName,
30
31
  scaler: { version: 'v2' },
32
+ processReady: (req) => {
33
+ receivedReadyReq = req.body
34
+ return { success: true }
35
+ },
31
36
  processSignals: (req) => {
32
37
  assert.equal(req.headers.authorization, 'Bearer test-token')
33
38
  receivedSignalReqs.push(req.body)
@@ -92,6 +97,12 @@ test('should send health signals when service becomes unhealthy', async (t) => {
92
97
  assert.strictEqual(statusCode, 200)
93
98
  }
94
99
 
100
+ // Verify ready signal was sent to /ready endpoint
101
+ assert.ok(receivedReadyReq, 'Ready request should have been received')
102
+ assert.strictEqual(receivedReadyReq.applicationId, applicationId)
103
+ assert.ok(receivedReadyReq.runtimeId, 'runtimeId should be present')
104
+ assert.ok(typeof receivedReadyReq.timestamp === 'number', 'timestamp should be a number')
105
+
95
106
  // Multiple batches may be sent due to timing, verify we received at least one
96
107
  assert.ok(receivedSignalReqs.length >= 1, `Expected at least 1 signal request, got ${receivedSignalReqs.length}`)
97
108
 
package/test/helper.js CHANGED
@@ -182,6 +182,9 @@ async function startICC (t, opts = {}) {
182
182
  icc.post('/signals', async (req) => {
183
183
  return opts.processSignals?.(req)
184
184
  })
185
+ icc.post('/ready', async (req) => {
186
+ return opts.processReady?.(req) ?? { success: true }
187
+ })
185
188
  icc.post('/pods/:podId/services/:serviceId/flamegraph', async (req) => {
186
189
  return opts.processFlamegraphs?.(req)
187
190
  })
@@ -1,6 +0,0 @@
1
- ignoredBuiltDependencies:
2
- - '@datadog/pprof'
3
- - msgpackr-extract
4
- - protobufjs
5
- - sharp
6
- - unrs-resolver