-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathqueues.d.ts
More file actions
52 lines (49 loc) · 1.43 KB
/
Copy pathqueues.d.ts
File metadata and controls
52 lines (49 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// These types will be added to "@cloudflare/workers-types" soon.
export {};
declare global {
/**
* A binding that allows a producer to send messages to a Queue.
*/
interface Queue<Body = any> {
/**
* Sends a message to the Queue.
* @param message The message can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types), as long as its size is less than 128 KB.
* @returns A promise that resolves when the message is confirmed to be written to disk.
*/
send(message: Body): Promise<void>;
}
/**
* A message that is sent to a consumer Worker.
*/
interface Message<Body = any> {
/**
* A unique, system-generated ID for the message.
*/
readonly id: string;
/**
* A timestamp when the message was sent.
*/
readonly timestamp: Date;
/**
* The body of the message.
*/
readonly body: Body;
}
/**
* A batch of messages that are sent to a consumer Worker.
*/
interface MessageBatch<Body = any> {
/**
* The name of the Queue that belongs to this batch.
*/
readonly queue: string;
/**
* An array of messages in the batch. Ordering of messages is not guaranteed.
*/
readonly messages: readonly Message<Body>[];
/**
* Marks every message to be retried in the next batch.
*/
retryAll(): void;
}
}