kuzzleio/koncorde

Add a new matcher allowing to notify on datetime values

Closed this issue · 0 comments

Proposed syntax:

{
  "timerange": {
    "[document field]": {
      "after": xxx,
      "before": xxx,
    }
  }
}

With xxx allowing the following formats on subscriptions:

  • (integer) epoch timestamp
  • (integer) epoch-millis timestamp
  • (string) ISO-8601 datetimes (w/ timezone)
  • (string) This regex: /^now\s*[-+]\s*[0-9]+\s*(s|m|h)$/ (e.g. now - 20 m, now+2h

Caveats:

  • tested fields can only be in the following formats: integer (epoch or epoch-millis), string (ISO-8601). For performance reasons, we should limit the number of available formats. And we'll have to write a super-fast ISO-8601 parser (I don't know if one is already available on NPM)
  • we'll have to handle timezones.
  • we should allow exactly 1 "after", or exactly 1 "before", or exactly 1 of both. For the latter case, the subscription procedure should check that the "before" value is lower than the "after" one
  • for performance reasons, the check on the "now" value will have a precision of roughly 1 second. This'll allow us to update an internal "now" value every second, and using it in the new timerange matcher, drastically reducing the overhead on that keyword compared to getting a new Date.now() value everytime a document is tested (which can be done, hundred of times per second, and maybe more if we do things right)