github.com/blend/go-sdk@v1.20220411.3/configutil/duration_func.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package configutil
     9  
    10  import (
    11  	"context"
    12  	"time"
    13  )
    14  
    15  var (
    16  	_ DurationSource = (*DurationFunc)(nil)
    17  )
    18  
    19  // DurationFunc is a value source from a function.
    20  type DurationFunc func(context.Context) (*time.Duration, error)
    21  
    22  // Duration returns an invocation of the function.
    23  func (vf DurationFunc) Duration(ctx context.Context) (*time.Duration, error) {
    24  	return vf(ctx)
    25  }