Как создать обратный звонок в Groovy - PullRequest
0 голосов
/ 21 марта 2020

Я разрабатываю DSL с groovy, который позволяет изучать данные, поступающие из тем Кафки, мой DSL выглядит так

study(timestamp,region){
    content {
        // in the block content I can declare several variables which are then used in the block where
        data1 = topic(“topic1”) // the topic method allows you to subscribe to the topic with the name "topic1"
        data2 = topic(“topic2”) // the topic method allows you to subscribe to the topic with the name "topic2"
            }
    where {
           // define predicates on the data such as 'in', '> =', '<=', '==', etc.
           data1["timestamp"] == timestamp AND data2["region"] == region
         }
    then {
          // make actions when the block where return true
         }
}

Моя проблема заключается в том, как выполнить блок, где каждый раз, когда я получаю новые данные из kafka и как использовать переменные, определенные в области содержимого замыкания, в блоке, где, например, переменная data1 определена в содержимом замыкания, так как я могу использовать ее в блоке where.

...