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() }
func startNode(host string) { log.Println("Starting node", host) seedAddress := "127.0.0.2" config := Config{ ReplicationLevel: 3, W: 1, R: 1, RPCPort: 3001, Host: host, Store: memory.New(), } if host != seedAddress { config.SeedAddress = seedAddress } node := New(config) m.Lock() nodes = append(nodes, node) m.Unlock() }