Created
January 30, 2014 03:50
-
-
Save l1x/8702206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"strconv" | |
"github.com/tpjg/goriakpbc" | |
) | |
func main() { | |
err := riak.ConnectClientPool("127.0.0.1:8087", 32) | |
if err != nil { | |
fmt.Println("Cannot connect, is Riak running?") | |
return | |
} | |
bucket, _ := riak.NewBucket("tstriak") | |
obj := bucket.NewObject("tstobj") | |
obj.ContentType = "application/json" | |
obj.Data = []byte("{'field':'value'}") | |
obj.Store() | |
fmt.Printf("Stored an object in Riak, vclock = %v\n", obj.Vclock) | |
for i := 0; i < 100; i++ { | |
t := strconv.Itoa(i) | |
fmt.Println(t) | |
obj := bucket.NewObject(t) | |
obj.ContentType = "application/json" | |
obj.Data = []byte("{'field':'value'}") | |
err = obj.Store() | |
if err != nil { | |
log.Fatal(err) | |
} | |
} | |
riak.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment