@toa.io/atomicity 1.0.0-alpha.308 → 1.0.0-alpha.311
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 +16 -0
- package/package.json +4 -4
- package/readme.md +8 -2
- package/src/atom.js +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.311](https://github.com/toa-io/toa/compare/v1.0.0-alpha.310...v1.0.0-alpha.311) (2026-09-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @toa.io/atomicity
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.0.0-alpha.310](https://github.com/toa-io/toa/compare/v1.0.0-alpha.309...v1.0.0-alpha.310) (2026-09-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @toa.io/atomicity
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [1.0.0-alpha.308](https://github.com/toa-io/toa/compare/v1.0.0-alpha.307...v1.0.0-alpha.308) (2026-09-15)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @toa.io/atomicity
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/atomicity",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.311",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa Atomicity Connector",
|
|
6
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@sesamecare-oss/redlock": "1.4.0",
|
|
21
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
22
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
21
|
+
"@toa.io/core": "1.0.0-alpha.311",
|
|
22
|
+
"@toa.io/generic": "1.0.0-alpha.311",
|
|
23
23
|
"ioredis": "6.0.0",
|
|
24
24
|
"n-and-i": "0.3.4",
|
|
25
25
|
"openspan": "1.0.0-alpha.305"
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "4f45061964e275296a27ff8ff39f757ce27d4008"
|
|
31
31
|
}
|
package/readme.md
CHANGED
|
@@ -85,6 +85,9 @@ const atom = new Factory().atom('mail.sender')
|
|
|
85
85
|
await atom.connect()
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
The group is the context's, so a process with Redis configured has `TOA_CONTEXT` — or `TOA_DEV=1`
|
|
89
|
+
— and an atom connecting without either throws.
|
|
90
|
+
|
|
88
91
|
## Configuration
|
|
89
92
|
|
|
90
93
|
Requires Redis.
|
|
@@ -106,5 +109,8 @@ and two tolerate none at all.
|
|
|
106
109
|
One set of clients per process, shared by every atom in it, and an unreachable Redis does not fail
|
|
107
110
|
a start.
|
|
108
111
|
|
|
109
|
-
Keys nest by whose they are, then by what they are for:
|
|
110
|
-
|
|
112
|
+
Keys nest by whose they are, then by what they are for: `<scope>:atom:<group>:slots:{group}…`,
|
|
113
|
+
`<scope>:atom:<group>:meter:<key>`, `<scope>:atom:<group>:lock:<key>`. The scope is the context's
|
|
114
|
+
name followed by `TOA_SUFFIX` (see
|
|
115
|
+
[deployment](/documentation/deployment.md#several-processes-of-one-context-on-shared-infrastructure)),
|
|
116
|
+
so contexts sharing a Redis do not share a group.
|
package/src/atom.js
CHANGED
|
@@ -14,6 +14,9 @@ export class Atom extends Connector {
|
|
|
14
14
|
#name
|
|
15
15
|
#interval
|
|
16
16
|
|
|
17
|
+
/** what every key of this atom begins with, once it has a Redis to write them to */
|
|
18
|
+
#prefix
|
|
19
|
+
|
|
17
20
|
/** @type {{ i: number, n: number } | null} */
|
|
18
21
|
#assignment = null
|
|
19
22
|
|
|
@@ -145,14 +148,15 @@ export class Atom extends Connector {
|
|
|
145
148
|
/**
|
|
146
149
|
* A key names whose it is and then what it is for, under the one namespace every atom
|
|
147
150
|
* shares, so that a name used for a lock and for a meter is two keys, and two groups using
|
|
148
|
-
* the same name do not meet either.
|
|
151
|
+
* the same name do not meet either. All of it is under the scope, because contexts share a
|
|
152
|
+
* Redis, and so do the processes of one context given different suffixes.
|
|
149
153
|
*
|
|
150
154
|
* @private
|
|
151
155
|
*/
|
|
152
156
|
#keys(kind, keys) {
|
|
153
157
|
if (typeof keys === 'string') keys = [keys]
|
|
154
158
|
|
|
155
|
-
return keys.map((key) => `${
|
|
159
|
+
return keys.map((key) => `${this.#prefix}${kind}:${key}`)
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
async open() {
|
|
@@ -161,6 +165,11 @@ export class Atom extends Connector {
|
|
|
161
165
|
// without a Redis nothing can be owned exclusively, so nothing is claimed at all
|
|
162
166
|
if (redis === undefined) return
|
|
163
167
|
|
|
168
|
+
// read as it opens rather than when it is made: an atom is one per group for the life of
|
|
169
|
+
// the process, and a process without a Redis — one run outside a context — has no scope
|
|
170
|
+
// to ask for
|
|
171
|
+
this.#prefix = `${environment.scope()}:${ATOM}:${this.#name}:`
|
|
172
|
+
|
|
164
173
|
this.#abort = new AbortController()
|
|
165
174
|
this.#discovering = this.#discover(redis)
|
|
166
175
|
}
|
|
@@ -186,7 +195,7 @@ export class Atom extends Connector {
|
|
|
186
195
|
|
|
187
196
|
const loop = discover({
|
|
188
197
|
redis,
|
|
189
|
-
prefix: `${
|
|
198
|
+
prefix: `${this.#prefix}${SLOTS}:`,
|
|
190
199
|
name: this.#name,
|
|
191
200
|
interval: this.#interval,
|
|
192
201
|
signal: this.#abort.signal,
|