amqp-workflow

1.0.7 • Public • Published

insipred from amqp-delegate

const { makeWorker, makeDelegator } = require("amqp-workflow");
const fetch = require("node-fetch");

const namespace = "amqp"; // default namespace
const url = "amqp://username:password@localhost:5672";

makeWorker({
  name: "gd.docs",
  task: ({ appNo }) => ({ s3_path: `${appNo}.xxx.pdf` }),
  url,
})
  .start()
  .then(() => {
    const mgmt_list_queues = "http://localhost:15672/api/queues";
    const toBase64 = (text) => Buffer.from(text).toString("base64");
    fetch(mgmt_list_queues, {
      headers: { Authorization: `Basic ${toBase64("username:password")}` },
    })
      .then((r) => r.json())
      .then((r) =>
        console.log(
          `available under ${namespace}`,
          r.reduce((m, { name }) => {
            if (name.startsWith(`${namespace}.`)) m.push(name);
            return m;
          }, [])
        )
      );
  });

const workflow = makeDelegator({ url });
workflow
  .start()
  .then(() => workflow.invoke("gd.docs", { appNo: "US12345678" }))
  .then(console.log);

Readme

Keywords

Package Sidebar

Install

npm i amqp-workflow

Weekly Downloads

2

Version

1.0.7

License

MIT

Unpacked Size

6.35 kB

Total Files

9

Last publish

Collaborators

  • linto.cet