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

Justification for IO dispatcher? #31

Open
zeldigas opened this issue Jun 8, 2020 · 2 comments
Open

Justification for IO dispatcher? #31

zeldigas opened this issue Jun 8, 2020 · 2 comments

Comments

@zeldigas
Copy link

zeldigas commented Jun 8, 2020

What is the reason of using IO dispatcher for launching message fetchers and consumers?
https://github.com/SeekerWing/aws-sqs-consumer/blob/master/src/main/kotlin/org/seekerwing/aws/sqsconsumer/SqsQueueConsumer.kt#L19

As you are using aws sdk v2 and message processor has suspend modifier I don't see the reason for not using Dispatchers.Default.

@plastic-karma
Copy link
Collaborator

@zeldigas , thanks for the feedback. I think the idea for having the IO dispatcher fetch messages is that there is in fact a lot of IO work being done.

As you are using aws sdk v2 and message processor has suspend modifier I don't see the reason for not using Dispatchers.Default.

I don't fully understand, how this relates to the dispatcher, but I would love to learn more.

@zeldigas
Copy link
Author

zeldigas commented Jul 5, 2020

IO dispatcher in coroutines should be used in cases when you expect a blocking to happen (and as it name suggests there is expectation that blocking would be done while dealing with I/O operations if you use regular Socket impl, not NIO).
But the thing is that in your code you are using aws sdk v2 (https://github.com/SeekerWing/aws-sqs-consumer/blob/master/src/main/kotlin/org/seekerwing/aws/sqsconsumer/model/Queue.kt#L10) that is non-blocking, so you can use regular dispatcher (Distpachers.Default), because it is not supposed to block on socker read/write.

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

No branches or pull requests

2 participants