@zintrust/workers 2.0.3 → 2.0.4
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/AnomalyDetection.js +3 -1
- package/dist/AutoScaler.js +3 -1
- package/dist/BroadcastWorker.js +2 -1
- package/dist/CanaryController.js +2 -1
- package/dist/ChaosEngineering.js +3 -1
- package/dist/CircuitBreaker.js +1 -1
- package/dist/ClusterLock.d.ts +1 -1
- package/dist/ClusterLock.js +5 -1
- package/dist/ComplianceManager.d.ts +1 -1
- package/dist/ComplianceManager.js +4 -1
- package/dist/DatacenterOrchestrator.js +2 -1
- package/dist/DeadLetterQueue.d.ts +1 -1
- package/dist/DeadLetterQueue.js +3 -1
- package/dist/HealthMonitor.js +2 -1
- package/dist/MultiQueueWorker.js +3 -1
- package/dist/NotificationWorker.js +1 -1
- package/dist/Observability.js +3 -1
- package/dist/PluginManager.js +2 -1
- package/dist/PriorityQueue.d.ts +1 -1
- package/dist/PriorityQueue.js +2 -1
- package/dist/ResourceMonitor.js +3 -1
- package/dist/SLAMonitor.js +3 -1
- package/dist/WorkerFactory.d.ts +2 -2
- package/dist/WorkerFactory.js +8 -2
- package/dist/WorkerInit.js +3 -1
- package/dist/WorkerMetrics.d.ts +1 -1
- package/dist/WorkerMetrics.js +3 -1
- package/dist/WorkerRegistry.d.ts +1 -1
- package/dist/WorkerRegistry.js +2 -1
- package/dist/WorkerShutdown.js +1 -1
- package/dist/WorkerVersioning.js +2 -1
- package/dist/config/workerConfig.js +1 -1
- package/dist/createQueueWorker.js +11 -44
- package/dist/dashboard/workers-api.js +4 -1
- package/dist/helper/index.d.ts +1 -1
- package/dist/http/WorkerApiController.d.ts +1 -1
- package/dist/http/WorkerApiController.js +1 -1
- package/dist/http/WorkerController.d.ts +1 -1
- package/dist/http/WorkerController.js +4 -1
- package/dist/http/WorkerMonitoringService.js +2 -1
- package/dist/http/middleware/CustomValidation.d.ts +1 -1
- package/dist/http/middleware/CustomValidation.js +1 -1
- package/dist/http/middleware/DatacenterValidator.d.ts +1 -1
- package/dist/http/middleware/DatacenterValidator.js +1 -1
- package/dist/http/middleware/EditWorkerValidation.d.ts +1 -1
- package/dist/http/middleware/EditWorkerValidation.js +1 -1
- package/dist/http/middleware/FeaturesValidator.d.ts +1 -1
- package/dist/http/middleware/FeaturesValidator.js +1 -1
- package/dist/http/middleware/InfrastructureValidator.d.ts +1 -1
- package/dist/http/middleware/InfrastructureValidator.js +1 -1
- package/dist/http/middleware/OptionsValidator.d.ts +1 -1
- package/dist/http/middleware/OptionsValidator.js +1 -1
- package/dist/http/middleware/PayloadSanitizer.d.ts +1 -1
- package/dist/http/middleware/PayloadSanitizer.js +1 -1
- package/dist/http/middleware/ProcessorPathSanitizer.d.ts +1 -1
- package/dist/http/middleware/ProcessorPathSanitizer.js +2 -1
- package/dist/http/middleware/QueueNameSanitizer.d.ts +1 -1
- package/dist/http/middleware/QueueNameSanitizer.js +1 -1
- package/dist/http/middleware/ValidateDriver.d.ts +1 -1
- package/dist/http/middleware/VersionSanitizer.d.ts +1 -1
- package/dist/http/middleware/VersionSanitizer.js +1 -1
- package/dist/http/middleware/WorkerNameSanitizer.d.ts +1 -1
- package/dist/http/middleware/WorkerNameSanitizer.js +1 -1
- package/dist/http/middleware/WorkerValidationChain.d.ts +1 -1
- package/dist/http/middleware/WorkerValidationChain.js +1 -1
- package/dist/queueMonitorHistory.js +3 -1
- package/dist/routes/workers.d.ts +1 -1
- package/dist/routes/workers.js +4 -1
- package/dist/storage/WorkerStore.d.ts +2 -2
- package/dist/telemetry/api/TelemetryAPI.js +1 -1
- package/dist/telemetry/api/TelemetryMonitoringService.d.ts +1 -1
- package/dist/telemetry/api/TelemetryMonitoringService.js +2 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +2 -1
- package/dist/ui/router/ui.d.ts +1 -1
- package/dist/ui/router/ui.js +6 -1
- package/package.json +1 -1
- package/src/AnomalyDetection.ts +4 -2
- package/src/AutoScaler.ts +3 -2
- package/src/BroadcastWorker.ts +2 -1
- package/src/CanaryController.ts +2 -1
- package/src/ChaosEngineering.ts +3 -1
- package/src/CircuitBreaker.ts +1 -1
- package/src/ClusterLock.ts +5 -8
- package/src/ComplianceManager.ts +4 -7
- package/src/DatacenterOrchestrator.ts +2 -1
- package/src/DeadLetterQueue.ts +3 -1
- package/src/HealthMonitor.ts +2 -1
- package/src/MultiQueueWorker.ts +3 -1
- package/src/NotificationWorker.ts +1 -1
- package/src/Observability.ts +3 -1
- package/src/PluginManager.ts +2 -1
- package/src/PriorityQueue.ts +3 -1
- package/src/ResourceMonitor.ts +3 -1
- package/src/SLAMonitor.ts +3 -1
- package/src/WorkerFactory.ts +13 -19
- package/src/WorkerInit.ts +3 -1
- package/src/WorkerMetrics.ts +3 -7
- package/src/WorkerRegistry.ts +3 -1
- package/src/WorkerShutdown.ts +1 -1
- package/src/WorkerVersioning.ts +2 -1
- package/src/config/workerConfig.ts +1 -1
- package/src/createQueueWorker.ts +12 -45
- package/src/dashboard/workers-api.ts +4 -1
- package/src/helper/index.ts +1 -1
- package/src/http/WorkerApiController.ts +2 -2
- package/src/http/WorkerController.ts +5 -8
- package/src/http/WorkerMonitoringService.ts +2 -1
- package/src/http/middleware/CustomValidation.ts +2 -1
- package/src/http/middleware/DatacenterValidator.ts +2 -1
- package/src/http/middleware/EditWorkerValidation.ts +2 -1
- package/src/http/middleware/FeaturesValidator.ts +2 -1
- package/src/http/middleware/InfrastructureValidator.ts +2 -1
- package/src/http/middleware/OptionsValidator.ts +2 -1
- package/src/http/middleware/PayloadSanitizer.ts +2 -1
- package/src/http/middleware/ProcessorPathSanitizer.ts +3 -7
- package/src/http/middleware/QueueNameSanitizer.ts +2 -1
- package/src/http/middleware/ValidateDriver.ts +1 -1
- package/src/http/middleware/VersionSanitizer.ts +2 -1
- package/src/http/middleware/WorkerNameSanitizer.ts +2 -1
- package/src/http/middleware/WorkerValidationChain.ts +2 -1
- package/src/queueMonitorHistory.ts +3 -1
- package/src/routes/workers.ts +5 -2
- package/src/storage/WorkerStore.ts +2 -2
- package/src/telemetry/api/TelemetryAPI.ts +1 -1
- package/src/telemetry/api/TelemetryMonitoringService.ts +3 -2
- package/src/telemetry/index.ts +3 -2
- package/src/ui/router/ui.ts +9 -11
package/dist/AnomalyDetection.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Statistical anomaly detection with lightweight baselines
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { generateUuid } from '@zintrust/core/utils';
|
|
7
9
|
import { ResourceMonitor } from './ResourceMonitor.js';
|
|
8
10
|
import { WorkerMetrics } from './WorkerMetrics.js';
|
|
9
11
|
const configs = new Map();
|
package/dist/AutoScaler.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Automatic worker scaling based on queue depth, resource usage, and cost optimization
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { workersConfig } from '@zintrust/core/workers';
|
|
7
9
|
// Internal state
|
|
8
10
|
let config = null;
|
|
9
11
|
let scalingInterval = null;
|
package/dist/BroadcastWorker.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* This worker dequeues broadcast messages and sends them using the Broadcast service.
|
|
5
5
|
* Use with Queue.dequeue() in a background process or cron job.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { Broadcast, isArray, isNonEmptyString } from '@zintrust/core/utils';
|
|
8
9
|
import { createQueueWorker } from './createQueueWorker.js';
|
|
9
10
|
const resolveQueuedBroadcastChannels = (payload) => {
|
|
10
11
|
if (isArray(payload.channels)) {
|
package/dist/CanaryController.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Gradual rollout with traffic percentage control and automatic rollback
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
8
|
import { CircuitBreaker } from './CircuitBreaker.js';
|
|
8
9
|
// Internal state
|
|
9
10
|
const canaryDeployments = new Map();
|
package/dist/ChaosEngineering.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Controlled fault injection experiments for worker resilience testing
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { generateUuid } from '@zintrust/core/utils';
|
|
7
9
|
import { CircuitBreaker } from './CircuitBreaker.js';
|
|
8
10
|
import { Observability } from './Observability.js';
|
|
9
11
|
import { ResourceMonitor } from './ResourceMonitor.js';
|
package/dist/CircuitBreaker.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Fault tolerance with version tracking and automatic recovery
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { Logger } from '@zintrust/core';
|
|
6
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
7
|
// Internal state
|
|
8
8
|
const circuits = new Map();
|
|
9
9
|
const eventHistory = new Map();
|
package/dist/ClusterLock.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed locking using Redis for multi-instance worker coordination
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { type RedisConfig } from '@zintrust/core';
|
|
6
|
+
import { type RedisConfig } from '@zintrust/core/redis';
|
|
7
7
|
export type LockAcquisitionOptions = {
|
|
8
8
|
lockKey: string;
|
|
9
9
|
ttl: number;
|
package/dist/ClusterLock.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Distributed locking using Redis for multi-instance worker coordination
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { Cloudflare
|
|
6
|
+
import { Cloudflare } from '@zintrust/core/cloudflare';
|
|
7
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
8
|
+
import { Logger } from '@zintrust/core/logger';
|
|
9
|
+
import { createRedisConnection } from '@zintrust/core/redis';
|
|
10
|
+
import { generateUuid } from '@zintrust/core/utils';
|
|
7
11
|
let INSTANCE_ID = '';
|
|
8
12
|
const createInstanceId = () => {
|
|
9
13
|
const workers = Cloudflare.getWorkersEnv() !== null;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* GDPR, HIPAA, and SOC2 compliance enforcement
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { type RedisConfig } from '@zintrust/core';
|
|
6
|
+
import { type RedisConfig } from '@zintrust/core/redis';
|
|
7
7
|
export type ComplianceStandard = 'gdpr' | 'hipaa' | 'soc2';
|
|
8
8
|
export type DataClassification = 'public' | 'internal' | 'confidential' | 'restricted';
|
|
9
9
|
export type ComplianceConfig = {
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* GDPR, HIPAA, and SOC2 compliance enforcement
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { createRedisConnection } from '@zintrust/core/redis';
|
|
9
|
+
import { NodeSingletons } from '@zintrust/core/workers';
|
|
7
10
|
// Access NodeSingletons lazily to avoid initialization errors in test environments
|
|
8
11
|
const getCrypto = () => {
|
|
9
12
|
if (!NodeSingletons) {
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Multi-datacenter worker coordination with region affinity and failover
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
8
|
import { ClusterLock } from './ClusterLock.js';
|
|
8
9
|
// Internal state
|
|
9
10
|
const regions = new Map();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Failed job handling with compliance tracking (GDPR/HIPAA/SOC2)
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { type RedisConfig } from '@zintrust/core';
|
|
6
|
+
import { type RedisConfig } from '@zintrust/core/redis';
|
|
7
7
|
export type FailedJobEntry = {
|
|
8
8
|
id: string;
|
|
9
9
|
queueName: string;
|
package/dist/DeadLetterQueue.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Failed job handling with compliance tracking (GDPR/HIPAA/SOC2)
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { createRedisConnection } from '@zintrust/core/redis';
|
|
7
9
|
import { keyPrefixFor } from './config/workerConfig.js';
|
|
8
10
|
// Redis key prefixes - using workers package prefix system
|
|
9
11
|
const getDLQPrefix = () => {
|
package/dist/HealthMonitor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ErrorFactory
|
|
1
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
3
|
import { WorkerCreationStatus, WorkerFactory } from './WorkerFactory.js';
|
|
3
4
|
const DEFAULT_CONFIG = {
|
|
4
5
|
enabled: true,
|
package/dist/MultiQueueWorker.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Enable workers to process multiple queues with different priorities
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { ShutdownTrace } from '@zintrust/core/workers';
|
|
7
9
|
import { Worker } from 'bullmq';
|
|
8
10
|
import { PriorityQueue } from './PriorityQueue.js';
|
|
9
11
|
// Internal state
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This worker dequeues notification messages and sends them using the Notification service.
|
|
5
5
|
* Use with Queue.dequeue() in a background process or cron job.
|
|
6
6
|
*/
|
|
7
|
-
import { Notification } from '@zintrust/core';
|
|
7
|
+
import { Notification } from '@zintrust/core/mail';
|
|
8
8
|
import { createQueueWorker } from './createQueueWorker.js';
|
|
9
9
|
export const NotificationWorker = Object.freeze({
|
|
10
10
|
...createQueueWorker({
|
package/dist/Observability.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Integrations for Prometheus, OpenTelemetry, and Datadog
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { generateUuid } from '@zintrust/core/utils';
|
|
7
9
|
// Internal state
|
|
8
10
|
let config = null;
|
|
9
11
|
// Prometheus state
|
package/dist/PluginManager.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Extensible plugin system with lifecycle hooks
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
8
|
// Internal state
|
|
8
9
|
const plugins = new Map();
|
|
9
10
|
const hookExecutionHistory = [];
|
package/dist/PriorityQueue.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* BullMQ priority levels with datacenter affinity
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import type { RedisConfig } from '@zintrust/core/redis';
|
|
7
7
|
import type { Queue } from 'bullmq';
|
|
8
8
|
export type PriorityLevel = 'critical' | 'high' | 'normal' | 'low';
|
|
9
9
|
export type JobPriority = {
|
package/dist/PriorityQueue.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* BullMQ priority levels with datacenter affinity
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
8
|
// Priority mappings
|
|
8
9
|
const PRIORITY_VALUES = {
|
|
9
10
|
critical: 10,
|
package/dist/ResourceMonitor.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Real-time resource tracking with cost calculation
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { Env
|
|
6
|
+
import { Env } from '@zintrust/core/config';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { NodeSingletons } from '@zintrust/core/workers';
|
|
7
9
|
const getOsModule = () => NodeSingletons?.os ?? null;
|
|
8
10
|
const safeTotalMemory = () => {
|
|
9
11
|
const os = getOsModule();
|
package/dist/SLAMonitor.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* SLA compliance checks and violation tracking for workers
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { generateUuid } from '@zintrust/core/utils';
|
|
7
9
|
import { HealthMonitor } from './HealthMonitor.js';
|
|
8
10
|
import { WorkerMetrics } from './WorkerMetrics.js';
|
|
9
11
|
const slaConfigs = new Map();
|
package/dist/WorkerFactory.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Central factory for creating workers with all advanced features
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { type IDatabase } from '@zintrust/core';
|
|
7
|
-
import { type RedisConfig } from '@zintrust/core/
|
|
6
|
+
import { type IDatabase } from '@zintrust/core/database';
|
|
7
|
+
import { type RedisConfig } from '@zintrust/core/redis';
|
|
8
8
|
import { Worker, type Job, type WorkerOptions } from 'bullmq';
|
|
9
9
|
import { type AutoScalerConfig } from './AutoScaler';
|
|
10
10
|
import { type ComplianceConfig } from './ComplianceManager';
|
package/dist/WorkerFactory.js
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
import * as ZintrustCoreModule from '@zintrust/core';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { Cloudflare, databaseConfig, Env, queueConfig, workersConfig } from '@zintrust/core/config';
|
|
8
|
+
import { useEnsureDbConnected } from '@zintrust/core/database';
|
|
9
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
10
|
+
import { Logger } from '@zintrust/core/logger';
|
|
9
11
|
import { DatabaseConnectionRegistry, registerDatabasesFromRuntimeConfig } from '@zintrust/core/orm';
|
|
12
|
+
import { JobStateTracker } from '@zintrust/core/queue';
|
|
13
|
+
import { createRedisConnection, getBullMQSafeQueueName, } from '@zintrust/core/redis';
|
|
14
|
+
import { generateUuid, isFunction, isNonEmptyString, isObject, ZintrustLang, } from '@zintrust/core/utils';
|
|
15
|
+
import { NodeSingletons } from '@zintrust/core/workers';
|
|
10
16
|
import { Worker } from 'bullmq';
|
|
11
17
|
import { AutoScaler } from './AutoScaler.js';
|
|
12
18
|
import { CanaryController } from './CanaryController.js';
|
package/dist/WorkerInit.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* - Sets up auto-scaling and health checks
|
|
8
8
|
* - Ensures graceful startup and shutdown
|
|
9
9
|
*/
|
|
10
|
-
import { Env
|
|
10
|
+
import { Env } from '@zintrust/core/config';
|
|
11
|
+
import { Logger } from '@zintrust/core/logger';
|
|
12
|
+
import { isObject } from '@zintrust/core/utils';
|
|
11
13
|
import { ResourceMonitor } from './ResourceMonitor.js';
|
|
12
14
|
import { WorkerFactory } from './WorkerFactory.js';
|
|
13
15
|
import { WorkerShutdown } from './WorkerShutdown.js';
|
package/dist/WorkerMetrics.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Time-series metrics persistence with Redis Sorted Sets
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { type RedisConfig } from '@zintrust/core';
|
|
6
|
+
import { type RedisConfig } from '@zintrust/core/redis';
|
|
7
7
|
export type MetricType = 'processed' | 'errors' | 'duration' | 'memory' | 'cpu' | 'queue-size' | 'active-jobs' | 'waiting-jobs' | 'delayed-jobs' | 'failed-jobs' | 'completed-jobs';
|
|
8
8
|
export type MetricGranularity = 'hourly' | 'daily' | 'monthly';
|
|
9
9
|
export type MetricPoint = {
|
package/dist/WorkerMetrics.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Time-series metrics persistence with Redis Sorted Sets
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
|
+
import { RedisKeys, createRedisConnection } from '@zintrust/core/redis';
|
|
7
9
|
// Retention periods (in seconds)
|
|
8
10
|
const RETENTION = {
|
|
9
11
|
hourly: 7 * 24 * 60 * 60, // 7 days
|
package/dist/WorkerRegistry.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Central registry for all background workers with lifecycle management
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { type WorkerConfig, type WorkerStatus } from '@zintrust/core';
|
|
6
|
+
import { type WorkerConfig, type WorkerStatus } from '@zintrust/core/workers';
|
|
7
7
|
export type WorkerMetadata = {
|
|
8
8
|
name: string;
|
|
9
9
|
status: WorkerStatus;
|
package/dist/WorkerRegistry.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Central registry for all background workers with lifecycle management
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
8
|
import { AnomalyDetection } from './AnomalyDetection.js';
|
|
8
9
|
// Internal storage
|
|
9
10
|
const workers = new Map();
|
package/dist/WorkerShutdown.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Centralized graceful shutdown handling for the worker management system.
|
|
5
5
|
* Coordinates orderly shutdown of all worker modules and the WorkerFactory.
|
|
6
6
|
*/
|
|
7
|
-
import { Logger } from '@zintrust/core';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
8
8
|
import { WorkerFactory } from './WorkerFactory.js';
|
|
9
9
|
// ============================================================================
|
|
10
10
|
// Implementation
|
package/dist/WorkerVersioning.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Semantic versioning support for workers with backward compatibility
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { ErrorFactory
|
|
6
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
7
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
8
|
// Internal state
|
|
8
9
|
const workerVersions = new Map();
|
|
9
10
|
const versionAliases = new Map(); // 'latest', 'stable', etc. -> version string
|
|
@@ -1,41 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Env } from '@zintrust/core/config';
|
|
2
|
+
import { Logger } from '@zintrust/core/logger';
|
|
3
|
+
import { JobHeartbeatStore, JobStateTracker, Queue, TimeoutManager } from '@zintrust/core/queue';
|
|
4
|
+
import { SystemTraceBridge } from '@zintrust/core/trace';
|
|
3
5
|
import { recordQueueMonitorJob } from './queueMonitorHistory.js';
|
|
4
6
|
const TypedQueue = Queue;
|
|
5
7
|
const RETRY_BASE_DELAY_MS = 1000;
|
|
6
8
|
const RETRY_MAX_DELAY_MS = 30000;
|
|
7
|
-
const getJobStateTracker = () => {
|
|
8
|
-
try {
|
|
9
|
-
return Core['JobStateTracker'];
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const getJobHeartbeatStore = () => {
|
|
16
|
-
try {
|
|
17
|
-
return Core['JobHeartbeatStore'];
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const getTimeoutManager = () => {
|
|
24
|
-
try {
|
|
25
|
-
return Core['TimeoutManager'];
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const getSystemTraceBridge = () => {
|
|
32
|
-
try {
|
|
33
|
-
return Core['SystemTraceBridge'];
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
9
|
const getEnvInt = (key, fallback) => {
|
|
40
10
|
const getter = Env.getInt;
|
|
41
11
|
if (typeof getter === 'function') {
|
|
@@ -52,24 +22,21 @@ const getEnvInt = (key, fallback) => {
|
|
|
52
22
|
return fallback;
|
|
53
23
|
};
|
|
54
24
|
const resolveQueueJobTimeoutMs = () => {
|
|
55
|
-
const
|
|
56
|
-
const tm = (timeoutManager ?? {});
|
|
25
|
+
const tm = (TimeoutManager ?? {});
|
|
57
26
|
if (typeof tm.getQueueJobTimeoutMs === 'function') {
|
|
58
27
|
return tm.getQueueJobTimeoutMs();
|
|
59
28
|
}
|
|
60
29
|
return Math.max(1000, getEnvInt('QUEUE_JOB_TIMEOUT', 60) * 1000);
|
|
61
30
|
};
|
|
62
31
|
const runWithTimeout = async (operation, timeoutMs, operationName) => {
|
|
63
|
-
const
|
|
64
|
-
const tm = (timeoutManager ?? {});
|
|
32
|
+
const tm = (TimeoutManager ?? {});
|
|
65
33
|
if (typeof tm.withTimeout === 'function') {
|
|
66
34
|
return tm.withTimeout(operation, timeoutMs, operationName);
|
|
67
35
|
}
|
|
68
36
|
return operation();
|
|
69
37
|
};
|
|
70
38
|
const isTimeoutError = (error) => {
|
|
71
|
-
const
|
|
72
|
-
const tm = (timeoutManager ?? {});
|
|
39
|
+
const tm = (TimeoutManager ?? {});
|
|
73
40
|
if (typeof tm.isTimeoutError === 'function') {
|
|
74
41
|
return tm.isTimeoutError(error);
|
|
75
42
|
}
|
|
@@ -114,17 +81,17 @@ const getWorkerInstanceId = () => {
|
|
|
114
81
|
: undefined;
|
|
115
82
|
};
|
|
116
83
|
const getTrackerApi = () => {
|
|
117
|
-
return (
|
|
84
|
+
return (JobStateTracker ?? {});
|
|
118
85
|
};
|
|
119
86
|
const getHeartbeatStoreApi = () => {
|
|
120
|
-
return (
|
|
87
|
+
return (JobHeartbeatStore ?? {});
|
|
121
88
|
};
|
|
122
89
|
const emitJobProcessed = (name) => {
|
|
123
|
-
const bridge = (
|
|
90
|
+
const bridge = (SystemTraceBridge ?? {});
|
|
124
91
|
bridge.emitJobProcessed?.(name);
|
|
125
92
|
};
|
|
126
93
|
const emitJobFailed = (name, error) => {
|
|
127
|
-
const bridge = (
|
|
94
|
+
const bridge = (SystemTraceBridge ?? {});
|
|
128
95
|
bridge.emitJobFailed?.(name, error);
|
|
129
96
|
};
|
|
130
97
|
const removeHeartbeatIfSupported = async (queueName, jobId) => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Env,
|
|
1
|
+
import { Env, queueConfig } from '@zintrust/core/config';
|
|
2
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
3
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
4
|
import { WorkerFactory } from '../WorkerFactory.js';
|
|
3
5
|
import { WorkerMetrics as WorkerMetricsManager } from '../WorkerMetrics.js';
|
|
4
6
|
import { WorkerRegistry } from '../WorkerRegistry.js';
|
|
@@ -464,6 +466,7 @@ async function getRedisQueueData() {
|
|
|
464
466
|
try {
|
|
465
467
|
// Use existing queue monitor infrastructure
|
|
466
468
|
const { QueueMonitor } = await import('@zintrust/queue-monitor');
|
|
469
|
+
const { queueConfig } = await import('@zintrust/core/config');
|
|
467
470
|
const redisConfig = queueConfig.drivers.redis;
|
|
468
471
|
if (redisConfig?.driver !== 'redis') {
|
|
469
472
|
throw ErrorFactory.createConfigError('Redis driver not configured');
|
package/dist/helper/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Worker API Controller
|
|
3
3
|
* HTTP handlers for worker management API
|
|
4
4
|
*/
|
|
5
|
-
import type { IRequest, IResponse } from '@zintrust/core';
|
|
5
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
6
6
|
/**
|
|
7
7
|
* GET /api/workers - List workers with pagination, filtering, and sorting
|
|
8
8
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Worker API Controller
|
|
3
3
|
* HTTP handlers for worker management API
|
|
4
4
|
*/
|
|
5
|
-
import { Logger } from '@zintrust/core';
|
|
5
|
+
import { Logger } from '@zintrust/core/logger';
|
|
6
6
|
import { getWorkerDetails, getWorkers } from '../dashboard/workers-api.js';
|
|
7
7
|
import { getParam } from '../helper/index.js';
|
|
8
8
|
import { WorkerFactory } from '../WorkerFactory.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Worker Controller
|
|
3
3
|
* HTTP handlers for worker management API
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
6
6
|
/**
|
|
7
7
|
* Create a new worker instance
|
|
8
8
|
* @param req.body.name - Worker name (required)
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* Worker Controller
|
|
4
4
|
* HTTP handlers for worker management API
|
|
5
5
|
*/
|
|
6
|
-
import { Cloudflare
|
|
6
|
+
import { Cloudflare } from '@zintrust/core/cloudflare';
|
|
7
|
+
import { Env } from '@zintrust/core/config';
|
|
8
|
+
import { getValidatedBody } from '@zintrust/core/http';
|
|
9
|
+
import { Logger } from '@zintrust/core/logger';
|
|
7
10
|
import { CanaryController } from '../CanaryController.js';
|
|
8
11
|
import { HealthMonitor } from '../HealthMonitor.js';
|
|
9
12
|
import { getParam } from '../helper/index.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Logger
|
|
1
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
|
+
import { NodeSingletons, workersConfig } from '@zintrust/core/workers';
|
|
2
3
|
import { HealthMonitor } from '../HealthMonitor.js';
|
|
3
4
|
import { getWorkers } from '../dashboard/workers-api.js';
|
|
4
5
|
const createFallbackEmitter = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
2
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
3
|
export interface ValidationSchema {
|
|
4
4
|
[key: string]: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
2
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
3
|
export declare const withDatacenterValidation: (handler: RouteHandler) => RouteHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
2
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
3
|
/**
|
|
4
4
|
* Composite middleware for worker edit validation
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
2
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
3
|
export declare const withFeaturesValidation: (handler: RouteHandler) => RouteHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
2
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
3
|
export interface InfrastructureConfig {
|
|
4
4
|
persistence: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger } from '@zintrust/core';
|
|
1
|
+
import { Logger } from '@zintrust/core/logger';
|
|
2
2
|
const VALID_DRIVERS = new Set(['database', 'redis', 'memory']);
|
|
3
3
|
const VALID_DEAD_LETTER_POLICIES = new Set(['expire', 'retry', 'dead-letter']);
|
|
4
4
|
const validatePersistence = (persistence) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IRequest, IResponse } from '@zintrust/core/http';
|
|
2
2
|
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
3
|
export declare const withOptionsValidation: (handler: RouteHandler) => RouteHandler;
|