Package com.axelor.ai.chat.stream
Class BufferStreamWriter
java.lang.Object
com.axelor.ai.chat.stream.StreamWriter
com.axelor.ai.chat.stream.BufferStreamWriter
- All Implemented Interfaces:
AutoCloseable
A
StreamWriter that appends serialized SSE frames to an ActiveStream instead of a
socket. Never fails on client disconnects — delivery is the subscribers' concern — so the agentic
loop always runs to completion.
StreamEvent.Error and StreamEvent.Abort mark the stream terminating first so
the error path is exempt from the buffer size cap.
-
Field Summary
Fields inherited from class com.axelor.ai.chat.stream.StreamWriter
HEADER_NAME, HEADER_VALUE, NOTIFY_MAX_STEPS -
Constructor Summary
ConstructorsConstructorDescriptionBufferStreamWriter(ActiveStream stream, com.fasterxml.jackson.databind.ObjectMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voiddone()Writes thedata: [DONE]\n\nterminator and flushes.voidwrite(StreamEvent event) Serializes the event asdata: {json}\n\nand flushes.Methods inherited from class com.axelor.ai.chat.stream.StreamWriter
clearNotify, notify, notify
-
Constructor Details
-
BufferStreamWriter
-
-
Method Details
-
write
Description copied from class:StreamWriterSerializes the event asdata: {json}\n\nand flushes.- Overrides:
writein classStreamWriter- Throws:
IOException
-
done
public void done()Description copied from class:StreamWriterWrites thedata: [DONE]\n\nterminator and flushes. Must be the last write.- Overrides:
donein classStreamWriter
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classStreamWriter
-