Package com.tnsai.coordination.streaming
Class AgentStreamBridge
java.lang.Object
com.tnsai.coordination.streaming.AgentStreamBridge
- All Implemented Interfaces:
Closeable,AutoCloseable
Bridges streaming channels between agents for push-based inter-agent communication.
Provides named channels that agents can publish to and subscribe from.
Example usage:
AgentStreamBridge bridge = new AgentStreamBridge();
// Agent A publishes data
StreamingChannel<String> channel = bridge.createChannel("analysis-results", String.class);
channel.emit("partial result 1");
channel.emit("partial result 2");
channel.complete();
// Agent B consumes data
bridge.subscribe("analysis-results", String.class, chunk -> agentB.processChunk(chunk));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of active channels.Returns all channel names.voidclose()<T> StreamingChannel<T> createChannel(String name, Class<T> type) Creates a named streaming channel.<T> StreamingChannel<T> createChannel(String name, Class<T> type, int bufferSize, BackpressureStrategy backpressure) Creates a named streaming channel with custom settings.<T> StreamingChannel<T> getChannel(String name, Class<T> type) Gets an existing channel by name.booleanisClosed()voidremoveChannel(String name) Removes and closes a channel.<T> voidSubscribes a consumer to a named channel.
-
Constructor Details
-
AgentStreamBridge
public AgentStreamBridge()
-
-
Method Details
-
createChannel
Creates a named streaming channel.- Parameters:
name- the channel nametype- the value type class- Returns:
- the created channel
-
createChannel
public <T> StreamingChannel<T> createChannel(String name, Class<T> type, int bufferSize, BackpressureStrategy backpressure) Creates a named streaming channel with custom settings. -
getChannel
Gets an existing channel by name. -
subscribe
Subscribes a consumer to a named channel. -
channelNames
Returns all channel names. -
channelCount
public int channelCount()Returns the number of active channels. -
removeChannel
Removes and closes a channel. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isClosed
public boolean isClosed()
-