Backwards compatibility for table() and view() #1384
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1289 was a breaking change for the Perspective API, as it made Table and View constructors
async
by returning aPromise
to the Table or View instance instead of the instance itself. Internally, the constructors would wait on the server (across the websocket or a web worker) to return a message that signaled successful Table/View creation. However, when running a Perspective client that is newer than the Perspective server, older versions of the server (i.e. all released versions right now, as the async table/view changes are not in a tagged release yet) will not return the acknowledgement message and thus Table and View constructors will block forever.To maintain backwards compatibility, this PR adds a simple feature flag implementation on both the client and server, which allows newer versions of Perspective to run against older versions on the server. In the
init
message used to begin client/server communication, the server returns an array of strings that represent enabled features, and the client will use those flags to determine its behaviour.Currently, only one flag (
wait_for_response
) is implemented - if the flag is present, then the Table and View constructors will wait for an acknowledgement message from the server. If the flag is not present, or if there are no feature flags at all, then the constructors willresolve()
immediately, thus preserving compatible behaviour between different versions.