Skip to content

Queue manager for Typescript, as well as Nestjs.

License

Notifications You must be signed in to change notification settings

lucasguiss/roit-queues

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROIT Queues

Usage for Pub/Sub

In the env.yaml file add the pubSubCredential{} and projectId attributes, with the number of folders inside the {}:

dev:
    pubSubCredential{5}: my-credential.json
    projectId: my-project-id

Inject in your desired class:

import { PubSubHandler } from '@roit/roit-queues'

constructor( 
    private readonly pubSubHandler: PubSubHandler
) {}

Use the publish method:

const myObject = {
    // properties
}

const messageId = await this.pubSubHandler.publish(myObject, 'myTopic')
console.log(messageId) // outputs 234786275

Usage for Cloud Tasks

In the env.yaml file add the cloudTaskCredencial{} and projectId attributes, with the number of folders inside the {}:

dev:
    cloudTaskCredencial{5}: my-credential.json
    projectId: my-project-id

Inject in your desired class:

import { CloudTaskProvider } from '@roit/roit-queues'

constructor( 
    private readonly cloudTaskProvider: CloudTaskProvider
) {}

Use the createTask method:

import { TaskConfiguration } from '@roit/roit-queues'

const myTask: TaskConfiguration = {
    url: 'https://endpoint.com',
    httpMethod: 'POST',
    region: 'us-central1',
    queue: 'my-queue',
    scheduleTime: '1000',
    headers: MyHeadersObject,
    body: MyPayloadObject
}

const taskResponse = await this.cloudTaskProvider.createTask(myTask)
console.log(taskResponse)

About

Queue manager for Typescript, as well as Nestjs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%