<commit_before>// ketamaselector implements a list of servers where servers are picked based
// on Ketama consistent hashing algorithm
package ketamaselector

import (
	"net"
	"strings"
	"sync"

	"github.com/bradfitz/gomemcache/memcache"
	"github.com/dgryski/go-ketama"
)

type ServerSet struct {
	mu     sync.RWMutex
	addrs  map[string]net.Addr
	ketama *ketama.Continuum
}

// Sets buckets to be used. Label must be either a valid TCP address or
// a path to unix domain socket, in which case must contain a "/"
func (ss *ServerSet) SetBuckets(buckets ...ketama.Bucket) error {
	addrs := make(map[string]net.Addr)
	for _, b := range buckets {
		if strings.Contains(b.Label, "/") {
			addr, err := net.ResolveUnixAddr("unix", b.Label)
			if err != nil {
				return err
			}
			addrs[b.Label] = addr
		} else {
			tcpaddr, err := net.ResolveTCPAddr("tcp", b.Label)
			if err != nil {
				return err
			}
			addrs[b.Label] = tcpaddr
		}<commit_msg>Grr, don't forcefully put :11211 in the label<commit_after>// ketamaselector implements a list of servers where servers are picked based
// on Ketama consistent hashing algorithm
package ketamaselector

import (
	"net"
	"strings"
	"sync"

	"github.com/bradfitz/gomemcache/memcache"
	"github.com/dgryski/go-ketama"
)

type ServerSet struct {
	mu     sync.RWMutex
	addrs  map[string]net.Addr
	ketama *ketama.Continuum
}

func makeHostPort(s string) string {
	if !strings.Contains(s, ":") {
		return s + ":11211"
	}
	return s
}

// Sets buckets to be used. Label must be either a valid TCP address or
// a path to unix domain socket, in which case must contain a "/"
func (ss *ServerSet) SetBuckets(buckets ...ketama.Bucket) error {
	addrs := make(map[string]net.Addr)
	for _, b := range buckets {
		if strings.Contains(b.Label, "/") {
			addr, err := net.ResolveUnixAddr("unix", b.Label)
			if err != nil {
				return err
			}
			addrs[b.Label] = addr
		} else {
			tcpaddr, err := net.ResolveTCPAddr("tcp", b.Label)
			if err != nil {
				return err
			}
			addrs[makeHostPort(b.Label)] = tcpaddr
		}
{'fraction_non_alphanumeric': 0.12176039119804401, 'fraction_numerical': 0.004889975550122249, 'mean_word_length': 3.4094827586206895, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '597473', 'n_tokens_mistral': 791, 'n_tokens_neox': 725, 'n_words': 212}