@adonis-agora/durable 1.0.0-rc.15 → 1.0.0-rc.16
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/CHANGELOG.md +6 -0
- package/dist/providers/durable_provider.d.ts.map +1 -1
- package/dist/providers/durable_provider.js +2 -0
- package/dist/providers/durable_provider.js.map +1 -1
- package/dist/src/dashboard/index.d.ts +1 -1
- package/dist/src/dashboard/index.js +1 -1
- package/dist/src/define_config.d.ts +8 -0
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/doctor/checks.d.ts +6 -0
- package/dist/src/doctor/checks.d.ts.map +1 -1
- package/dist/src/doctor/checks.js +91 -0
- package/dist/src/doctor/checks.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/sql-schema.d.ts +54 -0
- package/dist/src/sql-schema.d.ts.map +1 -0
- package/dist/src/sql-schema.js +145 -0
- package/dist/src/sql-schema.js.map +1 -0
- package/dist/src/stores/factory.d.ts +6 -0
- package/dist/src/stores/factory.d.ts.map +1 -1
- package/dist/src/stores/factory.js +3 -0
- package/dist/src/stores/factory.js.map +1 -1
- package/dist/src/stores/lucid-schema.d.ts +17 -3
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +84 -62
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +27 -0
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +253 -205
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/transports/db-schema.d.ts +13 -5
- package/dist/src/transports/db-schema.d.ts.map +1 -1
- package/dist/src/transports/db-schema.js +50 -32
- package/dist/src/transports/db-schema.js.map +1 -1
- package/dist/src/transports/db.d.ts +6 -0
- package/dist/src/transports/db.d.ts.map +1 -1
- package/dist/src/transports/db.js +49 -39
- package/dist/src/transports/db.js.map +1 -1
- package/dist/src/transports/factory.d.ts +16 -0
- package/dist/src/transports/factory.d.ts.map +1 -1
- package/dist/src/transports/factory.js +6 -1
- package/dist/src/transports/factory.js.map +1 -1
- package/dist/src/transports/worker-keys-db.d.ts +5 -0
- package/dist/src/transports/worker-keys-db.d.ts.map +1 -1
- package/dist/src/transports/worker-keys-db.js +10 -8
- package/dist/src/transports/worker-keys-db.js.map +1 -1
- package/dist/stubs/database/migrations/create_durable_tables.stub +12 -2
- package/dist/stubs/database/migrations/create_durable_transport_messages.stub +34 -5
- package/dist/stubs/database/migrations/create_durable_transport_tables.stub +30 -8
- package/dist/stubs/database/migrations/create_durable_transport_worker_keys.stub +24 -2
- package/package.json +1 -1
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{{{
|
|
2
2
|
exports({ to: app.migrationsPath(`${new Date().getTime()}_create_durable_transport_tables.ts`) })
|
|
3
3
|
}}}
|
|
4
|
+
import app from '@adonisjs/core/services/app'
|
|
4
5
|
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* The database schema the tables live in (a database on MySQL): the top-level
|
|
9
|
+
* \`schema\` of config/durable.ts, read when the migration runs (\`undefined\` uses the
|
|
10
|
+
* connection's current schema). If you set it on \`transports.db({ schema })\` (or on the queue
|
|
11
|
+
* transport's \`workerKeysSchema\`) instead, put that value here.
|
|
12
|
+
*/
|
|
13
|
+
const configured = app.config.get('durable.schema', undefined)
|
|
14
|
+
const schema = typeof configured === 'string' ? configured : undefined
|
|
15
|
+
|
|
16
|
+
/** \`name\` in {@link schema}: Knex quotes \`schema.table\` part by part. */
|
|
17
|
+
const inSchema = (name: string) => (schema ? \`\${schema}.\${name}\` : name)
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* Transport tables for the @adonis-agora/durable \`db\` transport: the point-to-point work channels (tasks /
|
|
8
21
|
* results / heartbeats / control) that let durable remote steps run cross-process over the database
|
|
@@ -12,7 +25,16 @@ import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
12
25
|
*/
|
|
13
26
|
export default class extends BaseSchema {
|
|
14
27
|
async up() {
|
|
15
|
-
|
|
28
|
+
if (schema) {
|
|
29
|
+
// Runs before the tables below (calls run in order); \`??\` quotes the name as an identifier.
|
|
30
|
+
this.defer(async (db) => {
|
|
31
|
+
await db.rawQuery(
|
|
32
|
+
db.dialect.name === 'mysql' ? 'create database if not exists ??' : 'create schema if not exists ??',
|
|
33
|
+
[schema]
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
this.schema.createTable(inSchema('durable_transport_tasks'), (table) => {
|
|
16
38
|
table.string('step_id').primary()
|
|
17
39
|
table.string('run_id').notNullable()
|
|
18
40
|
table.integer('seq').notNullable()
|
|
@@ -33,7 +55,7 @@ export default class extends BaseSchema {
|
|
|
33
55
|
table.index(['namespace', 'grp', 'claimed_at', 'created_at'], 'durable_transport_tasks_grp_idx')
|
|
34
56
|
})
|
|
35
57
|
|
|
36
|
-
this.schema.createTable('durable_transport_results', (table) => {
|
|
58
|
+
this.schema.createTable(inSchema('durable_transport_results'), (table) => {
|
|
37
59
|
table.string('step_id').primary()
|
|
38
60
|
table.string('run_id').notNullable()
|
|
39
61
|
table.integer('seq').notNullable()
|
|
@@ -49,7 +71,7 @@ export default class extends BaseSchema {
|
|
|
49
71
|
table.index(['namespace', 'claimed_at', 'created_at'], 'durable_transport_results_idx')
|
|
50
72
|
})
|
|
51
73
|
|
|
52
|
-
this.schema.createTable('durable_transport_heartbeats', (table) => {
|
|
74
|
+
this.schema.createTable(inSchema('durable_transport_heartbeats'), (table) => {
|
|
53
75
|
table.increments('id').primary()
|
|
54
76
|
table.string('run_id').notNullable()
|
|
55
77
|
table.integer('seq').notNullable()
|
|
@@ -62,7 +84,7 @@ export default class extends BaseSchema {
|
|
|
62
84
|
table.index(['namespace', 'claimed_at', 'created_at'], 'durable_transport_heartbeats_idx')
|
|
63
85
|
})
|
|
64
86
|
|
|
65
|
-
this.schema.createTable('durable_transport_control', (table) => {
|
|
87
|
+
this.schema.createTable(inSchema('durable_transport_control'), (table) => {
|
|
66
88
|
table.increments('id').primary()
|
|
67
89
|
table.text('payload', 'longtext').notNullable()
|
|
68
90
|
table.string('namespace').notNullable().defaultTo('default')
|
|
@@ -74,9 +96,9 @@ export default class extends BaseSchema {
|
|
|
74
96
|
}
|
|
75
97
|
|
|
76
98
|
async down() {
|
|
77
|
-
this.schema.dropTableIfExists('durable_transport_control')
|
|
78
|
-
this.schema.dropTableIfExists('durable_transport_heartbeats')
|
|
79
|
-
this.schema.dropTableIfExists('durable_transport_results')
|
|
80
|
-
this.schema.dropTableIfExists('durable_transport_tasks')
|
|
99
|
+
this.schema.dropTableIfExists(inSchema('durable_transport_control'))
|
|
100
|
+
this.schema.dropTableIfExists(inSchema('durable_transport_heartbeats'))
|
|
101
|
+
this.schema.dropTableIfExists(inSchema('durable_transport_results'))
|
|
102
|
+
this.schema.dropTableIfExists(inSchema('durable_transport_tasks'))
|
|
81
103
|
}
|
|
82
104
|
}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{{{
|
|
2
2
|
exports({ to: app.migrationsPath(`${new Date().getTime()}_create_durable_transport_worker_keys.ts`) })
|
|
3
3
|
}}}
|
|
4
|
+
import app from '@adonisjs/core/services/app'
|
|
4
5
|
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* The database schema the tables live in (a database on MySQL): the top-level
|
|
9
|
+
* \`schema\` of config/durable.ts, read when the migration runs (\`undefined\` uses the
|
|
10
|
+
* connection's current schema). If you set it on \`transports.db({ schema })\` (or on the queue
|
|
11
|
+
* transport's \`workerKeysSchema\`) instead, put that value here.
|
|
12
|
+
*/
|
|
13
|
+
const configured = app.config.get('durable.schema', undefined)
|
|
14
|
+
const schema = typeof configured === 'string' ? configured : undefined
|
|
15
|
+
|
|
16
|
+
/** \`name\` in {@link schema}: Knex quotes \`schema.table\` part by part. */
|
|
17
|
+
const inSchema = (name: string) => (schema ? \`\${schema}.\${name}\` : name)
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* The worker advertisement keys for the @adonis-agora/durable \`db\` transport: the descriptor and
|
|
8
21
|
* heartbeat a worker runtime publishes (what it serves, and that it is alive), each with an expiry so a
|
|
@@ -10,7 +23,16 @@ import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
10
23
|
*/
|
|
11
24
|
export default class extends BaseSchema {
|
|
12
25
|
async up() {
|
|
13
|
-
|
|
26
|
+
if (schema) {
|
|
27
|
+
// Runs before the tables below (calls run in order); \`??\` quotes the name as an identifier.
|
|
28
|
+
this.defer(async (db) => {
|
|
29
|
+
await db.rawQuery(
|
|
30
|
+
db.dialect.name === 'mysql' ? 'create database if not exists ??' : 'create schema if not exists ??',
|
|
31
|
+
[schema]
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
this.schema.createTable(inSchema('durable_transport_worker_keys'), (table) => {
|
|
14
36
|
table.string('key', 512).primary()
|
|
15
37
|
table.text('value', 'longtext').notNullable()
|
|
16
38
|
table.bigInteger('expires_at').notNullable()
|
|
@@ -19,6 +41,6 @@ export default class extends BaseSchema {
|
|
|
19
41
|
}
|
|
20
42
|
|
|
21
43
|
async down() {
|
|
22
|
-
this.schema.dropTableIfExists('durable_transport_worker_keys')
|
|
44
|
+
this.schema.dropTableIfExists(inSchema('durable_transport_worker_keys'))
|
|
23
45
|
}
|
|
24
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/durable",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.16",
|
|
4
4
|
"description": "Durable cross-app workflows for AdonisJS — deterministic replay engine, AdonisJS binding, ace commands, dashboard, OpenTelemetry, Telescope, testing harness and Redis admission, all in one package. Part of the Agora ecosystem.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|