123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package odbclient
- import (
- "fmt"
- "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")
- var odbcfg *odb.Config
- func init() {
- odbpath := cfg.GetStrings("ODBPATH", "127.0.0.1:11001")
- keyspace := cfg.GetString("KEYSPACE", "oktest")
- poolsize := cfg.GetInt("Poolsize", 10)
- 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,
- }
- }
- 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
- }
|