Documentation ¶
Index ¶
- Variables
- type IPMux
- type Option
- func WithBaseClient(baseClient *http.Client) Option
- func WithBaseTransport(transport *http.Transport) Option
- func WithContext(ctx context.Context) Option
- func WithDNSCache(refreshInterval time.Duration) Option
- func WithDialer(dialer *net.Dialer) Option
- func WithKeepAlive(keepalive time.Duration) Option
- func WithTimeout(timeout time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidIP = errors.New("invalid source ip, not found in device network interfaces")
Functions ¶
This section is empty.
Types ¶
type IPMux ¶
type IPMux struct {
// contains filtered or unexported fields
}
func New ¶
New is the constructor of IPMux. It creates a http.Client for each of the ips given. If there are any errors for one of the ips, the client will not be created for that ip but the other clients will be created. you can customize the created clients with Option functions.
func (*IPMux) Client ¶
Client returns one of the clients that is associated with one of the IPs given in New. the function is safe to use without error handling of the constructor. it returns http.DefaultClient when there are no available clients.
func (*IPMux) ClientWithCounter ¶ added in v0.3.0
ClientWithCounter returns one of the clients that is associated with one of the IPs given in New. the function is safe to use without error handling of the constructor. it returns http.DefaultClient when there are no available clients.
type Option ¶
type Option func(base *clientBaseOpts)
func WithBaseClient ¶
WithBaseClient is used to change the base client that is used to create the clients for IPMux.
func WithBaseTransport ¶
WithBaseTransport is used to change the base transport (http.RoundTripper) that is used to create the clients for IPMux.
func WithContext ¶ added in v0.2.0
WithContext is used to change the context that is used to detect when to stop background goroutines like refreshing dns cache.
func WithDNSCache ¶ added in v0.2.0
WithDNSCache is used to enable dns cache for the clients.
func WithDialer ¶
WithDialer is used to change the base dialer that is used to create the clients for IPMux.
func WithKeepAlive ¶
WithKeepAlive is used to set keepalive on dialer of the clients.
func WithTimeout ¶
WithTimeout is used to set timeout on both client and dialer of the clients.