12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package odbc
- import (
- "fmt"
- "runtime"
- "strings"
- ccfg "git.wecise.com/wecise/common/matrix/cfg"
- clog "git.wecise.com/wecise/common/matrix/logger"
- "git.wecise.com/wecise/odb-go/odb"
- "github.com/scylladb/go-set/strset"
- )
- var cfg = ccfg.MConfig()
- var log = clog.New().WithConfig(cfg, "log")
- func init() {
- log.Info("cpu limit", 1)
- runtime.GOMAXPROCS(1)
- }
- var odbcfg *odb.Config
- func init() {
- odbpath := cfg.GetStrings("ODBPATH", "127.0.0.1:11001,47.92.151.165:11001")
- keyspace := cfg.GetString("KEYSPACE", "oktest")
- poolsize := cfg.GetInt("POOLSIZE", 0)
- odbpaths := strset.New()
- for _, p := range odbpath {
- odbpaths.Add(strings.Split(p, ",")...)
- }
- odbcfg = &odb.Config{
- Hosts: odbpaths.List(),
- Keyspace: keyspace,
- User: fmt.Sprint("测试客户端", cfg.GetString("N")),
- Pass: "********",
- PoolSize: poolsize,
- Debug: true,
- }
- }
- func Config() *odb.Config {
- return odbcfg
- }
- func NewClient() (c odb.Client, err error) {
- client, err := odb.NewClient(odbcfg)
- if err != nil {
- return nil, err
- }
- return client, nil
- }
|