Transferring nodes between instances
Eventually fixes #403.
This MR makes possible sending nodes over the wire from an instance A
to an instance B
. This MR introduces two new endpoints:
/api/v1.0/remote/export
/api/v1.0/remote/import
The idea is that users willing to transfer a node from A
to B
have to be logged on both instances. Then, they would issue a request to /api/v1.0/remote/export
specifying the id
of the node, the BaseUrl
of the target instance and the JWT token to authenticated against instance B
. Both the instance URL and the token would be in scope in the frontend, as the latter has to manage logins between instances.
Under the hood, the backend of node A
would call the /import
endpoint on node B
, which would proceed transferring the node.
At the moment there are several limitations:
- We support sending only one node at the time, but that's not very useful, because a node might have children, so we need to figure out, from
A
, the recursive list of children and stream all of that; - We don't efficiently deserialise and stream the results into the DB code that inserts them, there is support but is currently not leveraged, maybe that's for a follow-up MR;
- There is the question about what to do in case of inter-dependencies, but I think that for the initial MR it's enough to pass a tree structure we can use to sequentially insert nodes from the root (which
parentId
would beNothing
) to the last leaf, but I have to yet figure out how to do that properly.