Skip to content

Commit

Permalink
rfc42: add credit based flow control (write direction)
Browse files Browse the repository at this point in the history
Problem: rfc42 does not specify anything about channel flow control,
so it is difficult to design clients and servers that operate without
dropping data.

Add credit based flow control to the protocol in the write direction.

The client receives credit for writes to the subprocess via the
exec add-credit response.
  • Loading branch information
garlick committed Oct 15, 2024
1 parent 7eb2664 commit c267181
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec_42.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Goals

- Optionally forward additional I/O channels.

- Provide flow control on channels.

- Provide signal delivery capability.

- Protect against unauthorized use.
Expand Down Expand Up @@ -121,6 +123,10 @@ are defined as follows:
channel (4)
Forward auxiliary channel output to the client.

write-credit (8)
Send ``add-credit`` exec responses when buffer space is available
for standard input or writable auxiliary channels.

Several response types are distinguished by the type key:

.. object:: exec started response
Expand Down Expand Up @@ -179,6 +185,25 @@ Several response types are distinguished by the type key:

See `I/O Object`_ below.

.. object:: exec add-credit response

The subprocess server has more buffer space available to receive data
on the specified channel. The response SHALL consist of a JSON object
with the following keys:

.. object:: type

(*string*, REQUIRED) The response type with a value of ``add-credit``.

.. object:: channels

(*object*, REQUIRED) An object with channel names as keys and
integer credit counts as values.

The server's initial response contains the full buffer size(s).

These messages are suppressed if the write-credit flag was not specified.

.. object:: exec error response

The :program:`exec` response stream SHALL be terminated by an error
Expand All @@ -201,6 +226,12 @@ The :program:`write` RPC sends data to an I/O channel of a remote process.
Valid I/O channel names MAY include ``stdin`` and auxiliary channel names
specified in the exec request command object.

A client MAY avoid overrunning the remote buffer by monitoring
:program:`exec add-credit` responses and keeping a running total of
available remote buffer space, subtracting the size of the decoded data
contained with in the I/O object each time a :program:`write` request is sent,
and never allowing the running total to become negative.

.. object:: write request

The request SHALL consist of a JSON object with the following keys:
Expand Down

0 comments on commit c267181

Please sign in to comment.