<commit_before>package eureka

import (
	"bytes"
	"encoding/xml"
	"fmt"
	"math/rand"
	"net/http"
	"strings"
	"time"
)

func init() {
	rand.Seed(time.Now().Unix())
}

type Option func(*Client)

type Client struct {
	endpoints  []string
	httpClient *http.Client
}

func HttpClient(c *http.Client) Option {
	return func(client *Client) {
		client.httpClient = c
	}
}

func NewClient(endpoints []string, options ...Option) *Client {
	c := &Client{
		endpoints:  endpoints,
		httpClient: http.DefaultClient,
	}

	for _, opt := range options {
		opt(c)
	}

	return c
}

func (c *Client) Register(instance *Instance) error {
	data, err := xml.Marshal(instance)
	if err != nil {
		return err
	}

	return c.do("POST", c.appURI(instance.AppName), data, http.StatusNoContent)
}<commit_msg>Use custom http client with timeout<commit_after>package eureka

import (
	"bytes"
	"encoding/xml"
	"fmt"
	"math/rand"
	"net"
	"net/http"
	"strings"
	"time"
)

func init() {
	rand.Seed(time.Now().Unix())
}

type Option func(*Client)

type Client struct {
	endpoints  []string
	httpClient *http.Client
}

func HttpClient(c *http.Client) Option {
	return func(client *Client) {
		client.httpClient = c
	}
}

var defaultHttpClient = &http.Client{
	Timeout: 10 * time.Second,
	Transport: &http.Transport{
		Dial: (&net.Dialer{
			Timeout:   5 * time.Second,
			KeepAlive: 60 * time.Second,
		}).Dial,
		TLSHandshakeTimeout:   5 * time.Second,
		ResponseHeaderTimeout: 5 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
		MaxIdleConnsPerHost:   1,
	},
}

func NewClient(endpoints []string, options ...Option) *Client {
	c := &Client{
		endpoints:  endpoints,
		httpClient: defaultHttpClient,
	}

	for _, opt := range options {
		opt(c)
	}

	return c
}

func (c *Client) Register(instance *Instance) error {
	data, err := xml.Marshal(instance)
	if err != nil {
		return err
	}

	return c.do("POST", c.appURI(instance.AppName), data, http.StatusNoContent)
}
{'fraction_non_alphanumeric': 0.1441115702479339, 'fraction_numerical': 0.0046487603305785125, 'mean_word_length': 3.941326530612245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5024298', 'n_tokens_mistral': 753, 'n_tokens_neox': 719, 'n_words': 174}