SignalK / specification

Signal K is a JSON-based format for storing and sharing marine data from different sources (e.g. nmea 0183, 2000, seatalk, etc)
Other
91 stars 68 forks source link

"no timeout" in meta #647

Closed godind closed 6 months ago

godind commented 1 year ago

Timeout being potentially a critical meta value, we need a way to enforce 'no timeout'.

Current State

Proposition

Have Timeout key with value of 0 timeout: 0 interpreted as 'Infinity/No timeout. Note that values null and undefined have 'special' meanings and can cause trouble.

This would means:

Not only does it make numerical sense, it's also easier the handle and validate with Form Controls and eliminates the need to delete the key to have no expiration.

tkurki commented 1 year ago

What trouble do you see null creating? In general it is a special value that indicates the absence of a real value and as such would be a good fit for this purpose.

godind commented 1 year ago

null and undefined can create unforeseen interpretation side-effect for certain language, framework, libraries, etc. As an example, if you PUT value: undefined against a meta property, the server will deleted the key, but this is actually an unexpected side effect - did we think undefined would delete? Will null do the same thing? I think it's a risk not worth taking... but I'm no expert on the subject.

Back to the proposition at hand; timeout: 0 is a clear and affirmative statement eg. we have a timeout and it's value is never. timeout: null means timeout value has no reference - not as clear a statement, regardless of the fact that the null keyword might be sensitive or not.

The undefined value is a primitive value used when a variable has not been assigned a value. The null value is a primitive value that represents the null, empty, or non-existent reference

tkurki commented 1 year ago
  1. there is no special case undefined: firstly it can not be represented in JSON that most of current SK depends on, secondly a client needs to handle the situation that a meta property is "undefined", which in practise is that it is missing / non existent
  2. null is already used in Signal K and the proposed usage is imho very well in line with that, to me it would seeing a null value would be "timeout is explicitly missing, not just absent in the data, so don't apply a timeout for this path"
  3. Imho zero value has actually more potential for unforeseen interpretation side-effects (example: if I just blindly apply the timeout 0 can easily mean that a value is timed out immediately). This needs documentation and taken into account in implementation in any case.

PS. I edited the title so that it describes the use case instead of prescribing a solution.

godind commented 1 year ago

Make sense. Thanks!

godind commented 1 year ago

@tkurki Question: do you think anything needs to be modified in SK to use null string as a value, or could this cause issue with the current implementation?

godind commented 6 months ago

Not pertinent anymore.