From eaa1a04e0ab0c7d009c024dce3fe3af7ce8b0bb6 Mon Sep 17 00:00:00 2001 From: gunli <24350715@qq.com> Date: Sun, 6 Aug 2023 15:55:49 +0800 Subject: [PATCH] [INLONG-8631][SDK] Handle context.Done() in Send() (#8632) Co-authored-by: gunli --- .../dataproxy-sdk-golang/dataproxy/worker.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/worker.go b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/worker.go index 186a8e3be70..7edfc0c6dcf 100755 --- a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/worker.go +++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy/worker.go @@ -301,8 +301,12 @@ func (w *worker) send(ctx context.Context, msg Message) error { }, true) // wait for send done - <-doneCh - return err + select { + case <-ctx.Done(): + return ctx.Err() + case <-doneCh: + return err + } } func (w *worker) sendAsync(ctx context.Context, msg Message, callback Callback) {