weyoss / redis-smq

A simple high-performance Redis message queue for Node.js.
MIT License
588 stars 64 forks source link

Question about QueueManager.createInstance() initialisation #112

Closed PhilHannent closed 5 months ago

PhilHannent commented 5 months ago

Hi,

I'm trying to refactor our usage of redis-smq so that we can set all configuration settings (the redis details) via Azure KeyVault. Getting these settings from KeyVault is an async process. However, the example of calling the QueueManager.createInstance() is basically in the module header at the top level.

If a object is instantiated during the module creation in this way, there isn't enough time for the KeyVault code to place the correct variables onto the process.env.

I wanted to check if the QueueManager.createInstance() can be called within an async function (instead of in the top level of a file)?

The documentation for the QueueManager appears to be missing (that is linked from the initial help): https://github.com/weyoss/redis-smq/blob/HEAD/docs/api/queue-manager.md

Thanks Phil

weyoss commented 5 months ago

@PhilHannent hey!

The master branch of the project is currently pointing to the v8 pe-release.

The documentation for the v7.2.3 release is located at https://github.com/weyoss/redis-smq/tree/v7.2.3 . Here is the QueueManager page https://github.com/weyoss/redis-smq/blob/v7.2.3/docs/api/message-manager.md

I wanted to check if the QueueManager.createInstance() can be called within an async function (instead of in the top level of a file)?

Sure, you can create an instance of the QueueManager asynchronously (within an async function).

V8 Configuration

Starting with the release v8 the message queue configuration is now managed globally from a single place using Configuration.getSetConfig() and during the application bootstrap time. The configuration should be provided before working with the message queue.