github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/context.go (about)

     1  package ydb
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/operation"
     8  )
     9  
    10  // WithOperationTimeout returns a copy of parent context in which YDB operation timeout
    11  // parameter is set to d. If parent context timeout is smaller than d, parent context is returned.
    12  func WithOperationTimeout(ctx context.Context, operationTimeout time.Duration) context.Context {
    13  	return operation.WithTimeout(ctx, operationTimeout)
    14  }
    15  
    16  // WithOperationCancelAfter returns a copy of parent context in which YDB operation
    17  // cancel after parameter is set to d. If parent context cancellation timeout is smaller
    18  // than d, parent context is returned.
    19  func WithOperationCancelAfter(ctx context.Context, operationCancelAfter time.Duration) context.Context {
    20  	return operation.WithCancelAfter(ctx, operationCancelAfter)
    21  }