1.1.7 • Published 11 months ago

@cobee/queue v1.1.7

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

@cobee/queue

Just a queue abstraction library with a minimalist approach.

Installation

From Git

  npm install git@gitlab.com:cobee/payments/queue-client.git

From private registry

🚧 Not yet

Documentation

SQS

import { SQSClient } from '@aws-sdk/client-sqs';
import { SQS, QueueConfig } from '@cobee/queue';

interface MyPayload {
    id: string;
    timestamp: number;
}

const getId = () => Math.random().toString(15).substr(2);

async function main() {
    const sqsClient = new SQSClient({
        endpoint: AWS_ENDPOINT,
        region: AWS_REGION,
        credentials: {
        accessKeyId: String(AWS_ACCESS_KEY_ID),
        secretAccessKey: String(AWS_SECRET_ACCESS_KEY),
        },
    });

    const config: Partial<QueueConfig> = {
        partitionKey: (job) => String(job.id),
        queueGroup: () => '*',
    };

    const sqs = new SQS<MyPayload>(QUEUE_URI, sqsClient, config);

    setInterval(() => sqs.enqueue({ id: getId(), timestamp: Date.now() }), 1e3);

    for await (const msg of sqs.consumer().start()) {
        console.log(msg);
    }
}

main();

Examples

There're some examples here to check how library works.

TODO

  • Able to send error messages
  • Abstraction layer for job handling
  • Testing
1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago