@blokjs/runner 0.2.1 → 0.4.0
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/Blok.js +11 -11
- package/dist/Blok.js.map +1 -1
- package/dist/Configuration.d.ts +39 -2
- package/dist/Configuration.js +337 -28
- package/dist/Configuration.js.map +1 -1
- package/dist/ConfigurationResolver.d.ts +9 -0
- package/dist/ConfigurationResolver.js +17 -1
- package/dist/ConfigurationResolver.js.map +1 -1
- package/dist/PayloadTooLargeError.d.ts +19 -0
- package/dist/PayloadTooLargeError.js +29 -0
- package/dist/PayloadTooLargeError.js.map +1 -0
- package/dist/RunCancelledError.d.ts +17 -0
- package/dist/RunCancelledError.js +25 -0
- package/dist/RunCancelledError.js.map +1 -0
- package/dist/RunnerSteps.js +363 -23
- package/dist/RunnerSteps.js.map +1 -1
- package/dist/RuntimeAdapterNode.d.ts +32 -2
- package/dist/RuntimeAdapterNode.js +122 -27
- package/dist/RuntimeAdapterNode.js.map +1 -1
- package/dist/SubworkflowNode.d.ts +75 -0
- package/dist/SubworkflowNode.js +221 -0
- package/dist/SubworkflowNode.js.map +1 -0
- package/dist/TriggerBase.d.ts +128 -0
- package/dist/TriggerBase.js +808 -6
- package/dist/TriggerBase.js.map +1 -1
- package/dist/WaitDispatchRequest.d.ts +38 -0
- package/dist/WaitDispatchRequest.js +13 -0
- package/dist/WaitDispatchRequest.js.map +1 -0
- package/dist/WaitNode.d.ts +23 -0
- package/dist/WaitNode.js +26 -0
- package/dist/WaitNode.js.map +1 -0
- package/dist/adapters/BunRuntimeAdapter.d.ts +1 -0
- package/dist/adapters/BunRuntimeAdapter.js +1 -0
- package/dist/adapters/BunRuntimeAdapter.js.map +1 -1
- package/dist/adapters/DockerRuntimeAdapter.d.ts +2 -1
- package/dist/adapters/DockerRuntimeAdapter.js +10 -1
- package/dist/adapters/DockerRuntimeAdapter.js.map +1 -1
- package/dist/adapters/HttpRuntimeAdapter.d.ts +26 -5
- package/dist/adapters/HttpRuntimeAdapter.js +97 -16
- package/dist/adapters/HttpRuntimeAdapter.js.map +1 -1
- package/dist/adapters/NodeJsRuntimeAdapter.d.ts +1 -0
- package/dist/adapters/NodeJsRuntimeAdapter.js +1 -0
- package/dist/adapters/NodeJsRuntimeAdapter.js.map +1 -1
- package/dist/adapters/RuntimeAdapter.d.ts +17 -0
- package/dist/adapters/WasmRuntimeAdapter.d.ts +1 -0
- package/dist/adapters/WasmRuntimeAdapter.js +1 -0
- package/dist/adapters/WasmRuntimeAdapter.js.map +1 -1
- package/dist/adapters/grpc/GrpcChannelOptions.d.ts +31 -0
- package/dist/adapters/grpc/GrpcChannelOptions.js +68 -0
- package/dist/adapters/grpc/GrpcChannelOptions.js.map +1 -0
- package/dist/adapters/grpc/GrpcClientPool.d.ts +43 -0
- package/dist/adapters/grpc/GrpcClientPool.js +89 -0
- package/dist/adapters/grpc/GrpcClientPool.js.map +1 -0
- package/dist/adapters/grpc/GrpcCodec.d.ts +226 -0
- package/dist/adapters/grpc/GrpcCodec.js +275 -0
- package/dist/adapters/grpc/GrpcCodec.js.map +1 -0
- package/dist/adapters/grpc/GrpcErrors.d.ts +59 -0
- package/dist/adapters/grpc/GrpcErrors.js +190 -0
- package/dist/adapters/grpc/GrpcErrors.js.map +1 -0
- package/dist/adapters/grpc/GrpcHealthChecker.d.ts +69 -0
- package/dist/adapters/grpc/GrpcHealthChecker.js +96 -0
- package/dist/adapters/grpc/GrpcHealthChecker.js.map +1 -0
- package/dist/adapters/grpc/GrpcRuntimeAdapter.d.ts +98 -0
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js +478 -0
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js.map +1 -0
- package/dist/adapters/grpc/index.d.ts +13 -0
- package/dist/adapters/grpc/index.js +14 -0
- package/dist/adapters/grpc/index.js.map +1 -0
- package/dist/adapters/grpc/proto/blok/runtime/v1/runtime.proto +302 -0
- package/dist/adapters/grpc/types.d.ts +97 -0
- package/dist/adapters/grpc/types.js +41 -0
- package/dist/adapters/grpc/types.js.map +1 -0
- package/dist/adapters/transport.d.ts +108 -0
- package/dist/adapters/transport.js +196 -0
- package/dist/adapters/transport.js.map +1 -0
- package/dist/concurrency/ConcurrencyBackend.d.ts +61 -0
- package/dist/concurrency/ConcurrencyBackend.js +20 -0
- package/dist/concurrency/ConcurrencyBackend.js.map +1 -0
- package/dist/concurrency/ConcurrencyLimitError.d.ts +37 -0
- package/dist/concurrency/ConcurrencyLimitError.js +16 -0
- package/dist/concurrency/ConcurrencyLimitError.js.map +1 -0
- package/dist/concurrency/NatsKvConcurrencyBackend.d.ts +64 -0
- package/dist/concurrency/NatsKvConcurrencyBackend.js +297 -0
- package/dist/concurrency/NatsKvConcurrencyBackend.js.map +1 -0
- package/dist/concurrency/QueueExpiredError.d.ts +40 -0
- package/dist/concurrency/QueueExpiredError.js +15 -0
- package/dist/concurrency/QueueExpiredError.js.map +1 -0
- package/dist/concurrency/createConcurrencyBackend.d.ts +23 -0
- package/dist/concurrency/createConcurrencyBackend.js +34 -0
- package/dist/concurrency/createConcurrencyBackend.js.map +1 -0
- package/dist/concurrency/readConcurrencyConfig.d.ts +60 -0
- package/dist/concurrency/readConcurrencyConfig.js +60 -0
- package/dist/concurrency/readConcurrencyConfig.js.map +1 -0
- package/dist/idempotency/resolveIdempotencyKey.d.ts +20 -0
- package/dist/idempotency/resolveIdempotencyKey.js +37 -0
- package/dist/idempotency/resolveIdempotencyKey.js.map +1 -0
- package/dist/index.d.ts +35 -3
- package/dist/index.js +61 -2
- package/dist/index.js.map +1 -1
- package/dist/monitoring/ConcurrencyMetrics.d.ts +56 -0
- package/dist/monitoring/ConcurrencyMetrics.js +107 -0
- package/dist/monitoring/ConcurrencyMetrics.js.map +1 -0
- package/dist/monitoring/JanitorMetrics.d.ts +27 -0
- package/dist/monitoring/JanitorMetrics.js +48 -0
- package/dist/monitoring/JanitorMetrics.js.map +1 -0
- package/dist/scheduling/DebounceCoordinator.d.ts +88 -0
- package/dist/scheduling/DebounceCoordinator.js +141 -0
- package/dist/scheduling/DebounceCoordinator.js.map +1 -0
- package/dist/scheduling/DeferredDispatchSignal.d.ts +50 -0
- package/dist/scheduling/DeferredDispatchSignal.js +14 -0
- package/dist/scheduling/DeferredDispatchSignal.js.map +1 -0
- package/dist/scheduling/DeferredRunScheduler.d.ts +68 -0
- package/dist/scheduling/DeferredRunScheduler.js +154 -0
- package/dist/scheduling/DeferredRunScheduler.js.map +1 -0
- package/dist/scheduling/readSchedulingConfig.d.ts +24 -0
- package/dist/scheduling/readSchedulingConfig.js +52 -0
- package/dist/scheduling/readSchedulingConfig.js.map +1 -0
- package/dist/testing/WorkflowTestRunner.js +12 -0
- package/dist/testing/WorkflowTestRunner.js.map +1 -1
- package/dist/timeouts/StepTimeoutError.d.ts +22 -0
- package/dist/timeouts/StepTimeoutError.js +31 -0
- package/dist/timeouts/StepTimeoutError.js.map +1 -0
- package/dist/tracing/InMemoryRunStore.d.ts +28 -1
- package/dist/tracing/InMemoryRunStore.js +150 -0
- package/dist/tracing/InMemoryRunStore.js.map +1 -1
- package/dist/tracing/Janitor.d.ts +70 -0
- package/dist/tracing/Janitor.js +150 -0
- package/dist/tracing/Janitor.js.map +1 -0
- package/dist/tracing/PostgresRunStore.d.ts +30 -0
- package/dist/tracing/PostgresRunStore.js +435 -3
- package/dist/tracing/PostgresRunStore.js.map +1 -1
- package/dist/tracing/RunStore.d.ts +100 -1
- package/dist/tracing/RunTracker.d.ts +261 -11
- package/dist/tracing/RunTracker.js +691 -11
- package/dist/tracing/RunTracker.js.map +1 -1
- package/dist/tracing/SqliteRunStore.d.ts +23 -1
- package/dist/tracing/SqliteRunStore.js +421 -6
- package/dist/tracing/SqliteRunStore.js.map +1 -1
- package/dist/tracing/TraceRouter.d.ts +20 -2
- package/dist/tracing/TraceRouter.js +494 -9
- package/dist/tracing/TraceRouter.js.map +1 -1
- package/dist/tracing/sanitize.d.ts +11 -0
- package/dist/tracing/sanitize.js +29 -0
- package/dist/tracing/sanitize.js.map +1 -1
- package/dist/tracing/types.d.ts +429 -11
- package/dist/types/GlobalOptions.d.ts +9 -2
- package/dist/utils/createChildContext.d.ts +32 -0
- package/dist/utils/createChildContext.js +113 -0
- package/dist/utils/createChildContext.js.map +1 -0
- package/dist/workflow/PersistenceHelper.d.ts +46 -0
- package/dist/workflow/PersistenceHelper.js +57 -0
- package/dist/workflow/PersistenceHelper.js.map +1 -0
- package/dist/workflow/WorkflowNormalizer.d.ts +79 -0
- package/dist/workflow/WorkflowNormalizer.js +486 -0
- package/dist/workflow/WorkflowNormalizer.js.map +1 -0
- package/dist/workflow/WorkflowRegistry.d.ts +64 -0
- package/dist/workflow/WorkflowRegistry.js +81 -0
- package/dist/workflow/WorkflowRegistry.js.map +1 -0
- package/package.json +10 -7
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ import { HttpRuntimeAdapter } from "./adapters/HttpRuntimeAdapter";
|
|
|
13
13
|
import { NodeJsRuntimeAdapter } from "./adapters/NodeJsRuntimeAdapter";
|
|
14
14
|
import type { ExecutionResult, RuntimeAdapter, RuntimeKind } from "./adapters/RuntimeAdapter";
|
|
15
15
|
import { WasmRuntimeAdapter } from "./adapters/WasmRuntimeAdapter";
|
|
16
|
+
import { DEFAULT_HEALTH_SERVICE_CONFIG, buildChannelOptions } from "./adapters/grpc/GrpcChannelOptions";
|
|
17
|
+
import { GrpcClientPool, buildCredentials } from "./adapters/grpc/GrpcClientPool";
|
|
18
|
+
import { NodeRuntimeService, bufferToJson, decodeExecuteResponse, encodeExecuteRequest, jsonToBuffer } from "./adapters/grpc/GrpcCodec";
|
|
19
|
+
import { GRPC_STATUS_MAP, categoryToGrpcStatus, toBlokError as grpcToBlokError, isServiceError } from "./adapters/grpc/GrpcErrors";
|
|
20
|
+
import { GrpcRuntimeAdapter } from "./adapters/grpc/GrpcRuntimeAdapter";
|
|
21
|
+
import { DEFAULT_GRPC_PORTS, GRPC_DEFAULTS } from "./adapters/grpc/types";
|
|
22
|
+
import { resolveTransportForKind } from "./adapters/transport";
|
|
16
23
|
import { type FnNodeDefinition, FunctionNode, defineNode } from "./defineNode";
|
|
17
24
|
import { CircuitBreaker, CircuitOpenError } from "./monitoring/CircuitBreaker";
|
|
18
25
|
import { HealthCheck } from "./monitoring/HealthCheck";
|
|
@@ -39,10 +46,28 @@ import { GraphQLSchemaGenerator } from "./graphql/GraphQLSchemaGenerator";
|
|
|
39
46
|
import { NodeDependencyGraph } from "./visualization/NodeDependencyGraph";
|
|
40
47
|
import { WorkflowVisualizer } from "./visualization/WorkflowVisualizer";
|
|
41
48
|
import { PerformanceProfiler } from "./monitoring/PerformanceProfiler";
|
|
49
|
+
import { Janitor } from "./tracing/Janitor";
|
|
42
50
|
import { RunTracker } from "./tracing/RunTracker";
|
|
43
51
|
import { registerTraceRoutes } from "./tracing/TraceRouter";
|
|
44
52
|
import { TracingLogger } from "./tracing/TracingLogger";
|
|
45
|
-
import { sanitize as traceSanitize } from "./tracing/sanitize";
|
|
53
|
+
import { redactSensitive as traceRedactSensitive, sanitize as traceSanitize } from "./tracing/sanitize";
|
|
54
|
+
import { type RegisteredWorkflow, WorkflowRegistry } from "./workflow/WorkflowRegistry";
|
|
55
|
+
import { ConcurrencyLimitError, type ConcurrencyLimitInfo, isConcurrencyLimitError } from "./concurrency/ConcurrencyLimitError";
|
|
56
|
+
import { QueueExpiredError, type QueueExpiredInfo, isQueueExpiredError } from "./concurrency/QueueExpiredError";
|
|
57
|
+
import type { ConcurrencyBackend } from "./concurrency/ConcurrencyBackend";
|
|
58
|
+
import { NatsKvConcurrencyBackend, type NatsKvConcurrencyConfig, readNatsKvConfigFromEnv } from "./concurrency/NatsKvConcurrencyBackend";
|
|
59
|
+
import { createConcurrencyBackend } from "./concurrency/createConcurrencyBackend";
|
|
60
|
+
import { CONCURRENCY_DEFAULTS, type NormalizedConcurrencyConfig, readConcurrencyConfig } from "./concurrency/readConcurrencyConfig";
|
|
61
|
+
import { StepTimeoutError, isStepTimeoutError } from "./timeouts/StepTimeoutError";
|
|
62
|
+
import { RunCancelledError, isRunCancelledError } from "./RunCancelledError";
|
|
63
|
+
import { PayloadTooLargeError, isPayloadTooLargeError } from "./PayloadTooLargeError";
|
|
64
|
+
import { WaitDispatchRequest, isWaitDispatchRequest } from "./WaitDispatchRequest";
|
|
65
|
+
import { ConcurrencyMetrics } from "./monitoring/ConcurrencyMetrics";
|
|
66
|
+
import { JanitorMetrics } from "./monitoring/JanitorMetrics";
|
|
67
|
+
import { DebounceCoordinator } from "./scheduling/DebounceCoordinator";
|
|
68
|
+
import { type DeferredDispatchInfo, DeferredDispatchSignal, isDeferredDispatchSignal } from "./scheduling/DeferredDispatchSignal";
|
|
69
|
+
import { DeferredRunScheduler, type DeferredScheduleOptions } from "./scheduling/DeferredRunScheduler";
|
|
70
|
+
import { type NormalizedDebounceConfig, type NormalizedSchedulingConfig, SCHEDULING_DEFAULTS, readSchedulingConfig } from "./scheduling/readSchedulingConfig";
|
|
46
71
|
import { CostEstimator } from "./cost/CostEstimator";
|
|
47
72
|
import { DEFAULT_DURATIONS, DEFAULT_MEMORY, PRICING, getRuntimeCategory } from "./cost/pricing";
|
|
48
73
|
import { SentryIntegration } from "./integrations/SentryIntegration";
|
|
@@ -70,9 +95,13 @@ import Trigger from "./types/Trigger";
|
|
|
70
95
|
import TriggerHttp from "./types/TriggerHttp";
|
|
71
96
|
import TriggerResponse from "./types/TriggerResponse";
|
|
72
97
|
import Triggers from "./types/Triggers";
|
|
73
|
-
export { Configuration, Runner, ConfigurationResolver, DefaultLogger, LocalStorage, ResolverBase, TriggerBase, RuntimeRegistry, RuntimeAdapterNode, NodeJsRuntimeAdapter, DockerRuntimeAdapter, HttpRuntimeAdapter, BunRuntimeAdapter, WasmRuntimeAdapter, defineNode, FunctionNode, HealthCheck, RateLimiter, CircuitBreaker, CircuitOpenError, TriggerMetricsCollector, PrometheusMetricsBridge, bootstrapPrometheus, resetPrometheusBootstrap, RuntimeCatalog, RuntimeDiscovery, RuntimeHealthMonitor, RuntimeMetricsDashboard, RuntimeAutoScaler, FileWatcher, HotReloadManager, HmrDevConsole, AuthMiddleware, JWTAuthProvider, APIKeyAuthProvider, RBAC, createDefaultRBAC, ABACEngine, createDefaultABAC, AuditLogger, ConsoleAuditSink, FileAuditSink, InMemoryAuditSink, OAuthOIDCProvider, TokenCache, SecretManager, EnvironmentSecretProvider, InMemorySecretProvider, VaultSecretProvider, AWSSecretsProvider, GCPSecretProvider, OpenAPIGenerator, GraphQLSchemaGenerator, WorkflowVisualizer, NodeDependencyGraph, PerformanceProfiler, RunTracker, registerTraceRoutes, TracingLogger, traceSanitize, CostEstimator, PRICING, DEFAULT_DURATIONS, DEFAULT_MEMORY, getRuntimeCategory, SentryIntegration, InMemoryCache, NodeResultCache, NodeTestHarness, WorkflowTestRunner, TestLogger, Condition, Conditions, Config, Flow, Inputs, Node, Properties, Targets, Trigger, TriggerHttp, Triggers, ParamsDictionary, GlobalOptions, NodeMap, JsonLikeObject, BlokService, BlokResponse, IBlokResponse, RunnerSteps, Average, TriggerResponse, };
|
|
98
|
+
export { Configuration, Runner, ConfigurationResolver, DefaultLogger, LocalStorage, ResolverBase, TriggerBase, RuntimeRegistry, RuntimeAdapterNode, NodeJsRuntimeAdapter, DockerRuntimeAdapter, HttpRuntimeAdapter, BunRuntimeAdapter, WasmRuntimeAdapter, GrpcRuntimeAdapter, GrpcClientPool, buildCredentials, buildChannelOptions, NodeRuntimeService, encodeExecuteRequest, decodeExecuteResponse, jsonToBuffer, bufferToJson, GRPC_STATUS_MAP, GRPC_DEFAULTS, DEFAULT_GRPC_PORTS, DEFAULT_HEALTH_SERVICE_CONFIG, categoryToGrpcStatus, isServiceError, grpcToBlokError, resolveTransportForKind, defineNode, FunctionNode, HealthCheck, RateLimiter, CircuitBreaker, CircuitOpenError, TriggerMetricsCollector, PrometheusMetricsBridge, bootstrapPrometheus, resetPrometheusBootstrap, RuntimeCatalog, RuntimeDiscovery, RuntimeHealthMonitor, RuntimeMetricsDashboard, RuntimeAutoScaler, FileWatcher, HotReloadManager, HmrDevConsole, AuthMiddleware, JWTAuthProvider, APIKeyAuthProvider, RBAC, createDefaultRBAC, ABACEngine, createDefaultABAC, AuditLogger, ConsoleAuditSink, FileAuditSink, InMemoryAuditSink, OAuthOIDCProvider, TokenCache, SecretManager, EnvironmentSecretProvider, InMemorySecretProvider, VaultSecretProvider, AWSSecretsProvider, GCPSecretProvider, OpenAPIGenerator, GraphQLSchemaGenerator, WorkflowVisualizer, NodeDependencyGraph, PerformanceProfiler, RunTracker, Janitor, registerTraceRoutes, WorkflowRegistry, type RegisteredWorkflow, ConcurrencyLimitError, type ConcurrencyLimitInfo, isConcurrencyLimitError, QueueExpiredError, type QueueExpiredInfo, isQueueExpiredError, readConcurrencyConfig, type NormalizedConcurrencyConfig, CONCURRENCY_DEFAULTS, type ConcurrencyBackend, createConcurrencyBackend, NatsKvConcurrencyBackend, type NatsKvConcurrencyConfig, readNatsKvConfigFromEnv, StepTimeoutError, isStepTimeoutError, RunCancelledError, isRunCancelledError, PayloadTooLargeError, isPayloadTooLargeError, WaitDispatchRequest, isWaitDispatchRequest, ConcurrencyMetrics, JanitorMetrics, DeferredDispatchSignal, type DeferredDispatchInfo, isDeferredDispatchSignal, DeferredRunScheduler, type DeferredScheduleOptions, DebounceCoordinator, readSchedulingConfig, type NormalizedDebounceConfig, type NormalizedSchedulingConfig, SCHEDULING_DEFAULTS, TracingLogger, traceSanitize, traceRedactSensitive, CostEstimator, PRICING, DEFAULT_DURATIONS, DEFAULT_MEMORY, getRuntimeCategory, SentryIntegration, InMemoryCache, NodeResultCache, NodeTestHarness, WorkflowTestRunner, TestLogger, Condition, Conditions, Config, Flow, Inputs, Node, Properties, Targets, Trigger, TriggerHttp, Triggers, ParamsDictionary, GlobalOptions, NodeMap, JsonLikeObject, BlokService, BlokResponse, IBlokResponse, RunnerSteps, Average, TriggerResponse, };
|
|
74
99
|
export type { RuntimeAdapter, RuntimeKind, ExecutionResult, FnNodeDefinition };
|
|
75
100
|
export type { HttpRuntimeAdapterOptions } from "./adapters/HttpRuntimeAdapter";
|
|
101
|
+
export type { TraceAuthorizeFn, TraceRouterOptions } from "./tracing/TraceRouter";
|
|
102
|
+
export type { GrpcAdapterConfig, KeepaliveConfig, TlsConfig, Transport, } from "./adapters/grpc/types";
|
|
103
|
+
export type { DecodedExecuteResponse, DecodedLogLine, DecodedMetrics, DecodedNodeError, ExecuteRequestProto, ExecuteResponseProto, LogLineProto, MetricsProto, NodeErrorProto, NodeRefProto, RuntimeStateProto, StepInfoProto, TriggerInfoProto, WorkflowInfoProto, ExecuteOptionsProto, } from "./adapters/grpc/GrpcCodec";
|
|
104
|
+
export type { GrpcErrorContext } from "./adapters/grpc/GrpcErrors";
|
|
76
105
|
export type { HealthStatus, HealthCheckResult, DependencyHealth, DependencyCheckFn, } from "./monitoring/HealthCheck";
|
|
77
106
|
export type { RateLimitConfig, RateLimitResult } from "./monitoring/RateLimiter";
|
|
78
107
|
export type { CircuitState, CircuitBreakerConfig, CircuitBreakerStats, CircuitBreakerEvent, CircuitBreakerEventType, CircuitBreakerListener, } from "./monitoring/CircuitBreaker";
|
|
@@ -104,4 +133,7 @@ export type { CacheProvider, CacheEntry, CacheSetOptions, CacheStats, InMemoryCa
|
|
|
104
133
|
export type { LogEntry } from "./testing/TestLogger";
|
|
105
134
|
export type { TestContextOverrides, TestResult, TestMetrics } from "./testing/TestHarness";
|
|
106
135
|
export type { WorkflowTestConfig, WorkflowTestResult, ExecutionTrace, WorkflowExecuteOptions, } from "./testing/WorkflowTestRunner";
|
|
107
|
-
export type { WorkflowRun, WorkflowRunStatus, NodeRun, NodeRunStatus, RunEvent, RunEventType, TraceLogEntry, WorkflowSummary as TraceWorkflowSummary, WorkflowDetail as TraceWorkflowDetail, PaginatedResult, StartRunOptions, StartNodeOptions, } from "./tracing/types";
|
|
136
|
+
export type { WorkflowRun, WorkflowRunStatus, NodeRun, NodeRunStatus, RunEvent, RunEventType, TraceLogEntry, WorkflowSummary as TraceWorkflowSummary, WorkflowDetail as TraceWorkflowDetail, PaginatedResult, StartRunOptions, StartNodeOptions, ScheduledDispatchRow, } from "./tracing/types";
|
|
137
|
+
export type { JanitorStats } from "./tracing/Janitor";
|
|
138
|
+
export { createStore, InMemoryRunStore, SqliteRunStore } from "./tracing";
|
|
139
|
+
export type { CreateStoreOptions, StoreType } from "./tracing";
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,13 @@ import { DockerRuntimeAdapter } from "./adapters/DockerRuntimeAdapter";
|
|
|
13
13
|
import { HttpRuntimeAdapter } from "./adapters/HttpRuntimeAdapter";
|
|
14
14
|
import { NodeJsRuntimeAdapter } from "./adapters/NodeJsRuntimeAdapter";
|
|
15
15
|
import { WasmRuntimeAdapter } from "./adapters/WasmRuntimeAdapter";
|
|
16
|
+
import { DEFAULT_HEALTH_SERVICE_CONFIG, buildChannelOptions } from "./adapters/grpc/GrpcChannelOptions";
|
|
17
|
+
import { GrpcClientPool, buildCredentials } from "./adapters/grpc/GrpcClientPool";
|
|
18
|
+
import { NodeRuntimeService, bufferToJson, decodeExecuteResponse, encodeExecuteRequest, jsonToBuffer, } from "./adapters/grpc/GrpcCodec";
|
|
19
|
+
import { GRPC_STATUS_MAP, categoryToGrpcStatus, toBlokError as grpcToBlokError, isServiceError, } from "./adapters/grpc/GrpcErrors";
|
|
20
|
+
import { GrpcRuntimeAdapter } from "./adapters/grpc/GrpcRuntimeAdapter";
|
|
21
|
+
import { DEFAULT_GRPC_PORTS, GRPC_DEFAULTS } from "./adapters/grpc/types";
|
|
22
|
+
import { resolveTransportForKind } from "./adapters/transport";
|
|
16
23
|
// Function-first node API
|
|
17
24
|
import { FunctionNode, defineNode } from "./defineNode";
|
|
18
25
|
import { CircuitBreaker, CircuitOpenError } from "./monitoring/CircuitBreaker";
|
|
@@ -49,10 +56,37 @@ import { WorkflowVisualizer } from "./visualization/WorkflowVisualizer";
|
|
|
49
56
|
// Performance Profiling
|
|
50
57
|
import { PerformanceProfiler } from "./monitoring/PerformanceProfiler";
|
|
51
58
|
// Tracing (Blok Studio)
|
|
59
|
+
import { Janitor } from "./tracing/Janitor";
|
|
52
60
|
import { RunTracker } from "./tracing/RunTracker";
|
|
53
61
|
import { registerTraceRoutes } from "./tracing/TraceRouter";
|
|
54
62
|
import { TracingLogger } from "./tracing/TracingLogger";
|
|
55
|
-
import { sanitize as traceSanitize } from "./tracing/sanitize";
|
|
63
|
+
import { redactSensitive as traceRedactSensitive, sanitize as traceSanitize } from "./tracing/sanitize";
|
|
64
|
+
// Workflow registry (Tier 2 sub-workflow primitive)
|
|
65
|
+
import { WorkflowRegistry } from "./workflow/WorkflowRegistry";
|
|
66
|
+
// Concurrency gate (Tier 2 #6)
|
|
67
|
+
import { ConcurrencyLimitError, isConcurrencyLimitError, } from "./concurrency/ConcurrencyLimitError";
|
|
68
|
+
// Queue-mode TTL expiry (PR 1-5 polish · 410 Gone vs 429)
|
|
69
|
+
import { QueueExpiredError, isQueueExpiredError } from "./concurrency/QueueExpiredError";
|
|
70
|
+
import { NatsKvConcurrencyBackend, readNatsKvConfigFromEnv, } from "./concurrency/NatsKvConcurrencyBackend";
|
|
71
|
+
import { createConcurrencyBackend } from "./concurrency/createConcurrencyBackend";
|
|
72
|
+
import { CONCURRENCY_DEFAULTS, readConcurrencyConfig, } from "./concurrency/readConcurrencyConfig";
|
|
73
|
+
// Per-step timeout (Tier 2 quick-wins)
|
|
74
|
+
import { StepTimeoutError, isStepTimeoutError } from "./timeouts/StepTimeoutError";
|
|
75
|
+
// Cooperative cancellation (Tier 2 follow-up)
|
|
76
|
+
import { RunCancelledError, isRunCancelledError } from "./RunCancelledError";
|
|
77
|
+
// Durable-scheduler payload size cap (PR 2 A4)
|
|
78
|
+
import { PayloadTooLargeError, isPayloadTooLargeError } from "./PayloadTooLargeError";
|
|
79
|
+
// Wait step primitive (PR 4)
|
|
80
|
+
import { WaitDispatchRequest, isWaitDispatchRequest } from "./WaitDispatchRequest";
|
|
81
|
+
// Concurrency / scheduling OTel metrics (Tier 2 follow-up)
|
|
82
|
+
import { ConcurrencyMetrics } from "./monitoring/ConcurrencyMetrics";
|
|
83
|
+
// Janitor sweep OTel metrics (PR 3 D3)
|
|
84
|
+
import { JanitorMetrics } from "./monitoring/JanitorMetrics";
|
|
85
|
+
// Scheduling — delay / TTL / debounce (Tier 2 #5 + #7)
|
|
86
|
+
import { DebounceCoordinator } from "./scheduling/DebounceCoordinator";
|
|
87
|
+
import { DeferredDispatchSignal, isDeferredDispatchSignal, } from "./scheduling/DeferredDispatchSignal";
|
|
88
|
+
import { DeferredRunScheduler } from "./scheduling/DeferredRunScheduler";
|
|
89
|
+
import { SCHEDULING_DEFAULTS, readSchedulingConfig, } from "./scheduling/readSchedulingConfig";
|
|
56
90
|
// Cost Estimation
|
|
57
91
|
import { CostEstimator } from "./cost/CostEstimator";
|
|
58
92
|
import { DEFAULT_DURATIONS, DEFAULT_MEMORY, PRICING, getRuntimeCategory } from "./cost/pricing";
|
|
@@ -72,6 +106,8 @@ import RunnerSteps from "./RunnerSteps";
|
|
|
72
106
|
export { Configuration, Runner, ConfigurationResolver, DefaultLogger, LocalStorage, ResolverBase, TriggerBase,
|
|
73
107
|
// Runtime adapters
|
|
74
108
|
RuntimeRegistry, RuntimeAdapterNode, NodeJsRuntimeAdapter, DockerRuntimeAdapter, HttpRuntimeAdapter, BunRuntimeAdapter, WasmRuntimeAdapter,
|
|
109
|
+
// gRPC runtime adapter
|
|
110
|
+
GrpcRuntimeAdapter, GrpcClientPool, buildCredentials, buildChannelOptions, NodeRuntimeService, encodeExecuteRequest, decodeExecuteResponse, jsonToBuffer, bufferToJson, GRPC_STATUS_MAP, GRPC_DEFAULTS, DEFAULT_GRPC_PORTS, DEFAULT_HEALTH_SERVICE_CONFIG, categoryToGrpcStatus, isServiceError, grpcToBlokError, resolveTransportForKind,
|
|
75
111
|
// Function-first API
|
|
76
112
|
defineNode, FunctionNode,
|
|
77
113
|
// Monitoring
|
|
@@ -95,7 +131,25 @@ WorkflowVisualizer, NodeDependencyGraph,
|
|
|
95
131
|
// Performance Profiling
|
|
96
132
|
PerformanceProfiler,
|
|
97
133
|
// Tracing (Blok Studio)
|
|
98
|
-
RunTracker,
|
|
134
|
+
RunTracker, Janitor, registerTraceRoutes, WorkflowRegistry,
|
|
135
|
+
// Concurrency gate (Tier 2 #6)
|
|
136
|
+
ConcurrencyLimitError, isConcurrencyLimitError,
|
|
137
|
+
// Queue-mode TTL expiry (PR 1-5 polish)
|
|
138
|
+
QueueExpiredError, isQueueExpiredError, readConcurrencyConfig, CONCURRENCY_DEFAULTS, createConcurrencyBackend, NatsKvConcurrencyBackend, readNatsKvConfigFromEnv,
|
|
139
|
+
// Per-step timeout (Tier 2 quick-wins)
|
|
140
|
+
StepTimeoutError, isStepTimeoutError,
|
|
141
|
+
// Cooperative cancellation (Tier 2 follow-up)
|
|
142
|
+
RunCancelledError, isRunCancelledError,
|
|
143
|
+
// Durable-scheduler payload size cap (PR 2 A4)
|
|
144
|
+
PayloadTooLargeError, isPayloadTooLargeError,
|
|
145
|
+
// Wait step primitive (PR 4)
|
|
146
|
+
WaitDispatchRequest, isWaitDispatchRequest,
|
|
147
|
+
// Concurrency / scheduling OTel metrics (Tier 2 follow-up)
|
|
148
|
+
ConcurrencyMetrics,
|
|
149
|
+
// Janitor sweep OTel metrics (PR 3 D3)
|
|
150
|
+
JanitorMetrics,
|
|
151
|
+
// Scheduling — delay / TTL / debounce (Tier 2 #5 + #7)
|
|
152
|
+
DeferredDispatchSignal, isDeferredDispatchSignal, DeferredRunScheduler, DebounceCoordinator, readSchedulingConfig, SCHEDULING_DEFAULTS, TracingLogger, traceSanitize, traceRedactSensitive,
|
|
99
153
|
// Cost Estimation
|
|
100
154
|
CostEstimator, PRICING, DEFAULT_DURATIONS, DEFAULT_MEMORY, getRuntimeCategory,
|
|
101
155
|
// Integrations
|
|
@@ -104,4 +158,9 @@ SentryIntegration,
|
|
|
104
158
|
InMemoryCache, NodeResultCache,
|
|
105
159
|
// Testing
|
|
106
160
|
NodeTestHarness, WorkflowTestRunner, TestLogger, NodeMap, BlokService, BlokResponse, RunnerSteps, };
|
|
161
|
+
// Tracing store factory + concrete stores — exposed so the CLI's
|
|
162
|
+
// standalone `blokctl studio` mode can spin up its own SQLite-backed
|
|
163
|
+
// tracker without proxying to a live trigger. See
|
|
164
|
+
// `packages/cli/src/commands/trace/startStudio.ts` for the call site.
|
|
165
|
+
export { createStore, InMemoryRunStore, SqliteRunStore } from "./tracing";
|
|
107
166
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;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ErB,uBAAuB;AACvB,wCAAwC;AACxC,iBAAiB,EAEjB,mBAAmB,EACnB,qBAAqB,EAErB,oBAAoB,EAGpB,wBAAwB,EACxB,wBAAwB,EAExB,uBAAuB;AACvB,uCAAuC;AACvC,gBAAgB,EAChB,kBAAkB;AAClB,8CAA8C;AAC9C,iBAAiB,EACjB,mBAAmB;AACnB,+CAA+C;AAC/C,oBAAoB,EACpB,sBAAsB;AACtB,6BAA6B;AAC7B,mBAAmB,EACnB,qBAAqB;AACrB,2DAA2D;AAC3D,kBAAkB;AAClB,uCAAuC;AACvC,cAAc;AACd,uDAAuD;AACvD,sBAAsB,EAEtB,wBAAwB,EACxB,oBAAoB,EAEpB,mBAAmB,EACnB,oBAAoB,EAGpB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,oBAAoB;AACpB,kBAAkB;AAClB,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,kBAAkB;AAClB,eAAe;AACf,iBAAiB;AACjB,QAAQ;AACR,aAAa,EACb,eAAe;AACf,UAAU;AACV,eAAe,EACf,kBAAkB,EAClB,UAAU,EAeV,OAAO,EAEP,WAAW,EACX,YAAY,EAEZ,WAAW,GAGX,CAAC;AAsRF,iEAAiE;AACjE,qEAAqE;AACrE,kDAAkD;AAClD,sEAAsE;AACtE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier 2 follow-up · OpenTelemetry counters for concurrency + scheduling
|
|
3
|
+
* resource lifecycle events.
|
|
4
|
+
*
|
|
5
|
+
* Wired into:
|
|
6
|
+
* - `TriggerBase.run`'s concurrency gate — `recordAcquired` /
|
|
7
|
+
* `recordDenied` / `recordReleased` per slot operation.
|
|
8
|
+
* - `HttpTrigger.recoverDispatches` — `recordDispatchRecovered` /
|
|
9
|
+
* `recordDispatchExpired` for boot-recovery observability.
|
|
10
|
+
* - The scheduler / debounce coordinator — `recordDispatchFired`
|
|
11
|
+
* when a deferred timer fires successfully.
|
|
12
|
+
*
|
|
13
|
+
* Singleton; lazy-instantiated. No-ops cleanly when OTel isn't
|
|
14
|
+
* configured (the meter API silently swallows recordings without
|
|
15
|
+
* an exporter).
|
|
16
|
+
*/
|
|
17
|
+
interface ConcurrencyAttributes {
|
|
18
|
+
workflow_name: string;
|
|
19
|
+
concurrency_key?: string;
|
|
20
|
+
}
|
|
21
|
+
interface SchedulingAttributes {
|
|
22
|
+
workflow_name: string;
|
|
23
|
+
trigger_type: string;
|
|
24
|
+
dispatch_status?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare class ConcurrencyMetrics {
|
|
27
|
+
private static instance;
|
|
28
|
+
private readonly acquiredCounter;
|
|
29
|
+
private readonly deniedCounter;
|
|
30
|
+
private readonly releasedCounter;
|
|
31
|
+
private readonly dispatchRecoveredCounter;
|
|
32
|
+
private readonly dispatchExpiredCounter;
|
|
33
|
+
private readonly dispatchFiredCounter;
|
|
34
|
+
private readonly backendInstallCounter;
|
|
35
|
+
private readonly occRetriesHistogram;
|
|
36
|
+
private constructor();
|
|
37
|
+
static getInstance(): ConcurrencyMetrics;
|
|
38
|
+
/** Test-only — drop the singleton so re-import gets fresh meters. */
|
|
39
|
+
static resetInstance(): void;
|
|
40
|
+
recordAcquired(attrs: ConcurrencyAttributes): void;
|
|
41
|
+
recordDenied(attrs: ConcurrencyAttributes & {
|
|
42
|
+
mode: "throw" | "queue";
|
|
43
|
+
}): void;
|
|
44
|
+
recordReleased(attrs: ConcurrencyAttributes): void;
|
|
45
|
+
recordDispatchRecovered(attrs: SchedulingAttributes): void;
|
|
46
|
+
recordDispatchExpired(attrs: SchedulingAttributes): void;
|
|
47
|
+
recordDispatchFired(attrs: SchedulingAttributes): void;
|
|
48
|
+
recordBackendInstall(attrs: {
|
|
49
|
+
backend: string;
|
|
50
|
+
status: "success" | "failure";
|
|
51
|
+
}): void;
|
|
52
|
+
recordOccRetries(attrs: ConcurrencyAttributes & {
|
|
53
|
+
outcome: "success" | "denied" | "fail-closed";
|
|
54
|
+
}, attempts: number): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier 2 follow-up · OpenTelemetry counters for concurrency + scheduling
|
|
3
|
+
* resource lifecycle events.
|
|
4
|
+
*
|
|
5
|
+
* Wired into:
|
|
6
|
+
* - `TriggerBase.run`'s concurrency gate — `recordAcquired` /
|
|
7
|
+
* `recordDenied` / `recordReleased` per slot operation.
|
|
8
|
+
* - `HttpTrigger.recoverDispatches` — `recordDispatchRecovered` /
|
|
9
|
+
* `recordDispatchExpired` for boot-recovery observability.
|
|
10
|
+
* - The scheduler / debounce coordinator — `recordDispatchFired`
|
|
11
|
+
* when a deferred timer fires successfully.
|
|
12
|
+
*
|
|
13
|
+
* Singleton; lazy-instantiated. No-ops cleanly when OTel isn't
|
|
14
|
+
* configured (the meter API silently swallows recordings without
|
|
15
|
+
* an exporter).
|
|
16
|
+
*/
|
|
17
|
+
import { metrics } from "@opentelemetry/api";
|
|
18
|
+
export class ConcurrencyMetrics {
|
|
19
|
+
static instance = null;
|
|
20
|
+
acquiredCounter = metrics.getMeter("blok").createCounter("blok_concurrency_acquired_total", {
|
|
21
|
+
description: "Total concurrency slots acquired (per workflow + key).",
|
|
22
|
+
unit: "1",
|
|
23
|
+
});
|
|
24
|
+
deniedCounter = metrics.getMeter("blok").createCounter("blok_concurrency_denied_total", {
|
|
25
|
+
description: "Total concurrency slot denials (limit hit; throttled or queued).",
|
|
26
|
+
unit: "1",
|
|
27
|
+
});
|
|
28
|
+
releasedCounter = metrics.getMeter("blok").createCounter("blok_concurrency_released_total", {
|
|
29
|
+
description: "Total concurrency slots released (run reached terminal state).",
|
|
30
|
+
unit: "1",
|
|
31
|
+
});
|
|
32
|
+
dispatchRecoveredCounter = metrics
|
|
33
|
+
.getMeter("blok")
|
|
34
|
+
.createCounter("blok_scheduling_dispatch_recovered_total", {
|
|
35
|
+
description: "Scheduled dispatches re-registered on boot recovery (HttpTrigger).",
|
|
36
|
+
unit: "1",
|
|
37
|
+
});
|
|
38
|
+
dispatchExpiredCounter = metrics
|
|
39
|
+
.getMeter("blok")
|
|
40
|
+
.createCounter("blok_scheduling_dispatch_expired_total", {
|
|
41
|
+
description: "Scheduled dispatches marked expired on boot recovery (TTL elapsed).",
|
|
42
|
+
unit: "1",
|
|
43
|
+
});
|
|
44
|
+
dispatchFiredCounter = metrics
|
|
45
|
+
.getMeter("blok")
|
|
46
|
+
.createCounter("blok_scheduling_dispatch_fired_total", {
|
|
47
|
+
description: "Scheduled dispatches fired by the in-process scheduler.",
|
|
48
|
+
unit: "1",
|
|
49
|
+
});
|
|
50
|
+
// PR 3 D1 — backend install observability. Operators who misconfigure
|
|
51
|
+
// the cross-process backend (NATS KV unreachable / auth failure) get a
|
|
52
|
+
// silent fallback to the in-process backend. This counter surfaces
|
|
53
|
+
// install attempts so misconfiguration is visible in metrics.
|
|
54
|
+
backendInstallCounter = metrics
|
|
55
|
+
.getMeter("blok")
|
|
56
|
+
.createCounter("blok_concurrency_backend_install_total", {
|
|
57
|
+
description: "Concurrency backend install attempts (success / failure).",
|
|
58
|
+
unit: "1",
|
|
59
|
+
});
|
|
60
|
+
// PR 3 D2 — OCC retry depth histogram. The 95% fail-close rate at
|
|
61
|
+
// 200-way contention seen in LOAD-TESTS.md is invisible without a
|
|
62
|
+
// histogram. Recorded per acquireSlot exit point with bucket
|
|
63
|
+
// boundaries [0, 1, 2, 3, 5, 10] — OCC retry budget caps at 10.
|
|
64
|
+
occRetriesHistogram = metrics.getMeter("blok").createHistogram("blok_concurrency_occ_retries", {
|
|
65
|
+
description: "OCC retry attempts on cross-process concurrency backends.",
|
|
66
|
+
unit: "{retries}",
|
|
67
|
+
advice: { explicitBucketBoundaries: [0, 1, 2, 3, 5, 10] },
|
|
68
|
+
});
|
|
69
|
+
constructor() { }
|
|
70
|
+
static getInstance() {
|
|
71
|
+
if (!ConcurrencyMetrics.instance) {
|
|
72
|
+
ConcurrencyMetrics.instance = new ConcurrencyMetrics();
|
|
73
|
+
}
|
|
74
|
+
return ConcurrencyMetrics.instance;
|
|
75
|
+
}
|
|
76
|
+
/** Test-only — drop the singleton so re-import gets fresh meters. */
|
|
77
|
+
static resetInstance() {
|
|
78
|
+
ConcurrencyMetrics.instance = null;
|
|
79
|
+
}
|
|
80
|
+
recordAcquired(attrs) {
|
|
81
|
+
this.acquiredCounter.add(1, attrs);
|
|
82
|
+
}
|
|
83
|
+
recordDenied(attrs) {
|
|
84
|
+
this.deniedCounter.add(1, attrs);
|
|
85
|
+
}
|
|
86
|
+
recordReleased(attrs) {
|
|
87
|
+
this.releasedCounter.add(1, attrs);
|
|
88
|
+
}
|
|
89
|
+
recordDispatchRecovered(attrs) {
|
|
90
|
+
this.dispatchRecoveredCounter.add(1, attrs);
|
|
91
|
+
}
|
|
92
|
+
recordDispatchExpired(attrs) {
|
|
93
|
+
this.dispatchExpiredCounter.add(1, attrs);
|
|
94
|
+
}
|
|
95
|
+
recordDispatchFired(attrs) {
|
|
96
|
+
this.dispatchFiredCounter.add(1, attrs);
|
|
97
|
+
}
|
|
98
|
+
// PR 3 D1 — backend install attempt outcome.
|
|
99
|
+
recordBackendInstall(attrs) {
|
|
100
|
+
this.backendInstallCounter.add(1, attrs);
|
|
101
|
+
}
|
|
102
|
+
// PR 3 D2 — OCC retry depth + outcome (success | denied | fail-closed).
|
|
103
|
+
recordOccRetries(attrs, attempts) {
|
|
104
|
+
this.occRetriesHistogram.record(attempts, attrs);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=ConcurrencyMetrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrencyMetrics.js","sourceRoot":"","sources":["../../src/monitoring/ConcurrencyMetrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,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KAA0C,CAAC,CAAC;IAChF,CAAC;IAED,mBAAmB,CAAC,KAA2B;QAC9C,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,EAAE,KAA0C,CAAC,CAAC;IAC9E,CAAC;IAED,6CAA6C;IAC7C,oBAAoB,CAAC,KAAyD;QAC7E,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,KAA0C,CAAC,CAAC;IAC/E,CAAC;IAED,wEAAwE;IACxE,gBAAgB,CACf,KAAgF,EAChF,QAAgB;QAEhB,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,KAA0C,CAAC,CAAC;IACvF,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PR 3 D3 — OpenTelemetry metrics for the Janitor sweep.
|
|
3
|
+
*
|
|
4
|
+
* Operators tuning `BLOK_JANITOR_INTERVAL_MS` need real numbers per
|
|
5
|
+
* sweep: how long does each table's purge take, how many rows did it
|
|
6
|
+
* remove? This singleton exposes a histogram for sweep duration and a
|
|
7
|
+
* counter for purged rows, both labeled by the table being swept.
|
|
8
|
+
*
|
|
9
|
+
* Wired into `Janitor.runOnce` per-table after each purge call.
|
|
10
|
+
*
|
|
11
|
+
* No-op cleanly when OTel isn't configured (the meter API silently
|
|
12
|
+
* swallows recordings without an exporter).
|
|
13
|
+
*/
|
|
14
|
+
interface JanitorAttributes {
|
|
15
|
+
table: "idempotency_cache" | "concurrency_locks" | "scheduled_dispatches";
|
|
16
|
+
}
|
|
17
|
+
export declare class JanitorMetrics {
|
|
18
|
+
private static instance;
|
|
19
|
+
private readonly sweepDurationHistogram;
|
|
20
|
+
private readonly purgedCounter;
|
|
21
|
+
private constructor();
|
|
22
|
+
static getInstance(): JanitorMetrics;
|
|
23
|
+
/** Test-only — drop the singleton so re-import gets fresh meters. */
|
|
24
|
+
static resetInstance(): void;
|
|
25
|
+
recordSweep(attrs: JanitorAttributes, durationMs: number, rowsPurged: number): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PR 3 D3 — OpenTelemetry metrics for the Janitor sweep.
|
|
3
|
+
*
|
|
4
|
+
* Operators tuning `BLOK_JANITOR_INTERVAL_MS` need real numbers per
|
|
5
|
+
* sweep: how long does each table's purge take, how many rows did it
|
|
6
|
+
* remove? This singleton exposes a histogram for sweep duration and a
|
|
7
|
+
* counter for purged rows, both labeled by the table being swept.
|
|
8
|
+
*
|
|
9
|
+
* Wired into `Janitor.runOnce` per-table after each purge call.
|
|
10
|
+
*
|
|
11
|
+
* No-op cleanly when OTel isn't configured (the meter API silently
|
|
12
|
+
* swallows recordings without an exporter).
|
|
13
|
+
*/
|
|
14
|
+
import { metrics } from "@opentelemetry/api";
|
|
15
|
+
export class JanitorMetrics {
|
|
16
|
+
static instance = null;
|
|
17
|
+
sweepDurationHistogram = metrics.getMeter("blok").createHistogram("blok_janitor_sweep_duration_ms", {
|
|
18
|
+
description: "Janitor sweep duration per table.",
|
|
19
|
+
unit: "ms",
|
|
20
|
+
advice: { explicitBucketBoundaries: [1, 5, 10, 50, 100, 500, 1000, 5000, 30000] },
|
|
21
|
+
});
|
|
22
|
+
purgedCounter = metrics.getMeter("blok").createCounter("blok_janitor_purged_total", {
|
|
23
|
+
description: "Total rows purged by the Janitor per table.",
|
|
24
|
+
unit: "1",
|
|
25
|
+
});
|
|
26
|
+
constructor() { }
|
|
27
|
+
static getInstance() {
|
|
28
|
+
if (!JanitorMetrics.instance) {
|
|
29
|
+
JanitorMetrics.instance = new JanitorMetrics();
|
|
30
|
+
}
|
|
31
|
+
return JanitorMetrics.instance;
|
|
32
|
+
}
|
|
33
|
+
/** Test-only — drop the singleton so re-import gets fresh meters. */
|
|
34
|
+
static resetInstance() {
|
|
35
|
+
JanitorMetrics.instance = null;
|
|
36
|
+
}
|
|
37
|
+
recordSweep(attrs, durationMs, rowsPurged) {
|
|
38
|
+
this.sweepDurationHistogram.record(durationMs, attrs);
|
|
39
|
+
// Review fix-up · GAP-2. Always record the counter, even when zero.
|
|
40
|
+
// Without zero-row recordings, operators can't distinguish
|
|
41
|
+
// "Janitor running, table clean" from "Janitor not running" by
|
|
42
|
+
// looking at the counter alone. The duration histogram captures
|
|
43
|
+
// liveness too, but pairing them under the same emit cadence
|
|
44
|
+
// keeps dashboards consistent.
|
|
45
|
+
this.purgedCounter.add(rowsPurged, attrs);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=JanitorMetrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JanitorMetrics.js","sourceRoot":"","sources":["../../src/monitoring/JanitorMetrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAM7C,MAAM,OAAO,cAAc;IAClB,MAAM,CAAC,QAAQ,GAA0B,IAAI,CAAC;IAErC,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,gCAAgC,EAAE;QACpH,WAAW,EAAE,mCAAmC;QAChD,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,EAAE,wBAAwB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE;KACjF,CAAC,CAAC;IAEc,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,2BAA2B,EAAE;QACpG,WAAW,EAAE,6CAA6C;QAC1D,IAAI,EAAE,GAAG;KACT,CAAC,CAAC;IAEH,gBAAuB,CAAC;IAExB,MAAM,CAAC,WAAW;QACjB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC9B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,qEAAqE;IACrE,MAAM,CAAC,aAAa;QACnB,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,WAAW,CAAC,KAAwB,EAAE,UAAkB,EAAE,UAAkB;QAC3E,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,UAAU,EAAE,KAA0C,CAAC,CAAC;QAC3F,oEAAoE;QACpE,2DAA2D;QAC3D,+DAA+D;QAC/D,gEAAgE;QAChE,6DAA6D;QAC7D,+BAA+B;QAC/B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,KAA0C,CAAC,CAAC;IAChF,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier 2 #7 — in-memory debounce coordinator.
|
|
3
|
+
*
|
|
4
|
+
* Coalesces rapid same-key triggers into a single delayed run. Modes:
|
|
5
|
+
*
|
|
6
|
+
* - `"trailing"` (default): each ping resets a timer; the run fires
|
|
7
|
+
* after `delayMs` of silence. Latest payload wins. `maxDelayMs`
|
|
8
|
+
* bounds tail latency — even with continuous pings, the run fires
|
|
9
|
+
* after `maxDelayMs` from the FIRST ping.
|
|
10
|
+
* - `"leading"`: the first ping fires immediately. Subsequent pings
|
|
11
|
+
* within `delayMs` are dropped. Window resets after `delayMs` of
|
|
12
|
+
* silence.
|
|
13
|
+
*
|
|
14
|
+
* Process-wide singleton. In-memory only for v1 — cross-process
|
|
15
|
+
* debounce keys are a deferred follow-up.
|
|
16
|
+
*/
|
|
17
|
+
export type DebounceDispatchFn = () => Promise<void>;
|
|
18
|
+
export type DebounceMode = "leading" | "trailing";
|
|
19
|
+
export interface DebounceRegisterOpts {
|
|
20
|
+
workflowName: string;
|
|
21
|
+
debounceKey: string;
|
|
22
|
+
mode: DebounceMode;
|
|
23
|
+
delayMs: number;
|
|
24
|
+
maxDelayMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Run id allocated by the caller for THIS ping. On a fresh window
|
|
27
|
+
* this becomes the active run id; on a coalesce it's a "loser" and
|
|
28
|
+
* the caller marks it `debounced` terminal.
|
|
29
|
+
*/
|
|
30
|
+
runId: string;
|
|
31
|
+
/**
|
|
32
|
+
* Callback the coordinator invokes when the trailing-mode window
|
|
33
|
+
* closes. Captures ctx + runId via closure. NOT called for leading
|
|
34
|
+
* mode (the caller runs the first ping synchronously) or for
|
|
35
|
+
* coalesce pings (those are dropped by definition).
|
|
36
|
+
*/
|
|
37
|
+
onFire: DebounceDispatchFn;
|
|
38
|
+
/**
|
|
39
|
+
* Test-only override of "now" for deterministic tests. Production
|
|
40
|
+
* code does not pass this.
|
|
41
|
+
*/
|
|
42
|
+
__now?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The outcome of `register`. Branches the caller's behavior.
|
|
46
|
+
*
|
|
47
|
+
* - `"fire-immediate"` (leading + fresh window) — caller runs the
|
|
48
|
+
* workflow synchronously. The window is now open; subsequent pings
|
|
49
|
+
* in `delayMs` are suppressed.
|
|
50
|
+
* - `"schedule-trailing"` (trailing + fresh window) — caller marks the
|
|
51
|
+
* run `debounced` (transient) and throws `DeferredDispatchSignal`.
|
|
52
|
+
* The coordinator's timer will invoke `onFire` after the window.
|
|
53
|
+
* - `"coalesce"` (leading or trailing + existing window) — caller marks
|
|
54
|
+
* the run `debounced` (terminal, with `intoRunId = activeRunId`) and
|
|
55
|
+
* throws `DeferredDispatchSignal`. The active run absorbs the ping.
|
|
56
|
+
*/
|
|
57
|
+
export interface DebounceRegisterResult {
|
|
58
|
+
outcome: "fire-immediate" | "schedule-trailing" | "coalesce";
|
|
59
|
+
/**
|
|
60
|
+
* The runId of the run that owns the active window. Equal to
|
|
61
|
+
* `opts.runId` on `fire-immediate` and `schedule-trailing`; equal to
|
|
62
|
+
* the EXISTING window's runId on `coalesce` (so the caller knows
|
|
63
|
+
* which run absorbed the ping).
|
|
64
|
+
*/
|
|
65
|
+
activeRunId: string;
|
|
66
|
+
/** Dispatch time for trailing windows; undefined on `fire-immediate`. */
|
|
67
|
+
scheduledAt?: number;
|
|
68
|
+
/** Pings absorbed by the active window so far (including this one). */
|
|
69
|
+
pingCount: number;
|
|
70
|
+
}
|
|
71
|
+
export declare class DebounceCoordinator {
|
|
72
|
+
private static instance;
|
|
73
|
+
private states;
|
|
74
|
+
static getInstance(): DebounceCoordinator;
|
|
75
|
+
/** Test-only — reset the singleton + clear all state. */
|
|
76
|
+
static resetInstance(): void;
|
|
77
|
+
private bucket;
|
|
78
|
+
register(opts: DebounceRegisterOpts): DebounceRegisterResult;
|
|
79
|
+
private fireTrailing;
|
|
80
|
+
/** Cancel an active window without firing. Returns true if cancelled. */
|
|
81
|
+
cancel(workflowName: string, debounceKey: string): boolean;
|
|
82
|
+
/** Number of active debounce windows. Tests + observability. */
|
|
83
|
+
size(): number;
|
|
84
|
+
/** True if a window is open for `(workflow, key)`. */
|
|
85
|
+
has(workflowName: string, debounceKey: string): boolean;
|
|
86
|
+
/** Cancel everything without firing. */
|
|
87
|
+
clear(): void;
|
|
88
|
+
}
|