@xyo-network/xl1-cli-lib 1.12.6 → 1.12.7
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/dist/node/index.mjs +36 -31
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/orchestration/actor/model/Actor.d.ts +3 -3
- package/dist/node/orchestration/actor/model/Actor.d.ts.map +1 -1
- package/dist/node/orchestration/initServices.d.ts.map +1 -1
- package/dist/node/xl1.mjs +36 -31
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +7 -7
- package/src/orchestration/actor/model/Actor.ts +32 -24
- package/src/orchestration/initServices.ts +12 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/xl1-cli-lib",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.7",
|
|
4
4
|
"description": "XYO Layer One CLI Library",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@xylabs/base": "~5.0.10",
|
|
47
47
|
"@xylabs/creatable": "~5.0.10",
|
|
48
48
|
"@xylabs/delay": "~5.0.10",
|
|
49
|
-
"@xylabs/forget": "~5.0.10",
|
|
50
49
|
"@xylabs/hex": "~5.0.10",
|
|
51
50
|
"@xylabs/logger": "~5.0.10",
|
|
52
51
|
"@xylabs/object": "~5.0.10",
|
|
@@ -56,14 +55,14 @@
|
|
|
56
55
|
"@xyo-network/archivist-lmdb": "~5.0.7",
|
|
57
56
|
"@xyo-network/archivist-memory": "~5.0.7",
|
|
58
57
|
"@xyo-network/archivist-model": "~5.0.7",
|
|
59
|
-
"@xyo-network/chain-api": "~1.12.
|
|
60
|
-
"@xyo-network/chain-sdk": "~1.12.
|
|
58
|
+
"@xyo-network/chain-api": "~1.12.7",
|
|
59
|
+
"@xyo-network/chain-sdk": "~1.12.7",
|
|
61
60
|
"@xyo-network/payload-builder": "~5.0.7",
|
|
62
61
|
"@xyo-network/payload-model": "~5.0.7",
|
|
63
62
|
"@xyo-network/wallet": "~5.0.7",
|
|
64
63
|
"@xyo-network/wallet-model": "~5.0.7",
|
|
65
64
|
"@xyo-network/xl1-protocol": "~1.10.15",
|
|
66
|
-
"@xyo-network/xl1-protocol-sdk": "~1.12.
|
|
65
|
+
"@xyo-network/xl1-protocol-sdk": "~1.12.7",
|
|
67
66
|
"async-mutex": "~0.5.0",
|
|
68
67
|
"cosmiconfig": "~9.0.0",
|
|
69
68
|
"dotenv": "~17.2.1",
|
|
@@ -73,9 +72,10 @@
|
|
|
73
72
|
"zod": "~4.0.17"
|
|
74
73
|
},
|
|
75
74
|
"devDependencies": {
|
|
76
|
-
"@xylabs/ts-scripts-yarn3": "~7.1.
|
|
77
|
-
"@xylabs/tsconfig": "~7.1.
|
|
75
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.7",
|
|
76
|
+
"@xylabs/tsconfig": "~7.1.7",
|
|
78
77
|
"@xylabs/vitest-extended": "~5.0.10",
|
|
78
|
+
"eslint": "^9.33.0",
|
|
79
79
|
"nodemon": "~3.1.10",
|
|
80
80
|
"rimraf": "~6.0.1",
|
|
81
81
|
"tslib": "~2.8.1",
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { TracerProvider } from '@opentelemetry/api'
|
|
2
2
|
import { Base, type BaseParams } from '@xylabs/base'
|
|
3
|
-
import { forget } from '@xylabs/forget'
|
|
4
3
|
import { IdLogger } from '@xylabs/logger'
|
|
5
|
-
import type { Promisable } from '@xylabs/promise'
|
|
6
4
|
import { span, spanAsync } from '@xylabs/telemetry'
|
|
7
5
|
import type { Config } from '@xyo-network/xl1-protocol-sdk'
|
|
8
6
|
|
|
@@ -17,7 +15,8 @@ export type ActorParams = BaseParams<{
|
|
|
17
15
|
}>
|
|
18
16
|
|
|
19
17
|
export class Actor<TParams extends ActorParams = ActorParams> extends Base<TParams> implements IActor {
|
|
20
|
-
protected readonly
|
|
18
|
+
protected readonly _intervals: Map<string, ReturnType<typeof setInterval>> = new Map()
|
|
19
|
+
protected readonly _timeouts: Map<string, ReturnType<typeof setTimeout>> = new Map()
|
|
21
20
|
private _active = false
|
|
22
21
|
private readonly _displayName: string
|
|
23
22
|
private readonly _id: string
|
|
@@ -48,7 +47,7 @@ export class Actor<TParams extends ActorParams = ActorParams> extends Base<TPara
|
|
|
48
47
|
/**
|
|
49
48
|
* The timer runs until the actor is deactivated (or you manually stop it).
|
|
50
49
|
*/
|
|
51
|
-
registerTimer(timerName: string, callback: () =>
|
|
50
|
+
registerTimer(timerName: string, callback: () => Promise<void>, dueTimeMs: number, periodMs: number) {
|
|
52
51
|
if (!this._active) {
|
|
53
52
|
this.logger?.warn(
|
|
54
53
|
`Cannot register timer '${timerName}' because actor is not active.`,
|
|
@@ -56,24 +55,27 @@ export class Actor<TParams extends ActorParams = ActorParams> extends Base<TPara
|
|
|
56
55
|
return
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
58
|
+
let running = false
|
|
59
|
+
|
|
60
|
+
const timeoutId = setTimeout(() => {
|
|
61
|
+
const intervalId = setInterval(() => {
|
|
62
|
+
if (!this._active || !this._intervals.has(timerName) || running) return
|
|
63
|
+
running = true
|
|
64
|
+
callback()
|
|
65
|
+
.catch((error) => {
|
|
66
|
+
this.logger?.error(`Error in timer '${this.name}:${timerName}': ${error}`)
|
|
67
|
+
})
|
|
68
|
+
.finally(() => {
|
|
69
|
+
running = false
|
|
70
|
+
})
|
|
71
|
+
}, periodMs)
|
|
72
|
+
|
|
73
|
+
// store interval so we can clear it on stop()
|
|
74
|
+
this._intervals.set(timerName, intervalId)
|
|
75
|
+
}, dueTimeMs)
|
|
74
76
|
|
|
75
|
-
//
|
|
76
|
-
this.
|
|
77
|
+
// store timeout so we can clear it on stop() if interval hasn't started yet
|
|
78
|
+
this._timeouts.set(timerName, timeoutId)
|
|
77
79
|
|
|
78
80
|
this.logger?.log(
|
|
79
81
|
`Timer '${this.name}:${timerName}' registered: first call after ${dueTimeMs}ms, recurring every ${periodMs}ms.`,
|
|
@@ -105,10 +107,16 @@ export class Actor<TParams extends ActorParams = ActorParams> extends Base<TPara
|
|
|
105
107
|
await Promise.resolve()
|
|
106
108
|
this._active = false
|
|
107
109
|
this.logger?.log('Stopping all timers...')
|
|
108
|
-
for (const [,
|
|
109
|
-
clearTimeout(
|
|
110
|
+
for (const [, timeoutRef] of this._timeouts.entries()) {
|
|
111
|
+
clearTimeout(timeoutRef)
|
|
110
112
|
}
|
|
111
|
-
this.
|
|
113
|
+
this._timeouts.clear()
|
|
114
|
+
|
|
115
|
+
for (const [, intervalRef] of this._intervals.entries()) {
|
|
116
|
+
clearInterval(intervalRef)
|
|
117
|
+
}
|
|
118
|
+
this._intervals.clear()
|
|
119
|
+
|
|
112
120
|
this.logger?.log('Stopped.')
|
|
113
121
|
}
|
|
114
122
|
}
|
|
@@ -22,17 +22,6 @@ import {
|
|
|
22
22
|
} from './services/index.ts'
|
|
23
23
|
import { RuntimeStatusMonitor } from './status/index.ts'
|
|
24
24
|
|
|
25
|
-
const telemetryConfig = {
|
|
26
|
-
attributes: {
|
|
27
|
-
serviceName: 'xl1-producer',
|
|
28
|
-
serviceVersion: '1.0.0',
|
|
29
|
-
},
|
|
30
|
-
metricsConfig: {
|
|
31
|
-
endpoint: '/metrics',
|
|
32
|
-
port: 9464,
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
|
|
36
25
|
interface Startable {
|
|
37
26
|
start: () => Promise<void>
|
|
38
27
|
}
|
|
@@ -59,7 +48,18 @@ export const initServices = async (context: InitServicesContext): Promise<ChainS
|
|
|
59
48
|
})
|
|
60
49
|
|
|
61
50
|
await startupSpanAsync('initHealthEndpoints', () => initHealthEndpoints({ ...context, statusReporter }))
|
|
62
|
-
|
|
51
|
+
const { otlpEndpoint } = config.telemetry?.otel ?? {}
|
|
52
|
+
const telemetryConfig = {
|
|
53
|
+
attributes: {
|
|
54
|
+
serviceName: 'xl1-producer',
|
|
55
|
+
serviceVersion: '1.0.0',
|
|
56
|
+
},
|
|
57
|
+
otlpEndpoint,
|
|
58
|
+
metricsConfig: {
|
|
59
|
+
endpoint: '/metrics',
|
|
60
|
+
port: 9464,
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
63
|
const [
|
|
64
64
|
{ traceProvider, meterProvider },
|
|
65
65
|
account,
|