1.0.7 • Published 7 months ago

amqp-workflow v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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);
1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.3

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago