1.0.4 • Published 7 months ago

@roit/roit-queues v1.0.4

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

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

Note: if you use glcloud auth application-default login, you don't need to set pubSubCredential at env file!

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:
    cloudTaskCredential{5}: my-credential.json
    projectId: my-project-id

Inject in your desired class:

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

constructor( 
    private readonly cloudTaskProvider: CloudTaskProvider
) {}

Schedule Time params:

scheduleTime: {
    seconds?: number
    nanos?: number
    dateExecute?: string // Use moment formats: https://www.npmjs.com/package/moment
    executeAt?: string // Use ms formats: https://www.npmjs.com/package/ms
}

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: {
        seconds: 3600   
    },
    headers: MyHeadersObject,
    body: MyPayloadObject
}

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

7 months ago

1.0.3

7 months ago

0.0.40

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.36

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.27

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.20

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.17

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.2

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago

0.0.3

3 years ago