Documentation ¶
Overview ¶
Example (Basic) ¶
c := newCLITest() c.Run("kv put a 1 b 2 c 3") c.Run("kv scan") c.Run("kv revscan") c.Run("kv del a c") c.Run("kv get a") c.Run("kv get b") c.Run("kv inc c 1") c.Run("kv inc c 10") c.Run("kv inc c 100") c.Run("kv inc c -- -60") c.Run("kv inc c -- -9") c.Run("kv scan") c.Run("kv revscan") c.Run("kv inc c b") c.Run("quit")
Output: kv put a 1 b 2 c 3 kv scan "a" "1" "b" "2" "c" "3" 3 result(s) kv revscan "c" "3" "b" "2" "a" "1" 3 result(s) kv del a c kv get a "a" not found kv get b "2" kv inc c 1 1 kv inc c 10 11 kv inc c 100 111 kv inc c -- -60 51 kv inc c -- -9 42 kv scan "b" "2" "c" 42 2 result(s) kv revscan "c" 42 "b" "2" 2 result(s) kv inc c b invalid increment: b: strconv.ParseInt: parsing "b": invalid syntax quit node drained and shutdown: ok
Example (Cput) ¶
c := newCLITest() c.Run("kv put a 1 b 2 c 3 d 4") c.Run("kv scan") c.Run("kv cput e 5") c.Run("kv cput b 3 2") c.Run("kv scan") c.Run("quit")
Output: kv put a 1 b 2 c 3 d 4 kv scan "a" "1" "b" "2" "c" "3" "d" "4" 4 result(s) kv cput e 5 kv cput b 3 2 kv scan "a" "1" "b" "3" "c" "3" "d" "4" "e" "5" 5 result(s) quit node drained and shutdown: ok
Example (Insecure) ¶
c := cliTest{} c.TestServer = &server.TestServer{} c.Ctx = server.NewTestContext() c.Ctx.Insecure = true if err := c.Start(); err != nil { log.Fatalf("Could not start server: %v", err) } c.Run("kv --insecure put a 1 b 2") c.Run("kv --insecure scan") c.Run("quit --insecure")
Output: kv --insecure put a 1 b 2 kv --insecure scan "a" "1" "b" "2" 2 result(s) quit --insecure node drained and shutdown: ok
Example (Logging) ¶
c := newCLITest() c.Run("kv --alsologtostderr=false scan") c.Run("kv --log-backtrace-at=foo.go:1 scan") c.Run("kv --log-dir='' scan") c.Run("kv --logtostderr=true scan") c.Run("kv --verbosity=0 scan") c.Run("kv --vmodule=foo=1 scan") c.Run("quit")
Output: kv --alsologtostderr=false scan 0 result(s) kv --log-backtrace-at=foo.go:1 scan 0 result(s) kv --log-dir='' scan 0 result(s) kv --logtostderr=true scan 0 result(s) kv --verbosity=0 scan 0 result(s) kv --vmodule=foo=1 scan 0 result(s) quit node drained and shutdown: ok
Example (Max_results) ¶
c := newCLITest() c.Run("kv put a 1 b 2 c 3 d 4") c.Run("kv scan --max-results=3") c.Run("kv revscan --max-results=2") c.Run("range split c") c.Run("range split d") c.Run("range ls --max-results=2") c.Run("quit")
Output: kv put a 1 b 2 c 3 d 4 kv scan --max-results=3 "a" "1" "b" "2" "c" "3" 3 result(s) kv revscan --max-results=2 "d" "4" "c" "3" 2 result(s) range split c range split d range ls --max-results=2 ""-"c" [1] 0: node-id=1 store-id=1 "c"-"d" [2] 0: node-id=1 store-id=1 2 result(s) quit node drained and shutdown: ok
Example (Quoted) ¶
c := newCLITest() c.Run(`kv put a\x00 日本語`) // UTF-8 input text c.Run(`kv put a\x01 \u65e5\u672c\u8a9e`) // explicit Unicode code points c.Run(`kv put a\x02 \U000065e5\U0000672c\U00008a9e`) // explicit Unicode code points c.Run(`kv put a\x03 \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e`) // explicit UTF-8 bytes c.Run(`kv scan`) c.Run(`kv get a\x00`) c.Run(`kv del a\x00`) c.Run(`kv inc 1\x01`) c.Run(`kv get 1\x01`) c.Run("quit")
Output: kv put a\x00 日本語 kv put a\x01 \u65e5\u672c\u8a9e kv put a\x02 \U000065e5\U0000672c\U00008a9e kv put a\x03 \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e kv scan "a\x00" "日本語" "a\x01" "日本語" "a\x02" "日本語" "a\x03" "日本語" 4 result(s) kv get a\x00 "日本語" kv del a\x00 kv inc 1\x01 1 kv get 1\x01 1 quit node drained and shutdown: ok
Example (Ranges) ¶
c := newCLITest() c.Run("kv put a 1 b 2 c 3 d 4") c.Run("kv scan") c.Run("kv revscan") c.Run("range split c") c.Run("range ls") c.Run("kv scan") c.Run("kv revscan") c.Run("range merge b") c.Run("range ls") c.Run("kv scan") c.Run("kv revscan") c.Run("kv delrange a c") c.Run("kv scan") c.Run("quit")
Output: kv put a 1 b 2 c 3 d 4 kv scan "a" "1" "b" "2" "c" "3" "d" "4" 4 result(s) kv revscan "d" "4" "c" "3" "b" "2" "a" "1" 4 result(s) range split c range ls ""-"c" [1] 0: node-id=1 store-id=1 "c"-"\xff\xff" [2] 0: node-id=1 store-id=1 2 result(s) kv scan "a" "1" "b" "2" "c" "3" "d" "4" 4 result(s) kv revscan "d" "4" "c" "3" "b" "2" "a" "1" 4 result(s) range merge b range ls ""-"\xff\xff" [1] 0: node-id=1 store-id=1 1 result(s) kv scan "a" "1" "b" "2" "c" "3" "d" "4" 4 result(s) kv revscan "d" "4" "c" "3" "b" "2" "a" "1" 4 result(s) kv delrange a c kv scan "c" "3" "d" "4" 2 result(s) quit node drained and shutdown: ok
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.