Wolkenkit REST API for getting a read model list d

2019-07-05 06:10发布

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.

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}}

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?

1条回答
太酷不给撩
2楼-- · 2019-07-05 06:25

Disclaimer: I am one of the developers of wolkenkit.

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

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.)

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')
  );
};

(Taken from the source code of json-lines-client 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).

查看更多
登录 后发表回答