用于获取读取模型列表的 Wolkenkit REST API 确实返回一个心跳条目 [英] Wolkenkit REST API for getting a read model list does return a heartbeat entry

查看:29
本文介绍了用于获取读取模型列表的 Wolkenkit REST API 确实返回一个心跳条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说 wolkenkit 还提供了 REST API,但没有找到任何相关文档.我对来源进行了筛选,并找到了一些有关如何执行此操作的指示.

I heard that wolkenkit also offers a REST API but didn't find any documentation for that. I sifted through the sources and found some indications on how to do this.

我正在使用 HTTPie 来处理来自 cli 的请求:

I am using HTTPie for doing requests from the cli:

$ http post https://local.wolkenkit.io:3500/v1/read/lists/labels

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate
Connection: keep-alive
Date: Wed, 30 Aug 2017 21:08:07 GMT
Expires: 0
Pragma: no-cache
Surrogate-Control: no-store
X-FRAME-OPTIONS: DENY
X-Powered-By: Express
X-XSS-Protection: 1; mode=block
content-type: application/json
transfer-encoding: chunked

{"name":"heartbeat"}
{"label":"first","id":"baa1b2b6-ab85-4929-a488-0cae622de20a","isAuthorized":{"owner":"anonymous","forAuthenticated":false,"forPublic":true}}
{"label":"second","id":"7fc6c3c9-3285-4292-b3db-6d88ca90a347","isAuthorized":{"owner":"anonymous","forAuthenticated":false,"forPublic":true}}

我的 label readModel 中有两个条目,但似乎还有第三个 {"name":"heartbeat"}.这是从哪里来的,是什么意思?

I have two entries in my label readModel, but there appears to be a third one {"name":"heartbeat"}. Where does that come from and what does it mean?

这是一个错误还是我不小心创建了该条目?

Is this a bug or may i have created that entry accidentally?

推荐答案

免责声明:我是 wolkenkit 的开发者之一.

这实际上既不是错误,也不是您无意中创建的条目;-)

This is actually neither a bug, nor did you create the entry accidentally ;-)

在幕后,我们通过 HTTP 流式传输 JSON,我们的经验是,当两个数据包之间的长时间停顿时,某些代理服务器(和类似的东西)会导致问题.

Under the hood we stream JSON over HTTP, and we had the experience that some proxy servers (and similar things) caused issues when there were long pauses between two data packets.

过去我们改变了几次读取模型的交付方式,我认为这真的不是必需的,所以这是过去的保留.(如果说活动路线的话,剧情就不一样了,这里肯定还是需要的.)

In the past we changed the way how the read model is being delivered a few times, and I don't think that this is really still required, so this is a holdover from the past. (If we were talking about the events route, the story would be different, here it is definitely still needed.)

在我们后台使用的库中,json-lines-client,我们过滤掉心跳事件:

In the library that we use under the hood, json-lines-client, we filter out the heartbeat events:

const isNotHeartbeat = function (data) {
  const keys = Object.keys(data);

  return !(
    (keys.length === 1) &&
    (keys[0] === 'name') &&
    (data.name === 'heartbeat')
  );
};

(摘自 json 的源代码线路客户端 0.7.9)

目前,我建议在您的代码中引入类似的逻辑,这样您就可以简单地忽略这些事件(随着时间的推移可能会有多个,并且它们不必是第一个).

For the moment, I'd suggest to introduce a similar logic to your code, so that you simply ignore these events (there may be more than one over time, and they do not need to be the first one).

这篇关于用于获取读取模型列表的 Wolkenkit REST API 确实返回一个心跳条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