本文整理匯總了Golang中hyperdex/client.Client.Put方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Put方法的具體用法?Golang Client.Put怎麽用?Golang Client.Put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hyperdex/client.Client
的用法示例。
在下文中一共展示了Client.Put方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
var attrs client.Attributes
var objs chan client.Attributes
var errs chan client.Error
_ = attrs
_ = objs
_ = errs
var c *client.Client
var err client.Error
port, _ := strconv.Atoi(os.Args[2])
c, er, _ := client.NewClient(os.Args[1], port)
if er != nil {
fmt.Println(err)
os.Exit(1)
}
objs, errs = c.Search("kv", []client.Predicate{{"v", "v1", client.EQUALS}})
err = c.Put("kv", "k1", client.Attributes{"v": "v1"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
objs, errs = c.Search("kv", []client.Predicate{{"v", "v1", client.EQUALS}})
err = c.Put("kv", "k2", client.Attributes{"v": "v1"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
objs, errs = c.Search("kv", []client.Predicate{{"v", "v1", client.EQUALS}})
os.Exit(0)
}
示例2: main
func main() {
var attrs client.Attributes
var objs chan client.Attributes
var errs chan client.Error
_ = attrs
_ = objs
_ = errs
var c *client.Client
var err client.Error
port, _ := strconv.Atoi(os.Args[2])
c, er, _ := client.NewClient(os.Args[1], port)
if er != nil {
fmt.Println(err)
os.Exit(1)
}
attrs, err = c.Get("kv", "k")
if err.Status != client.NOTFOUND {
fmt.Printf("bad status: %d (should be NOTFOUND)\n", err)
}
err = c.Put("kv", "k", client.Attributes{"v": "v1"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
attrs, err = c.Get("kv", "k")
if err.Status != client.SUCCESS {
fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
}
if !sloppyEqualAttributes(attrs, client.Attributes{"v": "v1"}) {
fmt.Printf("%s %s\n", attrs, client.Map{"v": "v1"})
panic("objects not equal")
}
err = c.CondPut("kv", "k", []client.Predicate{{"v", "v2", client.EQUALS}}, client.Attributes{"v": "v3"})
if err.Status != client.CMPFAIL {
os.Exit(1)
}
attrs, err = c.Get("kv", "k")
if err.Status != client.SUCCESS {
fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
}
if !sloppyEqualAttributes(attrs, client.Attributes{"v": "v1"}) {
fmt.Printf("%s %s\n", attrs, client.Map{"v": "v1"})
panic("objects not equal")
}
err = c.CondPut("kv", "k", []client.Predicate{{"v", "v1", client.EQUALS}}, client.Attributes{"v": "v3"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
attrs, err = c.Get("kv", "k")
if err.Status != client.SUCCESS {
fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
}
if !sloppyEqualAttributes(attrs, client.Attributes{"v": "v3"}) {
fmt.Printf("%s %s\n", attrs, client.Map{"v": "v3"})
panic("objects not equal")
}
os.Exit(0)
}
示例3: main
func main() {
var attrs client.Attributes
var objs chan client.Attributes
var errs chan client.Error
_ = attrs
_ = objs
_ = errs
var c *client.Client
var err client.Error
port, _ := strconv.Atoi(os.Args[2])
c, er, _ := client.NewClient(os.Args[1], port)
if er != nil {
fmt.Println(err)
os.Exit(1)
}
err = c.Put("kv", "A", client.Attributes{"v": "A"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "B", client.Attributes{"v": "B"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "C", client.Attributes{"v": "C"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "D", client.Attributes{"v": "D"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "E", client.Attributes{"v": "E"})
if err.Status != client.SUCCESS {
os.Exit(1)
}
objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.LESS_EQUAL}})
objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.LESS_EQUAL}})
objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.GREATER_EQUAL}})
objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.GREATER_EQUAL}})
objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.LESS_THAN}})
objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.LESS_THAN}})
objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.GREATER_THAN}})
objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.GREATER_THAN}})
objs, errs = c.Search("kv", []client.Predicate{{"k", "B", client.GREATER_EQUAL}, {"k", "D", client.LESS_EQUAL}})
objs, errs = c.Search("kv", []client.Predicate{{"v", "B", client.GREATER_EQUAL}, {"v", "D", client.LESS_EQUAL}})
os.Exit(0)
}
示例4: main
func main() {
var attrs client.Attributes
var objs chan client.Attributes
var errs chan client.Error
_ = attrs
_ = objs
_ = errs
var c *client.Client
var err client.Error
port, _ := strconv.Atoi(os.Args[2])
c, er, _ := client.NewClient(os.Args[1], port)
if er != nil {
fmt.Println(err)
os.Exit(1)
}
err = c.Put("kv", "A", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "AB", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "ABC", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "ABCD", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "ABCDE", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
objs, errs = c.Search("kv", []client.Predicate{{"k", int64(1), client.LENGTH_EQUALS}})
objs, errs = c.Search("kv", []client.Predicate{{"k", int64(2), client.LENGTH_EQUALS}})
objs, errs = c.Search("kv", []client.Predicate{{"k", int64(3), client.LENGTH_EQUALS}})
objs, errs = c.Search("kv", []client.Predicate{{"k", int64(4), client.LENGTH_EQUALS}})
objs, errs = c.Search("kv", []client.Predicate{{"k", int64(5), client.LENGTH_EQUALS}})
objs, errs = c.Search("kv", []client.Predicate{{"k", int64(3), client.LENGTH_LESS_EQUAL}})
objs, errs = c.Search("kv", []client.Predicate{{"k", int64(3), client.LENGTH_GREATER_EQUAL}})
os.Exit(0)
}
示例5: main
func main() {
var attrs client.Attributes
var objs chan client.Attributes
var errs chan client.Error
_ = attrs
_ = objs
_ = errs
var c *client.Client
var err client.Error
port, _ := strconv.Atoi(os.Args[2])
c, er, _ := client.NewClient(os.Args[1], port)
if er != nil {
fmt.Println(err)
os.Exit(1)
}
err = c.Put("kv", "k", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
attrs, err = c.Get("kv", "k")
if err.Status != client.SUCCESS {
fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
}
if !sloppyEqualAttributes(attrs, client.Attributes{"v": float64(0.0)}) {
fmt.Printf("%s %s\n", attrs, client.Map{"v": float64(0.0)})
panic("objects not equal")
}
err = c.Put("kv", "k", client.Attributes{"v": float64(3.14)})
if err.Status != client.SUCCESS {
os.Exit(1)
}
attrs, err = c.Get("kv", "k")
if err.Status != client.SUCCESS {
fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
}
if !sloppyEqualAttributes(attrs, client.Attributes{"v": float64(3.14)}) {
fmt.Printf("%s %s\n", attrs, client.Map{"v": float64(3.14)})
panic("objects not equal")
}
os.Exit(0)
}
示例6: main
func main() {
var attrs client.Attributes
var objs chan client.Attributes
var errs chan client.Error
_ = attrs
_ = objs
_ = errs
var c *client.Client
var err client.Error
port, _ := strconv.Atoi(os.Args[2])
c, er, _ := client.NewClient(os.Args[1], port)
if er != nil {
fmt.Println(err)
os.Exit(1)
}
err = c.Put("kv", "foo/foo/foo", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/foo/bar", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/foo/baz", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/bar/foo", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/bar/bar", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/bar/baz", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/baz/foo", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/baz/bar", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "foo/baz/baz", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/foo/foo", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/foo/bar", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/foo/baz", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/bar/foo", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/bar/bar", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/bar/baz", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/baz/foo", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/baz/bar", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "bar/baz/baz", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "baz/foo/foo", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "baz/foo/bar", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "baz/foo/baz", client.Attributes{})
if err.Status != client.SUCCESS {
os.Exit(1)
}
err = c.Put("kv", "baz/bar/foo", client.Attributes{})
//.........這裏部分代碼省略.........