-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added queues info command and tests * chore: removed table, add account_id in curl, and cleanup comments * chore: add condition for r2_bucket as producer * chore: added conditional and test for r2bucket producers * chore: add condition for r2_bucket consumer to print bucket_name * refactor: add conditions to not print producers and consumers if there aren't any * refactor: run prettier to match code style; modify curl styling * chore: add changeset for new command * fix: fix issue of accountId being undefined in curl string * refactor: prettified * refactor: update snapshot due to --experimental-json-config removal
- Loading branch information
1 parent
37b3ccc
commit 7da76de
Showing
5 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"wrangler": minor | ||
--- | ||
|
||
feat: implement queues info command | ||
|
||
This command allows users to get information on individual queues. | ||
|
||
To run this command use the queues info command with the name of a queue in the user's account. | ||
|
||
`wrangler queues info my-queue-name` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { readConfig } from "../../../config"; | ||
import { logger } from "../../../logger"; | ||
import { printWranglerBanner } from "../../../update-check"; | ||
import { requireAuth } from "../../../user"; | ||
import { getQueue } from "../../client"; | ||
import type { | ||
CommonYargsArgv, | ||
StrictYargsOptionsToInterface, | ||
} from "../../../yargs-types"; | ||
import type { Consumer, Producer, QueueResponse } from "../../client"; | ||
|
||
export function options(yargs: CommonYargsArgv) { | ||
return yargs.positional("name", { | ||
type: "string", | ||
demandOption: true, | ||
description: "The name of the queue", | ||
}); | ||
} | ||
|
||
export async function handler( | ||
args: StrictYargsOptionsToInterface<typeof options> | ||
) { | ||
const config = readConfig(args.config, args); | ||
const queue: QueueResponse = await getQueue(config, args.name); | ||
const accountId = await requireAuth(config); | ||
|
||
await printWranglerBanner(); | ||
logger.log(`Queue Name: ${queue.queue_name}`); | ||
logger.log(`Queue ID: ${queue.queue_id}`); | ||
logger.log(`Created On: ${queue.created_on}`); | ||
logger.log(`Last Modified: ${queue.modified_on}`); | ||
logger.log(`Number of Producers: ${queue.producers_total_count}`); | ||
queue.producers_total_count > 0 && | ||
logger.log( | ||
`Producers:${queue.producers.map((p: Producer) => (p.type === "r2_bucket" ? ` ${p.type}:${p.bucket_name}` : ` ${p.type}:${p.script}`)).toString()}` | ||
); | ||
logger.log(`Number of Consumers: ${queue.consumers_total_count}`); | ||
queue.consumers_total_count > 0 && | ||
logger.log( | ||
`Consumers: ${queue.consumers | ||
.map((c: Consumer) => { | ||
if (c.type === "r2_bucket") { | ||
return `${c.type}:${c.bucket_name}`; | ||
} | ||
if (c.type === "http_pull") { | ||
return `HTTP Pull Consumer. | ||
Pull messages using: | ||
curl "https://api.cloudflare.com/client/v4/accounts/${accountId || "<add your account id here>"}/queues/${queue.queue_id || "<add your queue id here>"}/messages/pull" \\ | ||
--header "Authorization: Bearer <add your api key here>" \\ | ||
--header "Content-Type: application/json" \\ | ||
--data '{ "visibility_timeout": 10000, "batch_size": 2 }'`; | ||
} | ||
return `${c.type}:${c.script}`; | ||
}) | ||
.toString()}` | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters