-
Notifications
You must be signed in to change notification settings - Fork 13
multipart messages
New meta key part
will be introduced in RpcResponse. RpcResponse without part
key is considered to be the final one. This is aligned with single-part messages, which currently have not a part
key.
Second possibility is to consider message to be multipart part == true
, if rcid
key is present in meta-data. When this approach will be used, then rcid
must be always used when inner parts will be transferred, what can lead to simpler client implementation because there will not be any need to store rcid
received in first response to have opportunity to cancel whole transfer.
RpcMessage body IMap keys will be extended by following keys:
-
chunk
- optional, ifchunk
key is received, thenresult
should be appended to result of previous chunks-
String
,Blob
will be concatenated -
List
will be appended -
Map
will be merged
-
-
progress
- optional, IMap with following keys:-
index
- index of current part<0, count)
-
count
- part count message
-
Both sides of multi-part session can cancel it sending a message with part == false
.
Also sender can cancel whole transfer, if it will send RpcResponse with error
set
What multipart messages can be good for:
- transfer big file in N chunks with progress
- keep caller informed about progress of very long time lasting RPC call
- cancel long lasting RPC call by caller
- tunneling
case | msg | rcid | part | method | param | result | error |
---|---|---|---|---|---|---|---|
send large file | RQ | x | setFile | file-name, chunk-1 | |||
_ | RESP | x | x | null | |||
_ | CRESP-x | x | chunk-x | ||||
_ | CRESP-N | chunk-N | |||||
get large file | RQ | getFile | file-name | ||||
_ | RESP-1 | x | x | chunk-1 | |||
_ | RESP-x | x | x | chunk-x | |||
_ | RESP-N | x | chunk-N | ||||
rpc wit progress | RQ | primeNumber | 1E+28 | ||||
_ | RESP-1 | x | x | chunk-1 | |||
_ | RESP-x | x | x | chunk-x | |||
_ | RESP-N | x | chunk-N | ||||
tunnel | RQ | openTunnel | null | ||||
_ | RESP | x | x | data | |||
_ | CRESP-x | x | data | ||||
_ | RESP-x | x | x | data | |||
_ | RESP-N | x | data | ||||
_ | CRESP-N | data |
- client issue
getFile()
rqId = RQID
- File device will split file content to N chunks
- N RpcResponses will be sent back to client
- every response will have
rqId == RQID
- first N-1 responses will be sent with
part==true
in metadata andchunk == true
+result == BLOB_DATA_n
in response body - N-th response will be sent with
part == false
in metadata andchunk == true
+result == BLOB_DATA_n
in response body
- every response will have
- client issue
sendFile()
withrqId == RQID
+rcid == null
+part == true
key set in metadata. - device responses with some
result
and wait for more messages withrqId == RQID
, client will takercid
list from response, we will call itRCID
- Client will split file content to N chunks
- N RpcResponses will be sent back to device
- every response will have
rqId == RQID
+cid == RCID
- first N-1 responses will be sent with
part==true
in metadata andchunk == true
+result == BLOB_DATA_n
in response - N-th response will be sent with
part == false
in metadata andchunk == true
+result == BLOB_DATA_n
in response data
- every response will have
- client issue
heavyComputation()
withrqId = RQID
- N RpcResponses will be sent back to client
- every response will have
rqId == RQID
+rcid
set to enable RPC call cancellation - first N-1 responses will be sent with
part==true
in metadata andprogress: i{...}
+result == null
in response body - N-th response will be sent with
part == false
in metadata andresult == 42
in response data
- every response will have
- client calls
openTunnel()
withrqId == RQID
+rcid == null
+part == true
key set in metadata. - device will save first message
cid
asCID
- Device responses with some
result
and wait for more messages withrqId == RQID
, client will takercid
list from response, we will call itRCID
- Client will send any data to its tunnel end as Rpcresponse with
rqId == RQID
+cid == RCID
- Device will send any data to its tunnel end as Rpcresponse with
rqId == RQID
+cid == CID
- Tunnel is closed if
- Client or device send RpcResponse with
part = false
- Client or device send RpcResponse with