@toa.io/atomicity 1.0.0-alpha.272 → 1.0.0-alpha.277
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 +6 -5
- package/src/atom.js +3 -7
- package/src/connection.js +9 -16
- package/src/factory.js +3 -7
- package/src/index.js +2 -7
- package/src/meter.js +1 -5
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.277](https://github.com/toa-io/toa/compare/v1.0.0-alpha.276...v1.0.0-alpha.277) (2026-09-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @toa.io/atomicity
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.0.0-alpha.273](https://github.com/toa-io/toa/compare/v1.0.0-alpha.272...v1.0.0-alpha.273) (2026-09-02)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @toa.io/atomicity
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [1.0.0-alpha.272](https://github.com/toa-io/toa/compare/v1.0.0-alpha.271...v1.0.0-alpha.272) (2026-09-01)
|
|
7
23
|
|
|
8
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/atomicity",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.277",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Toa Atomicity Connector",
|
|
5
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
7
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -17,13 +18,13 @@
|
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@sesamecare-oss/redlock": "1.4.0",
|
|
20
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
21
|
+
"@toa.io/core": "1.0.0-alpha.277",
|
|
21
22
|
"ioredis": "6.0.0",
|
|
22
|
-
"n-and-i": "0.3.
|
|
23
|
-
"openspan": "1.0.0-alpha.
|
|
23
|
+
"n-and-i": "0.3.2",
|
|
24
|
+
"openspan": "1.0.0-alpha.277"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
27
28
|
},
|
|
28
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "0c0071418c2c56a44e621ba5ced5cdd23dff1738"
|
|
29
30
|
}
|
package/src/atom.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { console } = require('openspan')
|
|
4
|
-
const { Connector } = require('@toa.io/core')
|
|
1
|
+
import { console } from 'openspan'
|
|
2
|
+
import { Connector } from '@toa.io/core'
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* What one group of replicas decides together, in one place: which of them owns what, what they
|
|
@@ -9,7 +7,7 @@ const { Connector } = require('@toa.io/core')
|
|
|
9
7
|
*
|
|
10
8
|
* @implements {toa.core.atomicity.Atom}
|
|
11
9
|
*/
|
|
12
|
-
class Atom extends Connector {
|
|
10
|
+
export class Atom extends Connector {
|
|
13
11
|
#connection
|
|
14
12
|
#name
|
|
15
13
|
#interval
|
|
@@ -172,5 +170,3 @@ const LEASE = 5000
|
|
|
172
170
|
const SLOTS = 'slots:'
|
|
173
171
|
const METER = 'meter:'
|
|
174
172
|
const LOCK = 'lock:'
|
|
175
|
-
|
|
176
|
-
exports.Atom = Atom
|
package/src/connection.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { Connector } = require('@toa.io/core')
|
|
7
|
-
const { Meter } = require('./meter')
|
|
1
|
+
import { Redlock } from '@sesamecare-oss/redlock'
|
|
2
|
+
import { Redis } from 'ioredis'
|
|
3
|
+
import { console } from 'openspan'
|
|
4
|
+
import { Connector } from '@toa.io/core'
|
|
5
|
+
import { Meter } from './meter.js'
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* One set of clients per process, shared by every atom in it. Each keeps its own keys, so a
|
|
11
9
|
* composition of five components opens one connection between them however much they decide.
|
|
12
10
|
*/
|
|
13
|
-
class Connection extends Connector {
|
|
11
|
+
export class Connection extends Connector {
|
|
14
12
|
/**
|
|
15
13
|
* The one the registry and the meter use. Both count on a single key — replicas per interval,
|
|
16
14
|
* debt per name — and a key spread over several servers would be several answers.
|
|
@@ -104,15 +102,10 @@ function resolve () {
|
|
|
104
102
|
let instance
|
|
105
103
|
|
|
106
104
|
/** the connection every atom of the process shares */
|
|
107
|
-
const connection = () => (instance ??= new Connection())
|
|
105
|
+
export const connection = () => (instance ??= new Connection())
|
|
108
106
|
|
|
109
107
|
/** @internal for tests */
|
|
110
|
-
const reset = () => (instance = undefined)
|
|
108
|
+
export const reset = () => (instance = undefined)
|
|
111
109
|
|
|
112
|
-
const VARIABLE = 'TOA_ATOMICITY_REDIS'
|
|
110
|
+
export const VARIABLE = 'TOA_ATOMICITY_REDIS'
|
|
113
111
|
const DEV = 'redis://localhost'
|
|
114
|
-
|
|
115
|
-
exports.Connection = Connection
|
|
116
|
-
exports.connection = connection
|
|
117
|
-
exports.reset = reset
|
|
118
|
-
exports.VARIABLE = VARIABLE
|
package/src/factory.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Atom } from './atom.js'
|
|
2
|
+
import { connection } from './connection.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { connection } = require('./connection')
|
|
5
|
-
|
|
6
|
-
class Factory {
|
|
4
|
+
export class Factory {
|
|
7
5
|
/**
|
|
8
6
|
* What the replicas of one group decide together. They find each other by `group` and by
|
|
9
7
|
* nothing else, so what shares a name shares a decision.
|
|
@@ -35,5 +33,3 @@ function atom (group, options) {
|
|
|
35
33
|
|
|
36
34
|
return atom
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
exports.Factory = Factory
|
package/src/index.js
CHANGED
package/src/meter.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Debt shared with every other process metering under the same key.
|
|
5
3
|
*
|
|
@@ -14,7 +12,7 @@
|
|
|
14
12
|
* A whole batch is metered by one script, because the callers are rate limiters and
|
|
15
13
|
* the number of keys they watch is the number of clients they are watching for.
|
|
16
14
|
*/
|
|
17
|
-
class Meter {
|
|
15
|
+
export class Meter {
|
|
18
16
|
#redis
|
|
19
17
|
|
|
20
18
|
constructor (redis) {
|
|
@@ -79,5 +77,3 @@ end
|
|
|
79
77
|
|
|
80
78
|
return debts
|
|
81
79
|
`
|
|
82
|
-
|
|
83
|
-
exports.Meter = Meter
|