go-smtp icon indicating copy to clipboard operation
go-smtp copied to clipboard

Context support

Open c4milo opened this issue 6 years ago • 4 comments
trafficstars

Adding context support would be nice for tracing and cancellation.

Thanks for this library!

c4milo avatar Dec 18 '18 03:12 c4milo

I'd like to see how the API could look like.

emersion avatar Dec 31 '18 16:12 emersion

For client it would involve duplicating Mail, Rcpt, etc. to add context.Context argument (MailContext, RcptContext).

As for relation to timeouts, perhaps we could have context-less functions create such context with some timeout value (e.g. 5 mins)? That would be convenient for me since maddy interfaces already have context.Context all over the place :)

foxcpp avatar Jul 17 '20 11:07 foxcpp

On a second thought, gluing together net.Conn and context.Context is a tricky task so it is probably better to just implement command timeouts like it is done for the server.

foxcpp avatar Jul 17 '20 11:07 foxcpp

+1 for the context, especially when you need to print debug logs per request and log the request ID. This would also require a rewriting of the Debug functionality.

kayrus avatar Sep 05 '20 09:09 kayrus