소스 검색

Simplify contextx.ShrinkDeadline (#596)

Oraoto 4 년 전
부모
커밋
425430f67c
1개의 변경된 파일1개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 8
      core/contextx/deadline.go

+ 1 - 8
core/contextx/deadline.go

@@ -8,12 +8,5 @@ import (
 // ShrinkDeadline returns a new Context with proper deadline base on the given ctx and timeout.
 // And returns a cancel function as well.
 func ShrinkDeadline(ctx context.Context, timeout time.Duration) (context.Context, func()) {
-	if deadline, ok := ctx.Deadline(); ok {
-		leftTime := time.Until(deadline)
-		if leftTime < timeout {
-			timeout = leftTime
-		}
-	}
-
-	return context.WithDeadline(ctx, time.Now().Add(timeout))
+	return context.WithTimeout(ctx, timeout)
 }