Abort is not implemented
The SPOE specification defines an "Abort" flag on the metadata field as:
ABORT: Indicates that the processing of the current frame must be
cancelled. This bit should be set on frames with a fragmented
payload. It can be ignore for frames with an unfragemnted
payload. When it is set, the FIN bit must also be set.
This is not yet implemented in this library.
Spec is not clear if both HaProxy and Agent can send Abort.
If Haproxy send a abort frame, the current fragmented buffer should be discard.
Current HandleStream implementation cannot be stopped. If it were possible, i think of two possibles cases before sending Disconnect frame (again not clear in the spec) :
- Agent should send abort frame for any existing fragments in the catalog, to tell Haproxy that frame being sent to the agent will not be processed.
- If agent was sending a fragmented frame, it may send an abort frame, to tell Haproxy that it will not send the complete frame.
SetVariable data type are synchronous, if the binary one was read from a stream while sending the fragment frame and the stream failed, agent may send an abort frame.
Do you have a better understanding of the spec and possible evolution ?
I agree, the spec is not clear about whether an agent can send an Abort. It only shows an example of a Notify frame from HAProxy aborting, so I think that's all that can be implemented for now. I have accepted your pull request, thanks!
Looking at the spec again, there is an example of the agent aborting incoming fragments from HAProxy:
* Aborted fragmentation of a NOTIFY frame:
HAPROXY AGENT SRV
| ... |
| UNSET (frag X) |
| --------------------------> |
| |
| ACK/ABORT |
| <-------------------------- |
| |
| UNSET (frag X+1) |
| -----------X |
| |
| |
I think this could happen if the agent code "cancels" the stream. This might be implemented as a side effect of cancelling the stream (related to #2) if there are unprocessed UNSET frames and the FIN flag has not been received yet.
It looks like the agent should send an ACK frame with the ABORT flag set to tell HAProxy that the agent wants to stop receiving UNSET frames when the payload is fragmented. I suppose the user would determine when to do this, and would need a function that sets this in motion, possibly a delegate that's passed into HandleStream, where some logic is checked to know whether to abort.
It might even be beneficial to leave this unimplemented until someone with a real use case chimes in.