func NewHTTPGateway()

in gateway/gateway.go [73:107]


func NewHTTPGateway(c *client.Client, p *entity.Profile) (*HTTPGateway, error) {

	if p.Certificate != nil {
		tlsConfig, err := GetTLSConfig(p.Certificate)
		if err != nil {
			return nil, err
		}
		c.HTTPClient.HTTPClient.Transport = &http.Transport{
			TLSClientConfig: tlsConfig,
		}
	}

	// set max retry if provided by command
	if p.MaxRetry != nil {
		c.HTTPClient.RetryMax = *p.MaxRetry
	}
	//override with environment variable if exists
	if val, ok := overrideValue(p, environment.OPENSEARCH_MAX_RETRY); ok {
		c.HTTPClient.RetryMax = *val
	}

	// set connection timeout if provided by command
	if p.Timeout != nil {
		c.HTTPClient.HTTPClient.Timeout = time.Duration(*p.Timeout) * time.Second
	}
	//override with environment variable if exists
	if duration, ok := overrideValue(p, environment.OPENSEARCH_TIMEOUT); ok {
		c.HTTPClient.HTTPClient.Timeout = time.Duration(*duration) * time.Second
	}

	return &HTTPGateway{
		Client:  c,
		Profile: p,
	}, nil
}