Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement redis queue #15

Merged
merged 14 commits into from
Sep 13, 2024
Merged

feat: implement redis queue #15

merged 14 commits into from
Sep 13, 2024

Conversation

lotharking
Copy link
Contributor

No description provided.

@lotharking lotharking marked this pull request as ready for review September 12, 2024 21:03
Copy link
Contributor

@genaris genaris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems very interesting!


const connection = await agent.connections.findById(message.connectionId)
let connection: ConnectionRecord | null = null
connection = await this.checkForDuplicateId(message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this method should return undefined, throwing an Error in case of duplicate like it does right now), and the line const connection = await agent.connections.findById(message.connectionId) remain here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

private readonly coreMessageService: CoreMessageService,
) {}

async setProcessMessage(redisAvailable: boolean, message: IBaseMessage, connection: ConnectionRecord) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't call this simply processMessage, receiving the message and connection and doing the isRedisAvailable check right here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


async setProcessMessage(redisAvailable: boolean, message: IBaseMessage, connection: ConnectionRecord) {
return redisAvailable
? await this.messageQueue.add('', { message, connection })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does that '' mean? Seems a bit awkward to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a conditional ternary operator. It's used to simplify the "if" condition

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm asking about await this.messageQueue.add('', { message, connection }). The first argument is an empty string. What does it mean? Is it the right way of doing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it's not necessary

README.md Outdated
@@ -34,6 +34,8 @@ but likely needed for production and test deployments.
| POSTGRES_PASSWORD | PosgreSQL database password | None |
| POSTGRES_ADMIN_USER | PosgreSQL database admin user | None |
| POSTGRES_ADMIN_PASSWORD | PosgreSQL database admin password | None |
| REDIS_HOST | Redis database host user | None |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments regarding the usage of this Redis (what does it does) and the fact that is optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@genaris genaris merged commit 92bc600 into main Sep 13, 2024
1 check passed
@genaris genaris deleted the feat/implement-redis-background branch September 13, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants