本文整理匯總了Golang中github.com/flike/kingshard/config.ParseConfigData函數的典型用法代碼示例。如果您正苦於以下問題:Golang ParseConfigData函數的具體用法?Golang ParseConfigData怎麽用?Golang ParseConfigData使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ParseConfigData函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newTestRouter
func newTestRouter() *Router {
var s = `
schema :
db : kingshard
nodes: [node1,node2,node3,node4,node5,node6,node7,node8,node9,node10]
default: node1
shard:
-
table: test1
key: id
nodes: [node1,node2,node3]
locations: [4,4,4]
type: hash
-
table: test2
key: id
type: range
nodes: [node1,node2,node3]
locations: [4,4,4]
table_row_limit: 10000
-
table: test_shard_year
key: date
nodes: [node2, node3]
date_range: [2012-2015,2016-2018]
type: date_year
-
table: test_shard_month
key: date
type: date_month
nodes: [node2, node3]
date_range: [201512-201603,201604-201608]
-
table: test_shard_day
key: date
type: date_day
nodes: [node2, node3]
date_range: [20151201-20160122,20160202-20160308]
`
cfg, err := config.ParseConfigData([]byte(s))
if err != nil {
println(err.Error())
panic(err)
}
var r *Router
r, err = NewRouter(&cfg.Schema)
if err != nil {
println(err.Error())
panic(err)
}
return r
}
示例2: newTestDBRule
func newTestDBRule() *Router {
var s = `
schema :
db : kingshard
nodes: [node1,node2,node3,node4,node5,node6,node7,node8,node9,node10]
default: node1
shard:
-
table: test1
key: id
nodes: [node1,node2,node3]
locations: [1,2,3]
type: hash
-
table: test2
key: id
type: range
nodes: [node1,node2,node3]
locations: [8,8,8]
table_row_limit: 100
-
table: test3
key: recdate
type: sep_range
nodes: [node1,node2,node3]
locations: [2,2,2]
seps: [2015-01-01, 2015-02-01, 2015-03-01, 2015-04-01, 2015-05-01]
key_type: string
`
cfg, err := config.ParseConfigData([]byte(s))
if err != nil {
println(err.Error())
panic(err)
}
var r *Router
r, err = NewRouter(&cfg.Schema)
if err != nil {
println(err.Error())
panic(err)
}
return r
}
示例3: newTestRouter
func newTestRouter() *Router {
var s = `
schemas :
-
db : kingshard
nodes: [node1,node2,node3,node4,node5,node6,node7,node8,node9,node10]
rules:
default: node1
shard:
-
table: test1
key: id
nodes: [node1,node2,node3]
locations: [4,4,4]
type: hash
-
table: test2
key: id
type: range
nodes: [node1,node2,node3]
locations: [4,4,4]
table_row_limit: 10000
`
cfg, err := config.ParseConfigData([]byte(s))
if err != nil {
println(err.Error())
panic(err)
}
var r *Router
r, err = NewRouter(&cfg.Schemas[0])
if err != nil {
println(err.Error())
panic(err)
}
return r
}
示例4: newTestServer
func newTestServer(t *testing.T) *Server {
f := func() {
cfg, err := config.ParseConfigData(testConfigData)
if err != nil {
t.Fatal(err.Error())
}
testServer, err = NewServer(cfg)
if err != nil {
t.Fatal(err)
}
go testServer.Run()
time.Sleep(1 * time.Second)
}
testServerOnce.Do(f)
return testServer
}