Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KVRouter特性说明 #20

Open
hawkwithwind opened this issue Apr 18, 2019 · 0 comments
Open

KVRouter特性说明 #20

hawkwithwind opened this issue Apr 18, 2019 · 0 comments

Comments

@hawkwithwind
Copy link
Owner

KVRouter

{"path1" {
"regex11" : "filter1",
"regex21": "filter2"
}, "path2": {
"regex21": "filter3"
}, ... }
  • 匹配逻辑
filter收集到msg后,预期其为json结构的字符串,将其解析成对象。
      之后循环对每一个path 进行
              取出该jsonpath(不支持数组,可以支持对象属性)的值
              循环对该path下每个regex
                      做正则匹配,如果匹配上,则
                             调用指定filter

一个消息可以循环匹配多次,对多个path和path内的多个正则,都可触发指定filter

如果一次都没匹配到,且默认的default next filter不为空,则触发默认下级filter
  • 举例

msg如下

{
"groupId": "",
"fromUser": "wxid_111",
"content": "hi"
}

filter设置如下

{"groupId": {
"": "4704034b-b2cf-4daa-8912-7bd34c87a416"
}, "fromUser" : {
"wxid_111" : "4704034b-b2cf-4daa-8912-7bd34c87a416"
}, "content": {
"i" : "4704034b-b2cf-4daa-8912-7bd34c87a416"
}}

匹配命中如下

[FILTER DEBUG][测试KVRouter_with_regex][content][i] filled
[FILTER DEBUG][测试KVRouter_with_regex][groupId][] filled
[FILTER DEBUG][测试KVRouter_with_regex][fromUser][wxid_111] filled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant