github.com/blend/go-sdk@v1.20240719.1/webutil/dial_option.go (about)

     1  /*
     2  
     3  Copyright (c) 2024 - 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 webutil
     9  
    10  import (
    11  	"net"
    12  	"time"
    13  )
    14  
    15  // DialOption is a mutator for a net.Dialer
    16  type DialOption func(*net.Dialer)
    17  
    18  // OptDialTimeout sets the dial timeout.
    19  func OptDialTimeout(d time.Duration) DialOption {
    20  	return func(dialer *net.Dialer) {
    21  		dialer.Timeout = d
    22  	}
    23  }
    24  
    25  // OptDialKeepAlive sets the dial keep alive duration.
    26  // Only use this if you know what you're doing, the defaults are typically sufficient.
    27  func OptDialKeepAlive(d time.Duration) DialOption {
    28  	return func(dialer *net.Dialer) {
    29  		dialer.KeepAlive = d
    30  	}
    31  }