Пример #1
0
func GetRule(name string) (cfg.Rule, error) {
	if name == "" {
		return cfg.Rule{}, errors.New("Please specify a name")
	}

	return routerzk.GetRule(zkConn.Conn, name)
}
Пример #2
0
func ParseRule(name string) (Rule, error) {
	var res Rule
	data, err := zk.GetRule(Zk, name)
	if err != nil {
		return res, err
	}
	return Rule{data.Type, data.Value, data.Next, data.Pool}, nil
}
Пример #3
0
func (e *GetRuleExecutor) Execute(t *Task) (err error) {
	if e.arg.Name == "" {
		return errors.New("Please specify a name")
	}
	helper.SetRouterRoot(e.arg.Internal)
	e.reply.Rule, err = routerzk.GetRule(datamodel.Zk.Conn, e.arg.Name)
	if err != nil {
		e.reply.Status = StatusError
	} else {
		e.reply.Status = StatusOk
	}
	return err
}