-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert-fake-data.ts
59 lines (53 loc) · 1.39 KB
/
insert-fake-data.ts
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
53
54
55
56
57
58
59
import {
GetQueueUrlCommand,
SQSClient,
SendMessageBatchCommand,
} from "@aws-sdk/client-sqs";
import { faker } from "@faker-js/faker";
import { v4 as uuidv4 } from "uuid";
const client = new SQSClient({});
const region = "us-west-2";
type MessageTypes = "SHOULD_MODIFY" | "SHOULD_SKIP" | "SHOULD_DELETE";
interface FakeMessage {
messageType: MessageTypes;
email: string;
description: string;
}
function createFakeMessage(): FakeMessage {
return {
messageType: faker.helpers.arrayElement<MessageTypes>([
"SHOULD_MODIFY",
"SHOULD_SKIP",
"SHOULD_DELETE",
]),
email: faker.internet.email(),
description: faker.lorem.sentence(),
};
}
async function script() {
for (const queueNumber of [1, 2, 3]) {
const queueName = `advanced-redrive-demo-${queueNumber}-dlq`;
const queueUrl = (
await client.send(
new GetQueueUrlCommand({
QueueName: queueName,
}),
)
).QueueUrl;
for (const _ of Array.from(Array(10).keys())) {
await client.send(
new SendMessageBatchCommand({
QueueUrl: queueUrl,
Entries: Array.from(Array(10).keys()).map((_) => {
return {
Id: uuidv4(),
MessageBody: JSON.stringify(createFakeMessage()),
};
}),
}),
);
console.log(`Inserted 10 fake records into ${queueName}.`);
}
}
}
script();