Documentation ¶
Overview ¶
Example (Basic) ¶
c := newCLITest() c.Run("kv put a 1 b 2") c.Run("kv scan") c.Run("kv del a") 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 inc c b") c.Run("quit")
Output: kv put a 1 b 2 kv scan "a" "1" "b" "2" kv del a 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" "\x00\x00\x00\x00\x00\x00\x00*" kv inc c b invalid increment: b: strconv.ParseInt: parsing "b": invalid syntax 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" 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 kv --log-backtrace-at=foo.go:1 scan kv --log-dir='' scan kv --logtostderr=true scan kv --verbosity=0 scan kv --vmodule=foo=1 scan 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("quit")
Output: kv put a 1 b 2 c 3 d 4 kv scan --max-results=3 "a" "1" "b" "2" "c" "3" 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" "日本語" kv get a\x00 "日本語" kv del a\x00 kv inc 1\x01 1 kv get 1\x01 "\x00\x00\x00\x00\x00\x00\x00\x01" 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("range split c") c.Run("range ls") c.Run("kv scan") c.Run("range merge b") c.Run("range ls") 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" 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 kv scan "a" "1" "b" "2" "c" "3" "d" "4" range merge b range ls ""-"\xff\xff" [1] 0: node-id=1 store-id=1 kv scan "a" "1" "b" "2" "c" "3" "d" "4" quit node drained and shutdown: ok
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Context = server.NewContext()
Context is the CLI Context used for the server.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.