Update task usage

This commit is contained in:
世界
2022-08-03 17:11:53 +08:00
parent 5c756f9000
commit 575dce6fb0
6 changed files with 38 additions and 22 deletions

View File

@@ -31,9 +31,11 @@ func StreamDomainNameQuery(readCtx context.Context, reader io.Reader) (*adapter.
defer buffer.Release()
readCtx, cancel := context.WithTimeout(readCtx, time.Millisecond*100)
err = task.Run(readCtx, func() error {
var readTask task.Group
readTask.Append0(func(ctx context.Context) error {
return common.Error(buffer.ReadFullFrom(reader, buffer.FreeLen()))
})
err = readTask.Run(readCtx)
cancel()
if err != nil {
return nil, err