1.4.4 • Published 1 year ago

pubsub-subscriber v1.4.4

Weekly downloads
139
License
MIT
Repository
github
Last release
1 year ago

pubsub-subscriber

An opinionated GCP Pub/Sub subscriber we use here at Namshi.

Usage

let {subscribe} = require('pubsub-subscriber')

// name of the topic you want to listen to
let topic = "my_topic" 

// name of your subscription, will be created automagically
let subscription = "my_topic_send_email"

// function that processes the message:
// payload will be the JSON parsed.
// 
// Return to ack, throw an exception to nack.
async function onMessage(payload, options) {
    if (payload.ok) {
        return
    }
    
    // options.message - the original message object from the pubsub SDK
    // options.topic_name - the topic you've subscribed to

    throw new Error("I f'ed up")
}

subscribe(topic, subscription, onMessage)

That's it!

1.4.4

1 year ago

1.4.3

4 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago