<commit_before>package main

import (
	"flag"
	"fmt"
	"log"
	"strings"
	"time"

	"github.com/coreos/go-etcd/etcd"
)

var (
	env      string
	etcdHost string
	etcdPort string
	publicIP string
)

func init() {
	flag.StringVar(&env, "env", "dev", "environment {dev|stage|prod}")
	flag.StringVar(&etcdHost, "etcd", "127.0.0.1", "etcd hostname")
	flag.StringVar(&etcdPort, "etcd-port", "4001", "etcd port")
	flag.StringVar(&publicIP, "public-ip", "127.0.0.1", "advertised public IP for this host")
	flag.StringVar(&backendCfg, "backends", "backend.cfg", "haproxy backend config file")
	flag.StringVar(&globalCfg, "global", "haproxy.cfg", "haproxy global config file")
	flag.StringVar(&haproxyPid, "pid", "haproxy.pid", "haproxy pid file")
	flag.StringVar(&haproxy, "haproxy", "haproxy", "haproxy binary")
	flag.Parse()

	haproxyOpts = []string{"-f", globalCfg, "-f", backendCfg, "-p", haproxyPid}
}

// struct for unmarshaling Service (for PORT) and Server locations
type ServiceCfg struct {
	Port         string `json:"PORT"`
	ExternalIP   string `json:"EXTERNAL_IP"`
	ExternalPort string `json:"EXTERNAL_PORT"`
	InternalIP   string `json:"INTERNAL_IP"`
	InternalPort string `json:"INTERNAL_PORT"`
}

// detect Services and Servers by their configuration key names
// return "server" or "service"
func valueType(parts []string) string {
	if len(parts) == 4 && parts[3] == "environment" {
		return "service"
	}
	if len(parts) == 6 && parts[5] == "location" {
		return "server"
	}
	return ""
}<commit_msg>Remove some service config registration duplicate code<commit_after>package main

import (
	"flag"
	"fmt"
	"log"
	"strings"
	"time"

	"github.com/coreos/go-etcd/etcd"
	"github.com/litl/galaxy/registry"
)

var (
	env      string
	etcdHost string
	etcdPort string
	publicIP string
)

func init() {
	flag.StringVar(&env, "env", "dev", "environment {dev|stage|prod}")
	flag.StringVar(&etcdHost, "etcd", "127.0.0.1", "etcd hostname")
	flag.StringVar(&etcdPort, "etcd-port", "4001", "etcd port")
	flag.StringVar(&publicIP, "public-ip", "127.0.0.1", "advertised public IP for this host")
	flag.StringVar(&backendCfg, "backends", "backend.cfg", "haproxy backend config file")
	flag.StringVar(&globalCfg, "global", "haproxy.cfg", "haproxy global config file")
	flag.StringVar(&haproxyPid, "pid", "haproxy.pid", "haproxy pid file")
	flag.StringVar(&haproxy, "haproxy", "haproxy", "haproxy binary")
	flag.Parse()

	haproxyOpts = []string{"-f", globalCfg, "-f", backendCfg, "-p", haproxyPid}
}

// struct for unmarshaling Service (for PORT) and Server locations
type ServiceCfg struct {
	Port string `json:"PORT"`
	registry.ServiceRegistration
}

// detect Services and Servers by their configuration key names
// return "server" or "service"
func valueType(parts []string) string {
	if len(parts) == 4 && parts[3] == "environment" {
		return "service"
	}
	if len(parts) == 6 && parts[5] == "location" {
		return "server"
	}
	return ""
}
{'fraction_non_alphanumeric': 0.16518467852257182, 'fraction_numerical': 0.013679890560875513, 'mean_word_length': 4.945121951219512, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '6106257', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1081, 'n_words': 268}