@libp2p/utils 6.0.6-d9c7e0f7e → 6.1.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.
@@ -9,4 +9,8 @@ export declare class RateLimitError extends Error {
9
9
  isFirstInDuration: boolean;
10
10
  constructor(message: string | undefined, props: RateLimiterResult);
11
11
  }
12
+ export declare class QueueFullError extends Error {
13
+ static name: string;
14
+ constructor(message?: string);
15
+ }
12
16
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;gBAEb,OAAO,oBAAwB,EAAE,KAAK,EAAE,iBAAiB;CAQvE"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;gBAEb,OAAO,oBAAwB,EAAE,KAAK,EAAE,iBAAiB;CAQvE;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,MAAM,CAAC,IAAI,SAAmB;gBAEjB,OAAO,GAAE,MAA6B;CAIpD"}
@@ -15,4 +15,11 @@ export class RateLimitError extends Error {
15
15
  this.isFirstInDuration = props.isFirstInDuration;
16
16
  }
17
17
  }
18
+ export class QueueFullError extends Error {
19
+ static name = 'QueueFullError';
20
+ constructor(message = 'The queue was full') {
21
+ super(message);
22
+ this.name = 'QueueFullError';
23
+ }
24
+ }
18
25
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,eAAe,CAAQ;IACvB,YAAY,CAAQ;IACpB,cAAc,CAAQ;IACtB,iBAAiB,CAAS;IAE1B,YAAa,OAAO,GAAG,qBAAqB,EAAE,KAAwB;QACpE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;QAC5B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAA;QAC5C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAA;QACtC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAA;QAC1C,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAA;IAClD,CAAC;CACF"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,eAAe,CAAQ;IACvB,YAAY,CAAQ;IACpB,cAAc,CAAQ;IACtB,iBAAiB,CAAS;IAE1B,YAAa,OAAO,GAAG,qBAAqB,EAAE,KAAwB;QACpE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;QAC5B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAA;QAC5C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAA;QACtC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAA;QAC1C,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAA;IAClD,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,MAAM,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAE9B,YAAa,UAAkB,oBAAoB;QACjD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC"}
@@ -15,6 +15,13 @@ export interface QueueInit<JobReturnType, JobOptions extends AbortOptions = Abor
15
15
  * @default Infinity
16
16
  */
17
17
  concurrency?: number;
18
+ /**
19
+ * If the queue size grows to larger than this number the promise returned
20
+ * from the add function will reject
21
+ *
22
+ * @default Infinity
23
+ */
24
+ maxSize?: number;
18
25
  /**
19
26
  * The name of the metric for the queue length
20
27
  */
@@ -29,8 +36,8 @@ export interface QueueInit<JobReturnType, JobOptions extends AbortOptions = Abor
29
36
  sort?: Comparator<Job<JobOptions, JobReturnType>>;
30
37
  }
31
38
  export type JobStatus = 'queued' | 'running' | 'errored' | 'complete';
