lonnymq 0.0.22 → 0.0.24

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/README.md CHANGED
@@ -26,9 +26,9 @@ databaseClient satisfies DatabaseClient
26
26
 
27
27
  const queue = new Queue({ schema: "lonny" })
28
28
 
29
- // Run migrations first
30
- for (const migration of queue.migrations()) {
31
- await databaseClient.query(migration, [])
29
+ // Install the queue
30
+ for (const sql of queue.install()) {
31
+ await databaseClient.query(sql, [])
32
32
  }
33
33
 
34
34
  // Create messages
@@ -60,26 +60,7 @@ LonnyMQ can be installed from npm:
60
60
  npm install lonnymq
61
61
  ```
62
62
 
63
- Once the package is installed, you need to install the required database schema. LonnyMQ is agnostic to database client and migration process, providing users with an ordered list of migrations - each containing a unique name and SQL fragments to be executed.
64
-
65
- ```typescript
66
- const queue = new Queue({ schema: "lonny" })
67
- const migrations = queue.migrations()
68
-
69
- // Execute migrations (in a transaction for safety)
70
- await databaseClient.query("BEGIN")
71
- try {
72
- for (const migration of migrations) {
73
- await databaseClient.query(migration, [])
74
- }
75
- await databaseClient.query("COMMIT")
76
- } catch (error) {
77
- await databaseClient.query("ROLLBACK")
78
- throw error
79
- }
80
- ```
81
-
82
- **Note:** Migration SQL is not idempotent and should be executed within a transaction that can be rolled back if an error occurs.
63
+ Once the package is installed, the queue needs to be "installed" to a postgres schema. The requisite SQL for this can be generated via: `queue.install()`.
83
64
 
84
65
  ## Channels
85
66
 
@@ -194,10 +175,10 @@ Using PostgreSQL `NOTIFY`, we can receive a granular stream of queue events:
194
175
  2. `MESSAGE_DEFERRED`
195
176
  4. `MESSAGE_DELETED`
196
177
 
197
- To enable this feature, ensure the optional `eventChannel` is defined when constructing the SQL migrations.
178
+ To enable this feature, ensure the optional `eventChannel` is defined when generating the installation SQL.
198
179
 
199
180
  ```typescript
200
- const migrations = queue.migrations({ eventChannel: "EVENTS"})
181
+ const install = queue.install({ eventChannel: "EVENTS"})
201
182
  ```
202
183
 
203
184
  ### Improving on Polling