Ejemplo n.º 1
0
func channeled() {
	client, err := kinetic.Connect("localhost:8123")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer client.Close()

	count := 10

	data := make([]byte, 64*1024)

	rxs := make([]<-chan error, count)

	for i := 0; i < count; i++ {
		ch := make(chan []byte)
		go repeat(ch, 16, data)
		rxs[i], err = client.PutFrom([]byte("go-big-"+strconv.Itoa(i)), 1024*1024, ch)
		if err != nil {
			fmt.Println(err)
		}
	}

	// wait for all
	for i := 0; i < count; i++ {
		err := <-rxs[i]
		if err != nil {
			fmt.Println(err)
		}
	}
}
Ejemplo n.º 2
0
func regular() {
	client, _ := kinetic.Connect("localhost:8123")
	defer client.Close()

	count := 10

	rxs := make([]<-chan error, count)

	for i := 0; i < count; i++ {
		rxs[i], _ = client.Put([]byte("from-go-"+strconv.Itoa(i)), []byte("refactored 2.0!"))
	}

	// wait for all
	for i := 0; i < count; i++ {
		err := <-rxs[i]
		if err != nil {
			fmt.Println(err)
		}
	}
}