예제 #1
0
func main() {
	var seed string
	if len(os.Args) != 2 {
		fmt.Printf("usage: %s [port] [seed]\n", os.Args[0])
		os.Exit(1)
	}
	port, err := strconv.Atoi(os.Args[1])

	if err != nil {
		panic(err)
	}

	// This section  is gross:

	seed_port := 3000

	// Seed for gossip protocol
	seed = ":3010"

	metaData := toystore.ToystoreMetaData{RPCAddress: ":3020"}
	if port == seed_port {
		log.Println("Seed node")
		Serve(toystore.New(port, memory.New(), "", metaData))
	} else {
		Serve(toystore.New(port, memory.New(), seed, metaData))
	}
}
예제 #2
0
파일: http.go 프로젝트: rlayte/toystore
func main() {
	if len(os.Args) != 2 {
		fmt.Printf("usage: %s [host]", os.Args[0])
		os.Exit(1)
	}

	host := os.Args[1]

	config := toystore.Config{
		ReplicationLevel: 3,
		W:                1,
		R:                1,
		RPCPort:          RpcPort,
		Host:             host,
		Store:            memory.New(),
	}

	if host != SeedAddress {
		config.SeedAddress = SeedAddress
	}

	store := toystore.New(config)
	api := Api{store}

	api.Serve()
}