resgateio/resgate

Props field on change event

Closed this issue · 2 comments

Issue

Model change events, as defined in RES-service specification V1.0, gives no opportunity to include meta data in the event. This is a design flaw which prevents the specification to adapt to requests such as version numbering of resources.

Since the number of Resgate deployments are still limited, this issue should be addressed, and a new specification version (v1.1) should be created.

Solution

Update specification to have the changed properties in a props field:

v1.0 model change event payload:

{
   "foo": "bar",
   "faz": 42
}

v1.1 model change event payload:

{
   "props": {
      "foo": "bar",
      "faz": 42
   }
}

Implementation

Resgate should detect legacy behaviour and handle it, while logging a Deprecated warning.
A change event payload is considered legacy behaviour unless all statements below are true:

  • payload contains a property called props
  • payload contains only a single property
  • value for props is an object

The only time a v1.0 service might be mistakenly taken as non-legacy (v.1.1), is for the following two payloads:

{
    "props": { "rid": "example.model" }
}

or

{
   "props": { "action": "delete" }
}

The chances of anyone being affected by this is minimal.

Renamed props to values to match that of RES-client protocol.

Fixed in #70