@platformatic/watt-extra 1.0.1-alpha.2 → 1.0.1-alpha.3

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/lib/watt.js CHANGED
@@ -92,28 +92,28 @@ class Watt {
92
92
  }
93
93
  }
94
94
 
95
- if (config.resources?.services && config.resources.services.length > 0) {
96
- const resourceUpdates = config.resources.services.map((service) => ({
97
- service: service.name,
98
- workers: service.threads,
99
- health: {
100
- maxHeapTotal: `${service.heap}MB`,
101
- },
102
- }))
103
-
104
- try {
105
- await this.runtime.updateServicesResources(resourceUpdates)
106
- this.#logger.info(
107
- { resourceUpdates },
108
- 'Successfully updated service resources'
109
- )
110
- } catch (err) {
111
- this.#logger.error(
112
- { err, resourceUpdates },
113
- 'Failed to update service resources'
114
- )
115
- }
116
- }
95
+ // if (config.resources?.services && config.resources.services.length > 0) {
96
+ // const resourceUpdates = config.resources.services.map((service) => ({
97
+ // service: service.name,
98
+ // workers: service.threads,
99
+ // health: {
100
+ // maxHeapTotal: `${service.heap}MB`,
101
+ // },
102
+ // }))
103
+ //
104
+ // try {
105
+ // await this.runtime.updateServicesResources(resourceUpdates)
106
+ // this.#logger.info(
107
+ // { resourceUpdates },
108
+ // 'Successfully updated service resources'
109
+ // )
110
+ // } catch (err) {
111
+ // this.#logger.error(
112
+ // { err, resourceUpdates },
113
+ // 'Failed to update service resources'
114
+ // )
115
+ // }
116
+ // }
117
117
  }
118
118
 
119
119
  async updateSharedContext (context) {
@@ -424,43 +424,43 @@ class Watt {
424
424
  }
425
425
 
426
426
  #configureSystemResources (config) {
427
- if (!this.#instanceConfig) {
428
- return
429
- }
430
- // Set system wide resources
431
- const resources = this.#instanceConfig?.config?.resources
432
- if (!resources) {
433
- return
434
- }
435
-
436
- const { threads, heap } = resources
437
-
438
- if (threads > 0) {
439
- config.workers = threads
440
- }
441
-
442
- if (heap > 0) {
443
- config.health ??= {}
444
- config.health.maxHeapTotal = heap * 1024 * 1024
445
- }
446
-
447
- // In v3 we renamed services to applications, so we support both (note that this is coming from icc)
448
- const res = resources.services || resources.applications
449
-
450
- // Set services resources
451
- for (const application of config.applications ?? []) {
452
- let applicationResources = res?.find((s) => s.name === application.id)
453
-
454
- if (!applicationResources) {
455
- applicationResources = {
456
- threads,
457
- heap,
458
- }
459
- }
460
- application.workers = applicationResources.threads
461
- application.health ??= {}
462
- application.health.maxHeapTotal = applicationResources.heap * 1024 * 1024
463
- }
427
+ // if (!this.#instanceConfig) {
428
+ // return
429
+ // }
430
+ // // Set system wide resources
431
+ // const resources = this.#instanceConfig?.config?.resources
432
+ // if (!resources) {
433
+ // return
434
+ // }
435
+ //
436
+ // const { threads, heap } = resources
437
+ //
438
+ // if (threads > 0) {
439
+ // config.workers = threads
440
+ // }
441
+ //
442
+ // if (heap > 0) {
443
+ // config.health ??= {}
444
+ // config.health.maxHeapTotal = heap * 1024 * 1024
445
+ // }
446
+ //
447
+ // // In v3 we renamed services to applications, so we support both (note that this is coming from icc)
448
+ // const res = resources.services || resources.applications
449
+ //
450
+ // // Set services resources
451
+ // for (const application of config.applications ?? []) {
452
+ // let applicationResources = res?.find((s) => s.name === application.id)
453
+ //
454
+ // if (!applicationResources) {
455
+ // applicationResources = {
456
+ // threads,
457
+ // heap,
458
+ // }
459
+ // }
460
+ // application.workers = applicationResources.threads
461
+ // application.health ??= {}
462
+ // application.health.maxHeapTotal = applicationResources.heap * 1024 * 1024
463
+ // }
464
464
  }
465
465
 
466
466
  async #configureServices (runtime) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.0.1-alpha.2",
3
+ "version": "1.0.1-alpha.3",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -16,10 +16,10 @@ const __dirname = dirname(__filename)
16
16
  const require = createRequire(import.meta.url)
17
17
  const platformaticVersion = require('@platformatic/runtime/package.json').version
18
18
 
19
- test('should spawn a service app sending the state', async (t) => {
19
+ test.only('should spawn a service app sending the state', async (t) => {
20
20
  const applicationName = 'test-app'
21
21
  const applicationId = randomUUID()
22
- const applicationPath = join(__dirname, 'fixtures', 'service-1')
22
+ const applicationPath = '/Users/ivan-tymoshenko/projects/platformatic/leads-demo'
23
23
 
24
24
  const applicationStates = []
25
25
 
@@ -49,29 +49,30 @@ test('should spawn a service app sending the state', async (t) => {
49
49
  await icc.close()
50
50
  })
51
51
 
52
- {
53
- const { statusCode, body } = await request('http://127.0.0.1:3042/example')
54
- assert.strictEqual(statusCode, 200)
55
-
56
- const data = await body.json()
57
- assert.deepStrictEqual(data, { hello: 'world' })
58
- }
59
-
60
- assert.strictEqual(applicationStates.length, 1)
61
- const [state] = applicationStates
62
- assert.strictEqual(state.instanceId, hostname())
63
- assert.strictEqual(
64
- state.state.metadata.platformaticVersion,
65
- platformaticVersion
66
- )
67
-
68
- assert.strictEqual(state.state.services.length, 1)
69
- const [service] = state.state.services
70
-
71
- assert.strictEqual(service.id, 'main')
72
- assert.strictEqual(service.workers, 1)
73
- assert.strictEqual(service.maxWorkers, 1)
74
- assert.strictEqual(service.minWorkers, 1)
52
+ process._rawDebug('--------spawn.test.js---23--------', applicationStates[0].state.services)
53
+ // {
54
+ // const { statusCode, body } = await request('http://127.0.0.1:3042/example')
55
+ // assert.strictEqual(statusCode, 200)
56
+ //
57
+ // const data = await body.json()
58
+ // assert.deepStrictEqual(data, { hello: 'world' })
59
+ // }
60
+ //
61
+ // assert.strictEqual(applicationStates.length, 1)
62
+ // const [state] = applicationStates
63
+ // assert.strictEqual(state.instanceId, hostname())
64
+ // assert.strictEqual(
65
+ // state.state.metadata.platformaticVersion,
66
+ // platformaticVersion
67
+ // )
68
+ //
69
+ // assert.strictEqual(state.state.services.length, 1)
70
+ // const [service] = state.state.services
71
+ //
72
+ // assert.strictEqual(service.id, 'main')
73
+ // assert.strictEqual(service.workers, 1)
74
+ // assert.strictEqual(service.maxWorkers, 1)
75
+ // assert.strictEqual(service.minWorkers, 1)
75
76
  })
76
77
 
77
78
  test('should not fail on worker error', async (t) => {