@efebia/sqs-queue-v3

中文文档
0.0.10发布于 2026/11/12MITCommonJS构建来源已验证近 30 天下载 3044

AWS SQS queue consumer built on @efebia/queue, using the modern modular AWS SDK v3 (@aws-sdk/client-sqs).

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. API
  4. new Queue<TMessage>(options)
  5. Inherited from @efebia/queue
  6. License

@efebia/sqs-queue-v3

AWS SQS queue consumer built on @efebia/queue, using the modern modular AWS SDK v3 (@aws-sdk/client-sqs).

Install

npm install @efebia/sqs-queue-v3

Usage

import { SQSClient } from '@aws-sdk/client-sqs';
import { Queue } from '@efebia/sqs-queue-v3';

type MyMessage = { userId: string; action: string };

const client = new SQSClient({ region: 'eu-west-1' });

const queue = new Queue<MyMessage>({
  client,
  receiveOptions: {
    QueueUrl: 'https://sqs.eu-west-1.amazonaws.com/123456789/my-queue',
    WaitTimeSeconds: 20,
    MaxNumberOfMessages: 1,
  },
  sleepTimeout: 5000,
  logger: (obj, msg) => console.log(msg, obj),
});

// Start consuming
queue.start(async (name, params, state) => {
  console.log(`Received "${name}":`, params);
  // set state.del = false to leave the message in the queue
});

// Send a message
await queue.send({ name: 'doWork', params: { userId: '42', action: 'sync' } });

// Stop the loop
queue.stop();

API

new Queue<TMessage>(options)

OptionTypeDefaultDescription
clientSQSClient—Required. Configured @aws-sdk/client-sqs client instance
receiveOptionsReceiveMessageCommandInput—Required. Passed to ReceiveMessageCommand. Must include QueueUrl.
receiveOptions.WaitTimeSecondsnumber20Long-polling wait time
receiveOptions.MaxNumberOfMessagesnumber1Max messages per receive call
canRead() => boolean | Promise<boolean>() => trueCalled before each receive; returning false skips the iteration
logger(obj, msg?) => voidno-opLogging function for errors and warnings
sleepTimeoutnumber5000Ms to wait after an error before retrying
errorCallback(error) => voidconsole.errorCalled on uncaught errors in the loop

Inherited from @efebia/queue

  • start(callback, canThrow?) — starts the polling loop
  • stop() — signals the loop to stop
  • resume(callback) — restarts a stopped queue
  • isRunning() — returns true if the loop is active
  • send(message) — sends a message (adds createdAt automatically)

Callback signature:

(name: string, params: TMessage, state: { del: boolean }) => void | Promise<void>

After the callback resolves, the message is deleted from SQS unless state.del is set to false.

License

MIT

版本与发布记录

@efebia/sqs-queue-v3 共发布 10 个版本,首次发布于 2023/01/13;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.10latest2026/11/121 天前
0.0.92026/03/197 个月前
0.0.82025/07/211.3 年前
0.0.72025/04/131.6 年前
0.0.62024/05/032 年前
0.0.52023/09/043 年前

关于 @efebia/sqs-queue-v3 的常见问题

@efebia/sqs-queue-v3 是什么?

AWS SQS queue consumer built on @efebia/queue, using the modern modular AWS SDK v3 (@aws-sdk/client-sqs).

如何安装 @efebia/sqs-queue-v3?

在项目目录运行 npm install @efebia/sqs-queue-v3,或使用 pnpm add / yarn add / bun add。

@efebia/sqs-queue-v3 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/efebia__sqs-queue-v3 是否存在。

@efebia/sqs-queue-v3 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@efebia/sqs-queue-v3 可以商用吗?

@efebia/sqs-queue-v3 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@efebia/sqs-queue-v3 的下载量有多少?

根据 npm 官方下载统计,@efebia/sqs-queue-v3 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,044 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@efebia/sqs-queue-v3 还在维护吗?

最新版本 0.0.10 发布于 2026/11/12(1 天前);至今共发布 10 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/01/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。