resgateio/resgate

Static resource type

Closed this issue · 3 comments

Issue

A static resource type should be added that allows arbitrary structures of JSON to be passed to the client.

The type will have no events describing mutations. It can be used for data which does not change, or data which the client should not be notified of changes.

Implementation

Service get response

The response to a get request follows the same pattern as for model resources, but with the parameter key "static".

It may look like this:

{
    "result": {
        "static": { "foo": { "bar": [ null ] }, "int": 42 }
    }
}

Client get response

The response follows the same pattern, but the resource set will have an additional optional field, "statics":

{
    "result": {
        "statics": {
            "example.static": { "foo": { "bar": [ null ] }, "int": 42 }
        }
    }
}

Notes

  • static resources have no modifying events (such as change/add/remove)
  • static resources may have any JSON value, including nested objects and arrays, without limitation
  • static resources cannot have resource references
  • static resources are cacheable by Resgate
  • system.reset events will invalidate cached static resources, but will not trigger any event to the clients.
  • static resources may have custom events
  • For clients only supporting protocol <= v1.2.0, the static resource should be replaced by an error by Resgate.

Resolved in #164

Reopen after reverting the merge.

The revert was made as the feature added too much complexity to the protocol in comparison to what it solved. A less complex solution that solves the same need for arbitrary data, is tried out in the data value feature.

Closing as a static resource type will not be the solution for the problem.