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
Make ExchangeWithConnContext public #1459
Conversation
If we want to use a custom mechanism of obtaining a Conn that doesn't match the net.Dialer type, but retain the timeout behaviour from ExchangeContext, there was previously no way to accomplish this. This PR makes the underlying ExchangeWithConnContext function public, which allows this behaviour. Now that miekg#1454 is merged, there is no longer any interaction between the context provided and the singleflight behaviour, so I removed the comment from ExchangeWithConn. Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
I don't understand... you mean |
Concretely: if I need to do something to obtain a netConn, err := myDialFunc(/* args */)
// check err
conn := &dns.Conn{
Conn: netConn,
}
var c dns.Client
resp, _, err := c.ExchangeWithConn(msg, conn) However, there's no way to add a timeout to the Exposing |
Ah I see.
Also for symmetry it would be nice to have both those *Context function to
be public.
Cheers
…On Sun, 18 Jun 2023, 01:51 Andrew Dunham, ***@***.***> wrote:
If we want to use a custom mechanism of obtaining a Conn that doesn't
match the net.Dialer type, but retain the timeout behaviour from
ExchangeContext, there was previously no way to accomplish this.
I don't understand... you mean doesn't match the net.Conn interface or
some such? As exchangeWithConnContext has the identical paramaters (apart
from the context) I don't see how this would help
Concretely: if I need to do something to obtain a *dns.Conn other than
using a *net.Dialer (through Client.Dialer), there's no way to both do
that and add a timeout to the request. I can do something like:
netConn, err := myDialFunc(/* args */)// check errconn := &dns.Conn{
Conn: netConn,
}
var c dns.Clientresp, _, err := c.ExchangeWithConn(msg, conn)
However, there's no way to add a timeout to the ExchangeWithConn
function. ExchangeContext doesn't let me provide a *dns.Conn, and the
Dialer field of Client is of concrete type *net.Dialer so I can't
override it with my custom dial logic.
Exposing ExchangeWithConnContext would allow me to pass a context.Context
with an appropriate deadline and thus add a timeout to the query.
—
Reply to this email directly, view it on GitHub
<#1459 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACWIW4MJEL2A5CYUSJAOB3XLY7JVANCNFSM6AAAAAAX5HF54U>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thank you! |
If we want to use a custom mechanism of obtaining a Conn that doesn't match the net.Dialer type, but retain the timeout behaviour from ExchangeContext, there was previously no way to accomplish this.
This PR makes the underlying ExchangeWithConnContext function public, which allows this behaviour.
Now that #1454 is merged, there is no longer any interaction between the context provided and the singleflight behaviour, so I removed the comment from ExchangeWithConn.