Eve icon indicating copy to clipboard operation
Eve copied to clipboard

http doesn't repeat a url fetch of the same url

Open hammerandtongs opened this issue 9 years ago • 4 comments

Expectation - this chunk of code retrieves new values every 10 seconds.

search
[#time seconds]
0 = mod[value: seconds, by: 10]

commit @http
[#request #melete-latest url: "http://foo/getlatestevents"]

Actual result - it only runs once and never again.

This worked around the problem (but will fail tomorrow).

search
[#time hours minutes seconds]
0 = mod[value: seconds, by: 10]

commit @http
[#request #melete-latest url: "http://foo/getlatestevents?{{hours}}{{minutes}}{{seconds}}"]

My assumption is that since the request commit was non-unique no further event fired to actually call the url?

This makes sense in eve but I don't think it does when interacting with an api that is going to the outside world.

hammerandtongs avatar Dec 07 '16 05:12 hammerandtongs

Also the requests don't get garbage collected, they seem to just build up over time.

hammerandtongs avatar Dec 07 '16 05:12 hammerandtongs

One work around that wouldn't fail tomorrow would be to use timestamp instead, and do the same thing you did here.

search
  [#time timestamp frames]
  0 = mod[value: timestamp, by: 10 * 1000] // timestamp is in ms

commit @http
  [#request #melete-latest url: "http://foo/getlatestevents?{{timestamp}}"]

I think that works, can't check now since I'm on my phone.

But to address the point, maybe @http needs some logic where a request is deleted after a response is received? I'm afraid I don't know enough about the protocol though to know all of the gotchas involved.

cmontella avatar Dec 07 '16 06:12 cmontella

The database already adds a #sent tag that states it has been seen and actioned by the database. This only happens if the #request and url attribute is present. You can use this or the response attribute that is written to separate the completed requests.

If you inject identity on creation it will run again, and there are various ways to handle both injecting identity and cleaning up the records afterwards if necessary.

Regards, Cormac.

Cormac-Williams avatar Dec 07 '16 09:12 Cormac-Williams

1- So I'd lean towards having the @http tool inject the unique values under the covers, given that http endpoints will almost always have these issues ie the url is static but the data coming from it is changing constantly.

2- The cleanup also seems like something that the api should handle after a configurable amount of time.

I can also see another answer which runs along the lines of this change of behavior would be undesirable because it's different from other parts of eve.

It seems like this exact issue will come up with something like a call to a sql database, so it seems a more general pattern for these issues will need to be laid out or at least clearly documented api by api.

Thank you for the workaround advice, I'll probably try to garbage collect and work the timestamp in tonight.

hammerandtongs avatar Dec 07 '16 22:12 hammerandtongs