| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- package main
- import (
- //"os"
- "fmt"
- //"time"
- //"encoding/json"
- //"runtime/pprof"
- //"git.wecise.com/wecise/util/const/mdir"
- "github.com/gomodule/redigo/redis"
- "github.com/vmihailenco/msgpack/v5"
- //"gitee.com/wecisecode/util/logger"
- )
- // dial wraps DialDefaultServer() with a more suitable function name for examples.
- func dial() (redis.Conn, error) {
- //c, err := redis.Dial("tcp", "172.26.38.247:11001")
- //c, err := redis.Dial("tcp", "127.0.0.1:11001")
- c, err := redis.Dial("tcp", "47.92.151.165: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" })
- //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "matrix" , "user":"/测试部/test01" } )
- //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "matrix" } )
- //reply, err := c.Do("SEARCH", `#/matrix/devops/alert_status | severity > 3 | print severity | top 200`, option)
- //params, _ := msgpack.Marshal(map[string]interface{}{ "policy": "dc1:1" })
- //reply, err := c.Do("OMDB", "testoo", "create", params )
- //reply, err := redis.DoWithTimeout(c, 1200*time.Second, "create", "testoo", "REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}" )
- /*params, _ := msgpack.Marshal([]interface{}{ "/matrix/devops/alert" })
- reply, err := c.Do("CQL", "select name from class where name=?", params )*/
- //params, _ := msgpack.Marshal([]interface{}{"10", "IT10", "11", "IT11", "12", "IT12", "13", "IT13"})
- //reply, err := c.Do("SQL", `insert into org values (?, ?)`, "type=table,console=true", params)
- //params, _ := msgpack.Marshal([]interface{}{ "07", "IT7"})
- //reply, err := c.Do("SQL", `insert into org values (?, ?)`, "type=table,console=true", params)
- //params, _ := msgpack.Marshal(nil)
- //option, _ := msgpack.Marshal(map[string]interface{}{ "db": "matrix" })
- //reply, err := c.Do("CQL", `alter table class add onconflict map<varchar,int>`)
- //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{} { map[string][]string{ "add": {"/测试部"}, "delete": {"/测试部"}, "edit": {"/测试部"}, "list": {"/测试部"}}, "", "company", []string{ "总行/核心交换机2", "总行/核心交换机", "总行"} } )
- //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "matrix" , "default_nil": true } )
- //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "eventbus" , "asterisk_no_relation": true, "asterisk_keep": []string{} } )
- //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "ootest" , "asterisk_keep": []string{"class", "id"} } )
- //params, _ := msgpack.Marshal( []interface{} { nil, nil, nil, nil, nil, "/admin" } )
- //reply, err := c.Do("MQL", `update alert_status set type=2 where severity in ?`, option, params )
- //reply, err := c.Do("MQL", `update /matrix/tagdir set _group = _group - ? where creater = ? and domain = ? and path in ?`, option, params )
- //reply, err := c.Do("MQL", `update group set tadd=tadd+?, tedit=tedit+?, tdelete=tdelete+?, tlist=tlist+?, _group=_group+? where fullname=?`, option, params )
- //reply, err := c.Do("MQL", ` insert into /matrix/devops/change (workordernum) values ('test1')`, string(option) )
- //option, _ := msgpack.Marshal( map[string]interface{}{ "db": "typedeftest", "content": "json", "asterisk_no_relation": true, "asterisk_keep": []string{"id", "class"} } )
- //reply, err := c.Do("MQL", ` select * from MillingCuttingTool where id = "MillingCuttingTool:1002"; `, option )
- //option, _ := msgpack.Marshal(map[string]interface{}{"meta": false, "content": "json"})
- params, _ := msgpack.Marshal([]interface{}{"IBPS", 202301251540, 1})
- option, _ := msgpack.Marshal(map[string]interface{}{"db": "ootest", "asterisk_no_relation": true})
- reply, err := c.Do("MQL", ` select transuid, appno, comptime, msgdealstatus, atrt from /native/cnccbdos@202301251540 where syscode = ? and minute = ? and batchno = ? `, option, params)
- /*st := time.Now().UnixNano()
- reply, err := c.Do("SEARCH", `#/matrix/devops/alert_status`)
- //reply, err := c.Do("MQL", ` select * from /matrix/devops/alert_status`)
- fmt.Printf( fmt.Sprintf("diff ==> %v\n", time.Now().UnixNano()-st) )
- */
- //reply, err := c.Do("PUBLISH", `test`, "hello")
- //reply, err := c.Do("schema", `matrix`, "/matrix/entity/interface")
- //reply, err := c.Do("schema", `matrix`, "/")
- //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<varchar> '开头匹配的JS目录权限',
- pmatch set<varchar> '完全匹配的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<varchar> '权限标签列表',
- 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)
- }
- }
|