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

Terminate/cancel the currently sending email #720

Closed
nichita-pasecinic opened this issue Oct 1, 2022 · 7 comments
Closed

Terminate/cancel the currently sending email #720

nichita-pasecinic opened this issue Oct 1, 2022 · 7 comments

Comments

@nichita-pasecinic
Copy link

Is your feature request related to a problem? Please describe.

I need to cancel the delivering process of the email when a timeout is reached. I would like handle by myself when the request should be cancelled

Is your feature request related to a specific adapter? Please specify.

Gmail, but could apply to others as well

Describe the solution you'd like

It could be implemented in various ways, and this one is not the smartest one:
The deliver function can receive a worker PID and would listen to its internal messages and in case there would appear something like :terminate it would cancel the request (email deliver) and exit with a corresponding status atom

Describe alternatives you've considered

probably a configurable timeout in deliver/2 config argument, I could not clearly find in the docs what config is supposed to have, probably just some adapters specific configuration, would be nice to have some Finch configs too, in case it implements those timeout/request cancellations already

Additional context

@princemaple
Copy link
Member

email |> put_private(:client_options, options) will be passed to your http client.

@nichita-pasecinic
Copy link
Author

Hi @princemaple and big thanks for a quick reply, yeah the put_private\3 solved it, but I could not find in the docs all available keys that are available for configuration.
I assume there are more than just :client_options I would possibly use 😄

Thanks 🙏

@princemaple
Copy link
Member

There are actually not that many. This one is documented on the Email module. And provider specific options are documented on respective provider module.

@princemaple
Copy link
Member

princemaple commented Oct 1, 2022

That's all I can recall at the moment.

@nichita-pasecinic
Copy link
Author

nichita-pasecinic commented Oct 1, 2022

Ohh, I see. But back to my question, passing a timeout to client API (Finch in my case) would not support cancellable requests, I see in the implementation is used Finch.request that internally does not support cancellable requests and only the Finch.stream might work in this case sneako/finch#112.

I can receive the right timeout error now from Finch, but the email is still delivered, which is not desired

@princemaple
Copy link
Member

Hmm. I don't know. I may accept PR about this, but I don't think I'll go and implement it, as it's going to be hard to keep hackney and SMTP up to speed.

@josevalim
Copy link
Contributor

I would say that, if you want to cancel it in general, run it inside a task and then send a shutdown/kill signal to the task to terminate it. I don't think swoosh in particular needs to accommodate it. :)

@princemaple princemaple closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants