如何在Event Store中获取特定类别的预测?

时间:2015-04-21 14:41:46

标签: get-event-store

我在Event Store中进行了以下投影:

fromCategory('Ping')
.foreachStream()
.when({
   $init: function() { 
     return { 
       min: 0,
       max: 0,
       sum: 0,
       cnt: 0
    }; 
   },
   $any: function(s, e) {
      if (s.max < e.body.AcPower) {
        s.max = e.body.AcPower;
      }
      if (s.min > e.body.AcPower) {
        s.min = e.body.AcPower;
      }
      s.sum += e.body.AcPower;
      s.cnt += 1;
      s.avg = s.sum/s.cnt;
   }
});

如何获取特定流的结果? 流Ids是:&#34; Ping-255.1&#34;,&#34; Ping-255.2&#34; ....&#34; Ping-255.1000&#34;

看: http://localhost:2113/projection/stats-cont 我明白了:

{
  "coreProcessingTime": 4072,
  "version": 0,
  "epoch": -1,
  "effectiveName": "stats-cont",
  "writesInProgress": 0,
  "readsInProgress": 0,
  "partitionsCached": 1000,
  "status": "Running",
  "stateReason": "",
  "name": "stats-cont",
  "mode": "Continuous",
  "position": "$ce-Ping: 132233",
  "progress": 100.0,
  "lastCheckpoint": "$ce-Ping: 131999",
  "eventsProcessedAfterRestart": 132234,
  "statusUrl": "http://localhost:2113/projection/stats-cont",
  "stateUrl": "http://localhost:2113/projection/stats-cont/state",
  "resultUrl": "http://localhost:2113/projection/stats-cont/result",
  "queryUrl": "http://localhost:2113/projection/stats-cont/query%3Fconfig=yes",
  "enableCommandUrl": "http://localhost:2113/projection/stats-cont/command/enable",
  "disableCommandUrl": "http://localhost:2113/projection/stats-cont/command/disable",
  "checkpointStatus": "",
  "bufferedEvents": 0,
  "writePendingEventsBeforeCheckpoint": 0,
  "writePendingEventsAfterCheckpoint": 0
}

以下不起作用: http://localhost:2113/projection/stats-cont/state?partition=255.1

提前致谢。

2 个答案:

答案 0 :(得分:2)

我通过调试Event-store找到答案: - )。

分区实际上是带有类别(&#34; Ping-255.1&#34;)所以获取状态投影状态的真实URL是: http://localhost:2113/projection/stats-cont/state?partition=Ping-255.1

答案 1 :(得分:0)

在事件存储4.0及更高版本中,启用内置投影的按类别:

;

此示例中的Authorization标头包含默认的admin:changeit credentials。

启用按类别投影时,会为Ping- *事件创建$ ce-Ping流。使用以下URL查看$ ce-Ping流:

http://127.0.0.1:2113/web/index.html#/streams/ $ CE-平