MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / enqueue

Method enqueue

packages/cloud/src/retry-queue/RetryQueue.ts:73–101  ·  view source on GitHub ↗
(
		url: string,
		options: RequestInit,
		type: QueuedRequest["type"] = "other",
		operation?: string,
	)

Source from the content-addressed store, hash-verified

71 }
72
73 public async enqueue(
74 url: string,
75 options: RequestInit,
76 type: QueuedRequest["type"] = "other",
77 operation?: string,
78 ): Promise<void> {
79 if (this.queue.size >= this.config.maxQueueSize) {
80 const oldestId = Array.from(this.queue.keys())[0]
81 if (oldestId) {
82 this.queue.delete(oldestId)
83 }
84 }
85
86 const request: QueuedRequest = {
87 id: `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
88 url,
89 options,
90 timestamp: Date.now(),
91 retryCount: 0,
92 type,
93 operation,
94 }
95
96 this.queue.set(request.id, request)
97 await this.persistQueue()
98
99 this.emit("request-queued", request)
100 this.log(`[RetryQueue] Queued request: ${url}`)
101 }
102
103 public async retryAll(): Promise<void> {
104 if (this.isProcessing) {

Callers 6

fetchMethod · 0.80
RetryQueue.test.tsFile · 0.80
pullFunction · 0.80
pullFunction · 0.80
startFunction · 0.80
startFunction · 0.80

Calls 8

persistQueueMethod · 0.95
fromMethod · 0.80
keysMethod · 0.65
deleteMethod · 0.65
toStringMethod · 0.65
setMethod · 0.65
emitMethod · 0.65
logMethod · 0.65

Tested by 4

pullFunction · 0.64
pullFunction · 0.64
startFunction · 0.64
startFunction · 0.64