package main import ( "fmt" //"encoding/json" "github.com/gomodule/redigo/redis" "github.com/vmihailenco/msgpack/v5" ) // dial wraps DialDefaultServer() with a more suitable function name for examples. func dial() (redis.Conn, error) { c, err := redis.Dial("tcp", "127.0.0.1:11001") if err != nil { return nil ,err } return c, nil } func main() { c, err := dial() if err != nil { fmt.Println(err) return } defer c.Close() //params, _ := msgpack.Marshal([]interface{}{ "SD25" }) //params, _ := json.Marshal([]interface{}{ "SD25" }) //reply, err := c.Do("MQL", "select name from /matrix/devops/alert where name=?", "db=matrix,content=json", params ) /*params, _ := msgpack.Marshal([]interface{}{ "/matrix/devops/alert" }) reply, err := c.Do("CQL", "select name from class where name=?", params )*/ //params, _ := msgpack.Marshal([]interface{}{"ccc", "ddd"}) //reply, err := c.Do("CQL", ` insert into testtasker ( group ,name ) values (?, ?)`, params) //params, _ := msgpack.Marshal(nil) //option, _ := msgpack.Marshal(map[string]interface{}{ "db": "matrix" }) //reply, err := c.Do("CQL", ` insert into testtasker ( group ,name ) values ('ccc', 'ddd')`,option) //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "matrix" , "search_dirs": []string{"/filesystem"}, "search_class": []string{"/hello"}, "asterisk_no_relation": true } ) //reply, err := c.Do("SEARCH", `devops`, option) //params, _ := msgpack.Marshal([]interface{}{"test1"}) //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "typedeftest" , "asterisk_no_relation": true, "asterisk_keep": []string{} } ) //reply, err := c.Do("MQL", `select id,wheel[*] from /matrix/entity/car/camry where wheel.rotations.time('1631462400000','').sum(count).assert($1 > 1200)`, option ) //reply, err := c.Do("MQL", ` insert into /matrix/devops/change (workordernum) values ('test1')`, string(option) ) for i:=1 ; i<100 ; i++ { reply, err := c.Do("SQL", fmt.Sprintf(` insert into org values ('Janet', 'IT%s') `,i )) } //reply, err := c.Do("MQL", ` update /matrix/devops/change set name='hello' where workordernum = 'test1'`) //reply, err := c.Do("PUBLISH", `test`, "hello") //reply, err := c.Do("schema", `matrix`, 23) //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "matrix" } ) /*reply, err := c.Do("MQL", ` create class if not exists /matrix/testddd(); create class if not exists /matrix/testddd/api ( name varchar '权限名称', pprefix set '开头匹配的JS目录权限', pmatch set '完全匹配的JS文件权限', mtime timestamp '更新时间', keys(name), indexes(name, mtime) ) with partition=name, version=true, key=hash, autosearch=false; create class if not exists /matrix/testddd/ui ( name varchar 'HTML的上级目录', app varchar '/app下第一级目录名称,与/matrix/portal/tools的app相同', perms set '权限标签列表', mtime timestamp '更新时间', keys(name, app), indexes(name, app, mtime) ) with partition=(name,app), version=true, key=hash, autosearch=false; `, option )*/ if err == nil { fmt.Printf("reply ==>%v \n", string(reply.([]byte)) ) }else{ fmt.Printf("error ==>%v \n", err) } }