本文整理汇总了Golang中github.com/graphite-ng/carbon-relay-ng/table.Table.AddRoute方法的典型用法代码示例。如果您正苦于以下问题:Golang Table.AddRoute方法的具体用法?Golang Table.AddRoute怎么用?Golang Table.AddRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/graphite-ng/carbon-relay-ng/table.Table
的用法示例。
在下文中一共展示了Table.AddRoute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: readAddRouteConsistentHashing
func readAddRouteConsistentHashing(s *toki.Scanner, table *tbl.Table) error {
t := s.Next()
if t.Token != word {
return errFmtAddRoute
}
key := string(t.Value)
prefix, sub, regex, err := readRouteOpts(s)
if err != nil {
return err
}
destinations, err := readDestinations(s, table, false)
if err != nil {
return err
}
if len(destinations) < 2 {
return fmt.Errorf("must get at least 2 destination for route '%s'", key)
}
route, err := route.NewConsistentHashing(key, prefix, sub, regex, destinations)
if err != nil {
return err
}
table.AddRoute(route)
return nil
}
示例2: readAddRoute
func readAddRoute(s *toki.Scanner, table *tbl.Table, constructor func(key, prefix, sub, regex string, destinations []*destination.Destination) (route.Route, error)) error {
t := s.Next()
if t.Token != word {
return errFmtAddRoute
}
key := string(t.Value)
prefix, sub, regex, err := readRouteOpts(s)
if err != nil {
return err
}
destinations, err := readDestinations(s, table, true)
if err != nil {
return err
}
if len(destinations) == 0 {
return fmt.Errorf("must get at least 1 destination for route '%s'", key)
}
route, err := constructor(key, prefix, sub, regex, destinations)
if err != nil {
return err
}
table.AddRoute(route)
return nil
}
示例3: readAddRouteGrafanaNet
func readAddRouteGrafanaNet(s *toki.Scanner, table *tbl.Table) error {
t := s.Next()
if t.Token != word {
return errFmtAddRouteGrafanaNet
}
key := string(t.Value)
prefix, sub, regex, err := readRouteOpts(s)
if err != nil {
return err
}
t = s.Next()
if t.Token != word {
return errFmtAddRouteGrafanaNet
}
addr := string(t.Value)
t = s.Next()
if t.Token != word {
return errFmtAddRouteGrafanaNet
}
apiKey := string(t.Value)
t = s.Next()
if t.Token != word {
return errFmtAddRouteGrafanaNet
}
schemasFile := string(t.Value)
t = s.Next()
var spool bool
sslVerify := true
var bufSize = int(1e7) // since a message is typically around 100B this is 1GB
var flushMaxNum = 10000 // number of metrics
var flushMaxWait = 500 // in ms
var timeout = 2000 // in ms
for ; t.Token != toki.EOF; t = s.Next() {
switch t.Token {
case optSpool:
t = s.Next()
if t.Token == optTrue || t.Token == optFalse {
spool, err = strconv.ParseBool(string(t.Value))
if err != nil {
return err
}
} else {
return errFmtAddRouteGrafanaNet
}
case optBufSize:
t = s.Next()
if t.Token == num {
bufSize, err = strconv.Atoi(strings.TrimSpace(string(t.Value)))
if err != nil {
return err
}
} else {
return errFmtAddRouteGrafanaNet
}
case optFlushMaxNum:
t = s.Next()
if t.Token == num {
flushMaxNum, err = strconv.Atoi(strings.TrimSpace(string(t.Value)))
if err != nil {
return err
}
} else {
return errFmtAddRouteGrafanaNet
}
case optFlushMaxWait:
t = s.Next()
if t.Token == num {
flushMaxWait, err = strconv.Atoi(strings.TrimSpace(string(t.Value)))
if err != nil {
return err
}
} else {
return errFmtAddRouteGrafanaNet
}
case optTimeout:
t = s.Next()
if t.Token == num {
timeout, err = strconv.Atoi(strings.TrimSpace(string(t.Value)))
if err != nil {
return err
}
} else {
return errFmtAddRouteGrafanaNet
}
case optSSLVerify:
t = s.Next()
if t.Token == optTrue || t.Token == optFalse {
sslVerify, err = strconv.ParseBool(string(t.Value))
if err != nil {
return err
}
} else {
return errFmtAddRouteGrafanaNet
}
//.........这里部分代码省略.........