如何避免在riemann clojure中使用`reinject`?

问题描述 投票:0回答:1

我有黎曼Clojure规则如下

(streams
 (where (service "a")
                #(info "a-" %)
                (moving-event-window 2 (smap folds/sum (with :service "a-derivative" reinject))))
  (where (service "b")
                #(info "b-" %)
                (moving-event-window 3 (smap folds/sum (with :service "b-derivative" reinject))))
 (project [(service "a-derivative") (service "b-derivative")]
          (smap folds/quotient (with :laa "doooo" prn))))

目的是创建 a 的 2 个事件之和并创建

a-derivative
。类似地,服务
b
创建 b 导数。然后我想找到派生事件“a-导数”和“b-导数”的商。

在上面的示例中,重新注入

a-derivative
b-derivative
事件,然后我使用项目获取派生事件来计算商。

riemann的文档来看,我们似乎必须避免

reinject
。如果是这种情况,我们如何避免
reinject
并重写上述规则?

好的,我尝试过的一种方法如下:

(streams
 (pipe -
       (splitp = service
               "a" (moving-event-window 2 (smap folds/sum (with :service "a-derivative" -)))
               "b" (moving-event-window 2 (smap folds/sum (with :service "b-derivative" -)))) 
            
       (sdo #(info "hmm" %)
            (project [(service "a-derivative") (service "b-derivative")]
                     (smap folds/quotient (with :laa "doooo" prn))))
       
       )
 )

而且它有效!但这对吗?

非常感谢您的帮助。

clojure riemann riemann-dashboard
1个回答
0
投票

这看起来是管道的一个很好的用途,也是解决这个问题的好方法。

© www.soinside.com 2019 - 2024. All rights reserved.