32
- export interface RunFunction<Options = AbortOptions, ReturnType = void> {
33
- (opts?: Options): Promise<ReturnType>;
39
+ export interface RunFunction<Options extends AbortOptions = AbortOptions, ReturnType = void> {
40
+ (options: Options): Promise<ReturnType>;
34
41
  }
35
42
  export interface JobMatcher<JobOptions extends AbortOptions = AbortOptions> {
36
43
  (options?: Partial<JobOptions>): boolean;
@@ -91,6 +98,7 @@ export interface QueueEvents<JobReturnType, JobOptions extends AbortOptions = Ab
91
98
  */
92
99
  export declare class Queue<JobReturnType = unknown, JobOptions extends AbortOptions = AbortOptions> extends TypedEventEmitter<QueueEvents<JobReturnType, JobOptions>> {
93
100
  concurrency: number;
101
+ maxSize: number;
94
102
  queue: Array<Job<JobOptions, JobReturnType>>;
95
103
  private pending;
96
104
  private readonly sort?;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAA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Qd;;;;OAIG;IACG,OAAO,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IASrD;;;;;;;;;;OAUG;IACG,cAAc,CAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3E;;;;;;;OAOG;IACG,MAAM,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IASpD;;OAEG;IACH,IAAI,IAAI,IAAK,MAAM,CAElB;IAED;;OAEG;IACH,IAAI,MAAM,IAAK,MAAM,CAEpB;IAED;;OAEG;IACH,IAAI,OAAO,IAAK,MAAM,CAErB;IAED;;;;;;;;;OASG;IACK,WAAW,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC;CAuD3F"}
@@ -1,6 +1,7 @@
1
1
  import { AbortError, TypedEventEmitter } from '@libp2p/interface';
2
2
  import { pushable } from 'it-pushable';
3
3
  import { raceEvent } from 'race-event';
4
+ import { QueueFullError } from '../errors.js';
4
5
  import { Job } from './job.js';
5
6
  /**
6
7
  * Heavily influence by `p-queue` with the following differences:
@@ -10,12 +11,14 @@ import { Job } from './job.js';
10
11
  */
11
12
  export class Queue extends TypedEventEmitter {
12
13
  concurrency;
14
+ maxSize;
13
15
  queue;
14
16
  pending;
15
17
  sort;
16
18
  constructor(init = {}) {
17
19
  super();
18
20
  this.concurrency = init.concurrency ?? Number.POSITIVE_INFINITY;
21
+ this.maxSize = init.maxSize ?? Number.POSITIVE_INFINITY;
19
22
  this.pending = 0;
20
23
  if (init.metricName != null) {
21
24
  init.metrics?.registerMetricGroup(init.metricName, {
@@ -88,6 +91,9 @@ export class Queue extends TypedEventEmitter {
88
91
  */
89
92
  async add(fn, options) {
90
93
  options?.signal?.throwIfAborted();
94
+ if (this.size === this.maxSize) {
95
+ throw new QueueFullError();
96
+ }
91
97
  const job = new Job(fn, options);
92
98
  this.enqueue(job);
93
99
  this.safeDispatchEvent('add');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/queue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAyG9B;;;;;GAKG;AACH,MAAM,OAAO,KAA+E,SAAQ,iBAAyD;IACpJ,WAAW,CAAQ;IACnB,KAAK,CAAuC;IAC3C,OAAO,CAAQ;IACN,IAAI,CAA6C;IAElE,YAAa,OAA6C,EAAE;QAC1D,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,iBAAiB,CAAA;QAC/D,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;QAEhB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,IAAI,CAAC,UAAU,EAAE;gBACjD,SAAS,EAAE,GAAG,EAAE;oBACd,OAAO;wBACL,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;wBACvB,OAAO,EAAE,IAAI,CAAC,OAAO;wBACrB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO;qBACzC,CAAA;gBACH,CAAC;aACF,CAAC,CAAA;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACjB,CAAC;IAEO,iBAAiB;QACvB,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACpB,mEAAmE;YACnE,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AE,aAAa,CAAC,CAAA;YAE5D,mEAAmE;YACnE,OAAO,EAAE,CAAA;QACX,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,113 @@
1
+ {
2
+ "createTimeoutOptions": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.abort_options.createTimeoutOptions.html",
3
+ "./abort-options:createTimeoutOptions": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.abort_options.createTimeoutOptions.html",
4
+ "AbstractStream": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.abstract_stream.AbstractStream.html",
5
+ "./abstract-stream:AbstractStream": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.abstract_stream.AbstractStream.html",
6
+ "AbstractStreamInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.abstract_stream.AbstractStreamInit.html",
7
+ "./abstract-stream:AbstractStreamInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.abstract_stream.AbstractStreamInit.html",
8
+ "AdaptiveTimeout": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.adaptive_timeout.AdaptiveTimeout.html",
9
+ "./adaptive-timeout:AdaptiveTimeout": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.adaptive_timeout.AdaptiveTimeout.html",
10
+ "AdaptiveTimeoutInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive_timeout.AdaptiveTimeoutInit.html",
11
+ "./adaptive-timeout:AdaptiveTimeoutInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive_timeout.AdaptiveTimeoutInit.html",
12
+ "AdaptiveTimeoutSignal": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive_timeout.AdaptiveTimeoutSignal.html",
13
+ "./adaptive-timeout:AdaptiveTimeoutSignal": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive_timeout.AdaptiveTimeoutSignal.html",
14
+ "GetTimeoutSignalOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive_timeout.GetTimeoutSignalOptions.html",
15
+ "./adaptive-timeout:GetTimeoutSignalOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive_timeout.GetTimeoutSignalOptions.html",
16
+ "DEFAULT_FAILURE_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive_timeout.DEFAULT_FAILURE_MULTIPLIER.html",
17
+ "./adaptive-timeout:DEFAULT_FAILURE_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive_timeout.DEFAULT_FAILURE_MULTIPLIER.html",
18
+ "DEFAULT_MIN_TIMEOUT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive_timeout.DEFAULT_MIN_TIMEOUT.html",
19
+ "./adaptive-timeout:DEFAULT_MIN_TIMEOUT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive_timeout.DEFAULT_MIN_TIMEOUT.html",
20
+ "DEFAULT_TIMEOUT_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive_timeout.DEFAULT_TIMEOUT_MULTIPLIER.html",
21
+ "./adaptive-timeout:DEFAULT_TIMEOUT_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive_timeout.DEFAULT_TIMEOUT_MULTIPLIER.html",
22
+ "arrayEquals": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.array_equals.arrayEquals.html",
23
+ "./array-equals:arrayEquals": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.array_equals.arrayEquals.html",
24
+ "SafelyCloseConnectionOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.close.SafelyCloseConnectionOptions.html",
25
+ "./close:SafelyCloseConnectionOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.close.SafelyCloseConnectionOptions.html",
26
+ "safelyCloseConnectionIfUnused": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseConnectionIfUnused.html",
27
+ "./close:safelyCloseConnectionIfUnused": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseConnectionIfUnused.html",
28
+ "safelyCloseStream": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseStream.html",
29
+ "./close:safelyCloseStream": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseStream.html",
30
+ "closeSource": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close_source.closeSource.html",
31
+ "./close-source:closeSource": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close_source.closeSource.html",
32
+ "BloomFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.BloomFilter.html",
33
+ "Bucket": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.Bucket.html",
34
+ "CuckooFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.CuckooFilter.html",
35
+ "Fingerprint": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.Fingerprint.html",
36
+ "ScalableCuckooFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.ScalableCuckooFilter.html",
37
+ "BloomFilterOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.BloomFilterOptions.html",
38
+ "CuckooFilterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.CuckooFilterInit.html",
39
+ "Filter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.Filter.html",
40
+ "./filters:Filter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.Filter.html",
41
+ "Hash": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.Hash.html",
42
+ "ScalableCuckooFilterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.ScalableCuckooFilterInit.html",
43
+ "createBloomFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.filters.createBloomFilter.html",
44
+ "createCuckooFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.filters.createCuckooFilter.html",
45
+ "createScalableCuckooFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.filters.createScalableCuckooFilter.html",
46
+ "ipPortToMultiaddr": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.ip_port_to_multiaddr.ipPortToMultiaddr.html",
47
+ "./ip-port-to-multiaddr:ipPortToMultiaddr": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.ip_port_to_multiaddr.ipPortToMultiaddr.html",
48
+ "isPromise": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is_promise.isPromise.html",
49
+ "./is-promise:isPromise": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is_promise.isPromise.html",
50
+ "MovingAverage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.moving_average.MovingAverage.html",
51
+ "./moving-average:MovingAverage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.moving_average.MovingAverage.html",
52
+ "isLoopback": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is_loopback.isLoopback.html",
53
+ "./multiaddr/is-loopback:isLoopback": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is_loopback.isLoopback.html",
54
+ "isPrivate": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is_private.isPrivate.html",
55
+ "./multiaddr/is-private:isPrivate": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is_private.isPrivate.html",
56
+ "PeerQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.peer_queue.PeerQueue.html",
57
+ "./peer-queue:PeerQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.peer_queue.PeerQueue.html",
58
+ "PeerQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.peer_queue.PeerQueueJobOptions.html",
59
+ "./peer-queue:PeerQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.peer_queue.PeerQueueJobOptions.html",
60
+ "PriorityQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.priority_queue.PriorityQueue.html",
61
+ "./priority-queue:PriorityQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.priority_queue.PriorityQueue.html",
62
+ "PriorityQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.priority_queue.PriorityQueueJobOptions.html",
63
+ "./priority-queue:PriorityQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.priority_queue.PriorityQueueJobOptions.html",
64
+ "isPrivateIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.private_ip.isPrivateIp.html",
65
+ "./private-ip:isPrivateIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.private_ip.isPrivateIp.html",
66
+ "Job": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.Job.html",
67
+ "JobRecipient": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.JobRecipient.html",
68
+ "Queue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.Queue.html",
69
+ "./queue:Queue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.Queue.html",
70
+ "Comparator": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.Comparator.html",
71
+ "./queue:Comparator": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.Comparator.html",
72
+ "JobMatcher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.JobMatcher.html",
73
+ "./queue:JobMatcher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.JobMatcher.html",
74
+ "JobTimeline": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.JobTimeline.html",
75
+ "QueueEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueEvents.html",
76
+ "./queue:QueueEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueEvents.html",
77
+ "QueueInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueInit.html",
78
+ "./queue:QueueInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueInit.html",
79
+ "QueueJobFailure": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobFailure.html",
80
+ "./queue:QueueJobFailure": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobFailure.html",
81
+ "QueueJobSuccess": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobSuccess.html",
82
+ "./queue:QueueJobSuccess": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobSuccess.html",
83
+ "RunFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.RunFunction.html",
84
+ "./queue:RunFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.RunFunction.html",
85
+ "JobStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_utils.queue.JobStatus.html",
86
+ "./queue:JobStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_utils.queue.JobStatus.html",
87
+ "MemoryStorage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate_limiter.MemoryStorage.html",
88
+ "./rate-limiter:MemoryStorage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate_limiter.MemoryStorage.html",
89
+ "RateLimiter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate_limiter.RateLimiter.html",
90
+ "./rate-limiter:RateLimiter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate_limiter.RateLimiter.html",
91
+ "GetKeySecDurationOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.GetKeySecDurationOptions.html",
92
+ "./rate-limiter:GetKeySecDurationOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.GetKeySecDurationOptions.html",
93
+ "RateLimiterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.RateLimiterInit.html",
94
+ "./rate-limiter:RateLimiterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.RateLimiterInit.html",
95
+ "RateLimiterResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.RateLimiterResult.html",
96
+ "./rate-limiter:RateLimiterResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.RateLimiterResult.html",
97
+ "RateRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.RateRecord.html",
98
+ "./rate-limiter:RateRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate_limiter.RateRecord.html",
99
+ "StreamProperties": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.stream_to_ma_conn.StreamProperties.html",
100
+ "./stream-to-ma-conn:StreamProperties": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.stream_to_ma_conn.StreamProperties.html",
101
+ "streamToMaConnection": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.stream_to_ma_conn.streamToMaConnection.html",
102
+ "./stream-to-ma-conn:streamToMaConnection": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.stream_to_ma_conn.streamToMaConnection.html",
103
+ "CreateTrackedListInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked_list.CreateTrackedListInit.html",
104
+ "./tracked-list:CreateTrackedListInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked_list.CreateTrackedListInit.html",
105
+ "trackedList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked_list.trackedList.html",
106
+ "./tracked-list:trackedList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked_list.trackedList.html",
107
+ "CreateTrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked_map.CreateTrackedMapInit.html",
108
+ "./tracked-map:CreateTrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked_map.CreateTrackedMapInit.html",
109
+ "TrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked_map.TrackedMapInit.html",
110
+ "./tracked-map:TrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked_map.TrackedMapInit.html",
111
+ "trackedMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked_map.trackedMap.html",
112
+ "./tracked-map:trackedMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked_map.trackedMap.html"
113
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/utils",
3
- "version": "6.0.6-d9c7e0f7e",
3
+ "version": "6.1.0",
4
4
  "description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/utils#readme",
@@ -148,9 +148,9 @@
148
148
  },
149
149
  "dependencies": {
150
150
  "@chainsafe/is-ip": "^2.0.2",
151
- "@libp2p/crypto": "5.0.4-d9c7e0f7e",
152
- "@libp2p/interface": "2.1.2-d9c7e0f7e",
153
- "@libp2p/logger": "5.1.0-d9c7e0f7e",
151
+ "@libp2p/crypto": "^5.0.4",
152
+ "@libp2p/interface": "^2.1.2",
153
+ "@libp2p/logger": "^5.1.0",
154
154
  "@multiformats/multiaddr": "^12.2.3",
155
155
  "@sindresorhus/fnv1a": "^3.1.0",
156
156
  "@types/murmurhash3js-revisited": "^3.0.3",
@@ -171,6 +171,7 @@
171
171
  "uint8arrays": "^5.1.0"
172
172
  },
173
173
  "devDependencies": {
174
+ "@libp2p/peer-id": "^5.0.4",
174
175
  "@types/netmask": "^2.0.5",
175
176
  "aegir": "^44.0.1",
176
177
  "benchmark": "^2.1.4",
package/src/errors.ts CHANGED
@@ -18,3 +18,12 @@ export class RateLimitError extends Error {
18
18
  this.isFirstInDuration = props.isFirstInDuration
19
19
  }
20
20
  }
21
+
22
+ export class QueueFullError extends Error {
23
+ static name = 'QueueFullError'
24
+
25
+ constructor (message: string = 'The queue was full') {
26
+ super(message)
27
+ this.name = 'QueueFullError'
28
+ }
29
+ }
@@ -1,6 +1,7 @@
1
1
  import { AbortError, TypedEventEmitter } from '@libp2p/interface'
2
2
  import { pushable } from 'it-pushable'
3
3
  import { raceEvent } from 'race-event'
4
+ import { QueueFullError } from '../errors.js'
4
5
  import { Job } from './job.js'
5
6
  import type { AbortOptions, Metrics } from '@libp2p/interface'
6
7
 
@@ -21,6 +22,14 @@ export interface QueueInit<JobReturnType, JobOptions extends AbortOptions = Abor
21
22
  */
22
23
  concurrency?: number
23
24
 
25
+ /**
26
+ * If the queue size grows to larger than this number the promise returned
27
+ * from the add function will reject
28
+ *
29
+ * @default Infinity
30
+ */
31
+ maxSize?: number
32
+
24
33
  /**
25
34
  * The name of the metric for the queue length
26
35
  */
@@ -39,8 +48,8 @@ export interface QueueInit<JobReturnType, JobOptions extends AbortOptions = Abor
39
48
 
40
49
  export type JobStatus = 'queued' | 'running' | 'errored' | 'complete'
41
50
 
42
- export interface RunFunction<Options = AbortOptions, ReturnType = void> {
43
- (opts?: Options): Promise<ReturnType>
51
+ export interface RunFunction<Options extends AbortOptions = AbortOptions, ReturnType = void> {
52
+ (options: Options): Promise<ReturnType>
44
53
  }
45
54
 
46
55
  export interface JobMatcher<JobOptions extends AbortOptions = AbortOptions> {
@@ -114,6 +123,7 @@ export interface QueueEvents<JobReturnType, JobOptions extends AbortOptions = Ab
114
123
  */
115
124
  export class Queue<JobReturnType = unknown, JobOptions extends AbortOptions = AbortOptions> extends TypedEventEmitter<QueueEvents<JobReturnType, JobOptions>> {
116
125
  public concurrency: number
126
+ public maxSize: number
117
127
  public queue: Array<Job<JobOptions, JobReturnType>>
118
128
  private pending: number
119
129
  private readonly sort?: Comparator<Job<JobOptions, JobReturnType>>
@@ -122,6 +132,7 @@ export class Queue<JobReturnType = unknown, JobOptions extends AbortOptions = Ab
122
132
  super()
123
133
 
124
134
  this.concurrency = init.concurrency ?? Number.POSITIVE_INFINITY
135
+ this.maxSize = init.maxSize ?? Number.POSITIVE_INFINITY
125
136
  this.pending = 0
126
137
 
127
138
  if (init.metricName != null) {
@@ -212,6 +223,10 @@ export class Queue<JobReturnType = unknown, JobOptions extends AbortOptions = Ab
212
223
  async add (fn: RunFunction<JobOptions, JobReturnType>, options?: JobOptions): Promise<JobReturnType> {
213
224
  options?.signal?.throwIfAborted()
214
225
 
226
+ if (this.size === this.maxSize) {
227
+ throw new QueueFullError()
228
+ }
229
+
215
230
  const job = new Job<JobOptions, JobReturnType>(fn, options)
216
231
  this.enqueue(job)
217
232
  this.safeDispatchEvent('add')