websocket docs

This commit is contained in:
Ben Irvin 2023-06-26 13:56:12 +02:00
parent e7e225ba5f
commit cb4126a9e8
2 changed files with 33 additions and 9 deletions

View File

@ -15,3 +15,5 @@ import { useCurrentSidebarCategory } from '@docusaurus/theme-common';
<DocCardList items={useCurrentSidebarCategory().items} />
```
Note: The data-transfer package is written in Typescript and any additions or changes must include all necessary typings.

View File

@ -14,23 +14,45 @@ Opening a websocket connection on those routes requires a valid transfer token a
Please see the `bootstrap()` method of the remote providers for an example of how to make the initial connection to the Strapi websocket.
## Websocket Messages
## Websocket Messages / Dispatcher
After connecting to the websocket.
The remote websocket server only accepts specific websocket messages which we call transfer commands. These commands must also be sent in a specific order, and an error messages will be returned if an unexpected message is received by the server.
### Initialization Messages
A message dispatcher object should be created to send messages to the server. See `packages/core/data-transfer/src/strapi/providers/utils.ts` for more inofrmation on the dispatcher.
** TODO **
The dispatcher includes
### Pull Messages
### dispatchCommand
** TODO **
Accepts "commands" used for opening and closing a transfer.
### Push Messages
Allows the following `command` values:
** TODO **
- `init`: for initializing a connection. Returns a transferID that must be sent with all future messages in this transfer
- `end`: for ending a connection
See `packages/core/data-transfer/dist/strapi/remote/handlers/push.d.ts` and `packages/core/data-transfer/dist/strapi/remote/handlers/push.d.ts`
### dispatchTransferStep
Used for switching between stages of a transfer and streaming the actual data of a transfer.
Accepts the following `action` values:
- `start`: sent with a `step` value for the name of the step/stage
- any number of `stream`: sent with a `step` value and the `data` being sent (ie, an entity)
- `end`: sent with a `step` value for the step being ended
### dispatchTransferAction
Used for triggering 'actions' on the server equivalent to the local providers.
- `bootstrap`
- `getMetadata`
- `beforeTransfer`
- `getSchemas`
- `rollback` (destination only)
- `close`: for completing a transfer (but doesn't close the connection)
See `packages/core/data-transfer/dist/strapi/remote/handlers/push.d.ts` and `packages/core/data-transfer/dist/strapi/remote/handlers/push.d.ts` for complete and precise definitions of the messages that must be sent.
## Message Timeouts and Retries