<commit_before>/*-
 * Copyright (c) 2012 <NAME> <<EMAIL>>,
 *                    Ancient Solutions. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions  of source code must retain  the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions  in   binary  form  must   reproduce  the  above
 *    copyright  notice, this  list  of conditions  and the  following
 *    disclaimer in the  documentation and/or other materials provided
 *    with the distribution.
 *
 * THIS  SOFTWARE IS  PROVIDED BY  ANCIENT SOLUTIONS  AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO,  THE IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS
 * FOR A  PARTICULAR PURPOSE  ARE DISCLAIMED.  IN  NO EVENT  SHALL THE
 * FOUNDATION  OR CONTRIBUTORS  BE  LIABLE FOR  ANY DIRECT,  INDIRECT,
 * INCIDENTAL,   SPECIAL,    EXEMPLARY,   OR   CONSEQUENTIAL   DAMAGES
 * (INCLUDING, BUT NOT LIMITED  TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT  LIABILITY,  OR  TORT  (INCLUDING NEGLIGENCE  OR  OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package main

import (
	"flag"
	"io/ioutil"
	"log"
	"net"
	"net/rpc"
	"os"

	"ancientsolutions.com/doozer/exportedservice"
	"ancientsolutions.com/geocolo"
	"code.google.com/p/goprotobuf/proto"
)

func main() {
	var service *geocolo.GeoProximityService
	var exporter *exportedservice.ServiceExporter
	var config *geocolo.GeoProximityServiceConfig
	var configpath, doozer_uri, boot_uri string
	var listen_net, listen_ip, listen_servicename string
	var listener net.Listener
	var configfile *os.File
	var bdata []byte
	var err error

	flag.StringVar(&configpath, "config", "",
		"Path to the geocolo service configuration")
	flag.StringVar(&doozer_uri, "doozer-uri", "",
		"URI of the Doozer service")
	flag.StringVar(&boot_uri, "doozer-boot-uri", "",
		"Boot URI of the Doozer service")
	flag.StringVar(&listen_net, "listen-proto", "tcp",
		"Protocol type to listen on (e.g. tcp)")
	flag.StringVar(&listen_ip, "listen-addr", "[::]",
		"IP address to listen on")
	flag.StringVar(&listen_servicename, "export-service", "geocolo",
		"Service name to export as")
	flag.Parse()

	config = new(geocolo.GeoProximityServiceConfig)
	configfile, err = os.Open(configpath)
	if err != nil {
		log.Fatal("Error opening ", configpath, ": ", err)
	}

	bdata, err = ioutil.ReadAll(configfile)
	if err != nil {
		configfile.Close()
		log.Fatal("Error reading ", configpath, ": ", err)
	}

	err = proto.Unmarshal(bdata, config)
	if err != nil {
		configfile.Close()
		log.Fatal("Error parsing ", configpath, ": ", err)
	}
<commit_msg>Fetch doozer URIs from environment if applicable.<commit_after>/*-
 * Copyright (c) 2012 <NAME> <<EMAIL>>,
 *                    Ancient Solutions. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions  of source code must retain  the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions  in   binary  form  must   reproduce  the  above
 *    copyright  notice, this  list  of conditions  and the  following
 *    disclaimer in the  documentation and/or other materials provided
 *    with the distribution.
 *
 * THIS  SOFTWARE IS  PROVIDED BY  ANCIENT SOLUTIONS  AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO,  THE IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS
 * FOR A  PARTICULAR PURPOSE  ARE DISCLAIMED.  IN  NO EVENT  SHALL THE
 * FOUNDATION  OR CONTRIBUTORS  BE  LIABLE FOR  ANY DIRECT,  INDIRECT,
 * INCIDENTAL,   SPECIAL,    EXEMPLARY,   OR   CONSEQUENTIAL   DAMAGES
 * (INCLUDING, BUT NOT LIMITED  TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT  LIABILITY,  OR  TORT  (INCLUDING NEGLIGENCE  OR  OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package main

import (
	"flag"
	"io/ioutil"
	"log"
	"net"
	"net/rpc"
	"os"

	"ancientsolutions.com/doozer/exportedservice"
	"ancientsolutions.com/geocolo"
	"code.google.com/p/goprotobuf/proto"
)

func main() {
	var service *geocolo.GeoProximityService
	var exporter *exportedservice.ServiceExporter
	var config *geocolo.GeoProximityServiceConfig
	var configpath, doozer_uri, boot_uri string
	var listen_net, listen_ip, listen_servicename string
	var listener net.Listener
	var configfile *os.File
	var bdata []byte
	var err error

	flag.StringVar(&configpath, "config", "",
		"Path to the geocolo service configuration")
	flag.StringVar(&doozer_uri, "doozer-uri", os.Getenv("DOOZER_URI"),
		"URI of the Doozer service")
	flag.StringVar(&boot_uri, "doozer-boot-uri",
		os.Getenv("DOOZER_BOOT_URI"),
		"Boot URI of the Doozer service")
	flag.StringVar(&listen_net, "listen-proto", "tcp",
		"Protocol type to listen on (e.g. tcp)")
	flag.StringVar(&listen_ip, "listen-addr", "[::]",
		"IP address to listen on")
	flag.StringVar(&listen_servicename, "export-service", "geocolo",
		"Service name to export as")
	flag.Parse()

	config = new(geocolo.GeoProximityServiceConfig)
	configfile, err = os.Open(configpath)
	if err != nil {
		log.Fatal("Error opening ", configpath, ": ", err)
	}

	bdata, err = ioutil.ReadAll(configfile)
	if err != nil {
		configfile.Close()
		log.Fatal("Error reading ", configpath, ": ", err)
	}

	err = proto.Unmarshal(bdata, config)
	if err != nil {
		configfile.Close()
		log.Fatal("Error parsing ", configpath, ": ", err)
	}

{'fraction_non_alphanumeric': 0.09906357811729916, 'fraction_numerical': 0.001971414489896501, 'mean_word_length': 3.973856209150327, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, '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': '4848546', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1926, 'n_words': 652}