@hatchet-dev/typescript-sdk 1.35.1 → 1.37.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/clients/rest/generated/Api.d.ts +85 -1
- package/clients/rest/generated/Api.js +30 -0
- package/clients/rest/generated/data-contracts.d.ts +11 -0
- package/package.json +1 -1
- package/protoc/dispatcher/dispatcher.d.ts +4 -0
- package/protoc/dispatcher/dispatcher.js +42 -2
- package/protoc/v1/streams.d.ts +34 -0
- package/protoc/v1/streams.js +279 -5
- package/protoc-es/dispatcher/dispatcher_pb.d.ts +12 -0
- package/protoc-es/dispatcher/dispatcher_pb.js +1 -1
- package/protoc-es/v1/streams_pb.d.ts +79 -0
- package/protoc-es/v1/streams_pb.js +12 -2
- package/v1/client/duration.js +3 -3
- package/v1/client/features/streams.d.ts +22 -0
- package/v1/client/features/streams.js +93 -13
- package/v1/client/worker/engine-version.d.ts +2 -0
- package/v1/client/worker/engine-version.js +7 -0
- package/v1/client/worker/worker-internal.d.ts +2 -0
- package/v1/client/worker/worker-internal.js +20 -1
- package/v1/examples/durable-streams/benchmark.d.ts +34 -0
- package/v1/examples/durable-streams/benchmark.js +120 -0
- package/v1/examples/e2e-worker.js +52 -49
- package/v1/examples/retry_after/run.d.ts +1 -0
- package/v1/examples/retry_after/run.js +21 -0
- package/v1/examples/retry_after/worker.d.ts +1 -0
- package/v1/examples/retry_after/worker.js +24 -0
- package/v1/examples/retry_after/workflow.d.ts +9 -0
- package/v1/examples/retry_after/workflow.js +40 -0
- package/v1/task.d.ts +13 -0
- package/v1/task.js +14 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/v1/examples/durable-streams/publish-latency.d.ts +0 -15
- package/v1/examples/durable-streams/publish-latency.js +0 -50
package/v1/task.d.ts
CHANGED
|
@@ -96,6 +96,19 @@ export type IdempotencyConfig = TTLBasedIdempotencyConfig | StatusBasedIdempoten
|
|
|
96
96
|
export declare class NonRetryableError extends Error {
|
|
97
97
|
constructor(message?: string);
|
|
98
98
|
}
|
|
99
|
+
export type RetryAfterOpts = {
|
|
100
|
+
/**
|
|
101
|
+
* The delay before the next attempt, e.g. `'90s'`, `{ minutes: 5 }`, or a number of milliseconds.
|
|
102
|
+
*/
|
|
103
|
+
after: Duration;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Throw from a task to retry it after a delay of its choosing. The retry counts against the task's `retries`.
|
|
107
|
+
*/
|
|
108
|
+
export declare class RetryAfterError extends Error {
|
|
109
|
+
readonly afterMs: number;
|
|
110
|
+
constructor(message: string | undefined, opts: RetryAfterOpts);
|
|
111
|
+
}
|
|
99
112
|
export type TaskFn<I extends InputType = UnknownInputType, O extends OutputType = void, C = Context<I>> = (input: I, ctx: C) => O | Promise<O>;
|
|
100
113
|
export type DurableTaskFn<I extends InputType = UnknownInputType, O extends OutputType = void> = TaskFn<I, O, DurableContext<I>>;
|
|
101
114
|
/**
|
package/v1/task.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NonRetryableError = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = void 0;
|
|
3
|
+
exports.RetryAfterError = exports.NonRetryableError = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = void 0;
|
|
4
4
|
const workflows_1 = require("../protoc/v1/workflows");
|
|
5
5
|
Object.defineProperty(exports, "ConcurrencyLimitStrategy", { enumerable: true, get: function () { return workflows_1.ConcurrencyLimitStrategy; } });
|
|
6
|
+
const duration_1 = require("./client/duration");
|
|
6
7
|
const trigger_1 = require("../protoc/v1/shared/trigger");
|
|
7
8
|
Object.defineProperty(exports, "WorkerLabelComparator", { enumerable: true, get: function () { return trigger_1.WorkerLabelComparator; } });
|
|
8
9
|
class NonRetryableError extends Error {
|
|
@@ -13,3 +14,15 @@ class NonRetryableError extends Error {
|
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
exports.NonRetryableError = NonRetryableError;
|
|
17
|
+
/**
|
|
18
|
+
* Throw from a task to retry it after a delay of its choosing. The retry counts against the task's `retries`.
|
|
19
|
+
*/
|
|
20
|
+
class RetryAfterError extends Error {
|
|
21
|
+
constructor(message, opts) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'RetryAfterError';
|
|
24
|
+
this.afterMs = Math.max(Math.round((0, duration_1.durationToMs)(opts.after)), 0);
|
|
25
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.RetryAfterError = RetryAfterError;
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.37.0";
|
package/version.js
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { HatchetClient } from '../..';
|
|
2
|
-
export type PublishLatencyStats = {
|
|
3
|
-
count: number;
|
|
4
|
-
avgMs: number;
|
|
5
|
-
p50Ms: number;
|
|
6
|
-
p99Ms: number;
|
|
7
|
-
maxMs: number;
|
|
8
|
-
throughputPerSec: number;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Times `count` sequential publishes, after `warmupCount` unmeasured ones
|
|
12
|
-
* absorb connection setup and topic creation.
|
|
13
|
-
*/
|
|
14
|
-
export declare function measurePublishLatency(hatchet: HatchetClient, topic: string, payload: Uint8Array | string, count: number, warmupCount?: number): Promise<PublishLatencyStats>;
|
|
15
|
-
export declare function formatPublishLatency(stats: PublishLatencyStats): string;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.measurePublishLatency = measurePublishLatency;
|
|
13
|
-
exports.formatPublishLatency = formatPublishLatency;
|
|
14
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
15
|
-
function percentile(sorted, p) {
|
|
16
|
-
return sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * p))];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Times `count` sequential publishes, after `warmupCount` unmeasured ones
|
|
20
|
-
* absorb connection setup and topic creation.
|
|
21
|
-
*/
|
|
22
|
-
function measurePublishLatency(hatchet_1, topic_1, payload_1, count_1) {
|
|
23
|
-
return __awaiter(this, arguments, void 0, function* (hatchet, topic, payload, count, warmupCount = 5) {
|
|
24
|
-
for (let i = 0; i < warmupCount; i += 1) {
|
|
25
|
-
yield hatchet.streams.publish(topic, payload);
|
|
26
|
-
}
|
|
27
|
-
const durationsMs = [];
|
|
28
|
-
const start = perf_hooks_1.performance.now();
|
|
29
|
-
for (let i = 0; i < count; i += 1) {
|
|
30
|
-
const before = perf_hooks_1.performance.now();
|
|
31
|
-
yield hatchet.streams.publish(topic, payload);
|
|
32
|
-
durationsMs.push(perf_hooks_1.performance.now() - before);
|
|
33
|
-
}
|
|
34
|
-
const totalMs = perf_hooks_1.performance.now() - start;
|
|
35
|
-
const sorted = [...durationsMs].sort((a, b) => a - b);
|
|
36
|
-
return {
|
|
37
|
-
count,
|
|
38
|
-
avgMs: durationsMs.reduce((sum, d) => sum + d, 0) / count,
|
|
39
|
-
p50Ms: percentile(sorted, 0.5),
|
|
40
|
-
p99Ms: percentile(sorted, 0.99),
|
|
41
|
-
maxMs: sorted[sorted.length - 1],
|
|
42
|
-
throughputPerSec: (count / totalMs) * 1000,
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function formatPublishLatency(stats) {
|
|
47
|
-
const fmt = (ms) => ms.toFixed(2);
|
|
48
|
-
return (`avg=${fmt(stats.avgMs)}ms p50=${fmt(stats.p50Ms)}ms p99=${fmt(stats.p99Ms)}ms ` +
|
|
49
|
-
`max=${fmt(stats.maxMs)}ms throughput=${fmt(stats.throughputPerSec)}/s`);
|
|
50
|
-
}
|