<commit_before>package coordinator

import (
	log "code.google.com/p/log4go"
	"protocol"
)

type ClusterServer struct {
	Id                       uint32
	RaftName                 string
	State                    ServerState
	RaftConnectionString     string
	ProtobufConnectionString string
	protobufClient           *ProtobufClient
}

type ServerState int

const (
	LoadingRingData ServerState = iota
	SendingRingData
	DeletingOldData
	Running
	Potential
)

func (self *ClusterServer) Connect() {
	if self.protobufClient != nil {
		return
	}

	log.Info("ClusterServer: %d connecting to: %s", self.Id, self.ProtobufConnectionString)
	self.protobufClient = NewProtobufClient(self.ProtobufConnectionString)
}

func (self *ClusterServer) MakeRequest(request *protocol.Request, responseStream chan *protocol.Response) error {
	self.Connect()
	return self.protobufClient.MakeRequest(request, responseStream)
}
<commit_msg>don't create a protobuf client in the tests<commit_after>package coordinator

import (
	log "code.google.com/p/log4go"
	"net"
	"protocol"
)

type ClusterServer struct {
	Id                       uint32
	RaftName                 string
	State                    ServerState
	RaftConnectionString     string
	ProtobufConnectionString string
	protobufClient           *ProtobufClient
}

type ServerState int

const (
	LoadingRingData ServerState = iota
	SendingRingData
	DeletingOldData
	Running
	Potential
)

// in the coordinator test we don't want to create protobuf servers,
// so we just ignore creating a protobuf client when the connection
// string has a 0 port
func shouldConnect(addr string) bool {
	_, port, err := net.SplitHostPort(addr)
	if err != nil {
		log.Error("Error parsing address '%s': %s", addr, err)
		return false
	}

	if port == "0" {
		log.Warn("Cannot connect to port 0. Not creating a protobuf client")
		return false
	}
	return true
}

func (self *ClusterServer) Connect() {
	if self.protobufClient != nil {
		return
	}

	if !shouldConnect(self.ProtobufConnectionString) {
		return
	}

	log.Info("ClusterServer: %d connecting to: %s", self.Id, self.ProtobufConnectionString)
	self.protobufClient = NewProtobufClient(self.ProtobufConnectionString)
}

func (self *ClusterServer) MakeRequest(request *protocol.Request, responseStream chan *protocol.Response) error {
	self.Connect()
	return self.protobufClient.MakeRequest(request, responseStream)
}

{'fraction_non_alphanumeric': 0.08117154811715481, 'fraction_numerical': 0.0037656903765690376, 'mean_word_length': 3.734653465346535, 'pattern_counts': {'":': 0, '<': 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': '7228505', 'n_tokens_mistral': 730, 'n_tokens_neox': 695, 'n_words': 198}