<commit_before>package workclient

import (
	"encoding/json"
	"fmt"
	"log"
	"net"
	"os"

	"time"

	"github.com/coreos/go-etcd/etcd"
	"github.com/quipo/statsd"
	"github.com/rcrowley/go-metrics"
)

type WorkClient struct {
	Config             *Config
	Header             string
	Version            string
	marshalledConfig   string
	closed             bool
	quit               chan struct{}
	logclosed          chan struct{}
	runtimeclosed      chan struct{}
	heartbeatclosed    chan struct{}
	reconnectclosed    chan struct{}
	runtimeTicker      *time.Ticker
	heartbeatTicker    *time.Ticker
	events             chan LogEvent
	statsdClient       *statsd.StatsdClient
	etcdClient         *etcd.Client
	stats              *statsd.StatsdBuffer
	gaugeMap           map[string]metrics.Gauge
	timeMap            map[string]metrics.Timer
	executeWorkFn      func()
	closeExecuteWorkFn func()
}

// Configure the client according to the given configuration and initialize state
func (client *WorkClient) Configure(config *Config, executeWorkFn, closeExecuteWorkFn func()) {
	client.logclosed = make(chan struct{}, 1)
	client.runtimeclosed = make(chan struct{}, 1)
	client.heartbeatclosed = make(chan struct{}, 1)
	client.reconnectclosed = make(chan struct{}, 1)
	client.quit = make(chan struct{}, 1)
	client.runtimeTicker = time.NewTicker(time.Second)
	client.heartbeatTicker = time.NewTicker(time.Second)
	client.events = make(chan LogEvent, 10)
	client.executeWorkFn = executeWorkFn
	client.closeExecuteWorkFn = closeExecuteWorkFn
	client.gaugeMap = make(map[string]metrics.Gauge)
	client.timeMap = make(map[string]metrics.Timer)
	client.Header = "%s v%s, pid: %v"
	client.Version = fmt.Sprintf("%v", time.Now().Unix())
	client.Config = config

	marshalledConfig, _ := json.Marshal(&config)
	client.marshalledConfig = string(marshalledConfig)

	if client.Config.Hostname == "" {
		if len(os.Getenv("HOSTNAME")) != 0 {
			client.Config.Hostname = os.Getenv("HOSTNAME")
		} else {
			h, err := os.Hostname()
			if err != nil {
				panic(err)<commit_msg>Removing reference pointer to config<commit_after>package workclient

import (
	"encoding/json"
	"fmt"
	"log"
	"net"
	"os"

	"time"

	"github.com/coreos/go-etcd/etcd"
	"github.com/quipo/statsd"
	"github.com/rcrowley/go-metrics"
)

type WorkClient struct {
	Config             Config
	Header             string
	Version            string
	marshalledConfig   string
	closed             bool
	quit               chan struct{}
	logclosed          chan struct{}
	runtimeclosed      chan struct{}
	heartbeatclosed    chan struct{}
	reconnectclosed    chan struct{}
	runtimeTicker      *time.Ticker
	heartbeatTicker    *time.Ticker
	events             chan LogEvent
	statsdClient       *statsd.StatsdClient
	etcdClient         *etcd.Client
	stats              *statsd.StatsdBuffer
	gaugeMap           map[string]metrics.Gauge
	timeMap            map[string]metrics.Timer
	executeWorkFn      func()
	closeExecuteWorkFn func()
}

// Configure the client according to the given configuration and initialize state
func (client *WorkClient) Configure(config Config, executeWorkFn, closeExecuteWorkFn func()) {
	client.logclosed = make(chan struct{}, 1)
	client.runtimeclosed = make(chan struct{}, 1)
	client.heartbeatclosed = make(chan struct{}, 1)
	client.reconnectclosed = make(chan struct{}, 1)
	client.quit = make(chan struct{}, 1)
	client.runtimeTicker = time.NewTicker(time.Second)
	client.heartbeatTicker = time.NewTicker(time.Second)
	client.events = make(chan LogEvent, 10)
	client.executeWorkFn = executeWorkFn
	client.closeExecuteWorkFn = closeExecuteWorkFn
	client.gaugeMap = make(map[string]metrics.Gauge)
	client.timeMap = make(map[string]metrics.Timer)
	client.Header = "%s v%s, pid: %v"
	client.Version = fmt.Sprintf("%v", time.Now().Unix())
	client.Config = config

	marshalledConfig, _ := json.Marshal(&config)
	client.marshalledConfig = string(marshalledConfig)

	if client.Config.Hostname == "" {
		if len(os.Getenv("HOSTNAME")) != 0 {
			client.Config.Hostname = os.Getenv("HOSTNAME")
		} else {
			h, err := os.Hostname()
			if err != nil {
				panic(err)
{'fraction_non_alphanumeric': 0.11000243368216112, 'fraction_numerical': 0.0038938914577756143, 'mean_word_length': 3.4336569579288025, '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': '1492165', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1304, 'n_words': 293}