From df74c3831e09bb5dddfc79ac13dc9016218520bb Mon Sep 17 00:00:00 2001 From: codesoap Date: Mon, 10 Feb 2025 16:40:33 +0100 Subject: [PATCH] Clarify that a blocked channel discards results The documentation previously did not clarify, that results are immediately discarded, if the receiving channel is not accepting entries. This is now emphasized and a remedy is suggested more directly. --- client.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client.go b/client.go index d4e4f40..81d2f74 100644 --- a/client.go +++ b/client.go @@ -65,19 +65,21 @@ func DefaultParams(service string) *QueryParam { } } -// Query looks up a given service, in a domain, waiting at most -// for a timeout before finishing the query. The results are streamed -// to a channel. Sends will not block, so clients should make sure to -// either read or buffer. +// Query looks up a given service, in a domain, waiting at most for +// a timeout before finishing the query. The results are sent to the +// params.Entries channel. If a result cannot be sent to params.Entries +// immediately, it will be discarded. A large buffer on the channel can +// ensure that no result is lost. func Query(params *QueryParam) error { return QueryContext(context.Background(), params) } // QueryContext looks up a given service, in a domain, waiting at most -// for a timeout before finishing the query. The results are streamed -// to a channel. Sends will not block, so clients should make sure to -// either read or buffer. QueryContext will attempt to stop the query -// on cancellation. +// for a timeout before finishing the query. The results are sent to the +// params.Entries channel. If a result cannot be sent to params.Entries +// immediately, it will be discarded. A large buffer on the channel can +// ensure that no result is lost. QueryContext will attempt to stop the +// query on cancellation. func QueryContext(ctx context.Context, params *QueryParam) error { if params.Logger == nil { params.Logger = log.Default()