示例#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)
		}
	}
}
示例#2
0
文件: kinetic.go 项目: y-okubo/nekofs
func unlink(name string) {
	client, _ := kinetic.Connect("localhost:8123")
	defer client.Close()

	chanError, _ := client.Delete([]byte(string(name)))
	err := <-chanError
	if err != nil {
		fmt.Println(err)
	}
}
示例#3
0
文件: kinetic.go 项目: y-okubo/nekofs
func create(name string, value string) {
	fmt.Println("create:::", " ", name, " ", value, " ")
	client, _ := kinetic.Connect("localhost:8123")
	defer client.Close()

	chanError, _ := client.Put([]byte(name), []byte(value))
	err := <-chanError
	if err != nil {
		fmt.Println(name, " ", value, " ", err)
	}
}
示例#4
0
文件: kinetic.go 项目: y-okubo/nekofs
func content(name string) (string, error) {
	client, _ := kinetic.Connect("localhost:8123")
	defer client.Close()

	chanValue, chanError, _ := client.Get([]byte(string(name)))
	select {
	case val := <-chanValue:
		// Success
		return string(val), nil
	case err := <-chanError:
		fmt.Println(err)
		return "", err
	}
}
示例#5
0
文件: kinetic.go 项目: y-okubo/nekofs
func listing() [][]byte {
	client, _ := kinetic.Connect("localhost:8123")
	defer client.Close()

	chanValue, chanError, _ := client.GetKeyRange([]byte(string(0)), []byte(string(math.MaxInt32)))
	select {
	case val := <-chanValue:
		// Success
		// for i := 0; i < len(val); i++ {
		// 	fmt.Println(string(val[i]))
		// }
		return val
	case err := <-chanError:
		fmt.Println(err)
		return nil
	}
}
示例#6
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)
		}
	}
}