Example #1
0
func main() {
	var array []int
	config := lilraft.NewConfig(
		lilraft.NewHTTPNode(1, "http://127.0.0.1:8787"),
		lilraft.NewHTTPNode(2, "http://127.0.0.1:8788"),
		lilraft.NewHTTPNode(3, "http://127.0.0.1:8789"),
	)
	s := lilraft.NewServer(1, &array, config, "server/")
	s.SetHTTPTransport(http.DefaultServeMux, 8787)
	s.Start(false)
	time.Sleep(50 * time.Millisecond)
}
Example #2
0
func main() {
	var array []int
	config := lilraft.NewConfig(
		lilraft.NewHTTPNode(1, "http://127.0.0.1:8787"),
	)
	s := lilraft.NewServer(1, &array, config, "server/")
	s.SetHTTPTransport(http.DefaultServeMux, 8787)
	s.RegisterCommand(&testCommand{})
	s.Start(true)
	time.Sleep(500 * time.Millisecond)
	fmt.Println(array)
	s.Stop()
}