Class AgentStreamBridge

java.lang.Object
com.tnsai.coordination.streaming.AgentStreamBridge
All Implemented Interfaces:
Closeable, AutoCloseable

public final class AgentStreamBridge extends Object implements Closeable
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 Details

    • AgentStreamBridge

      public AgentStreamBridge()
  • Method Details

    • createChannel

      public <T> StreamingChannel<T> createChannel(String name, Class<T> type)
      Creates a named streaming channel.
      Parameters:
      name - the channel name
      type - 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

      public <T> StreamingChannel<T> getChannel(String name, Class<T> type)
      Gets an existing channel by name.
    • subscribe

      public <T> void subscribe(String channelName, Class<T> type, Consumer<T> consumer)
      Subscribes a consumer to a named channel.
    • channelNames

      public Set<String> channelNames()
      Returns all channel names.
    • channelCount

      public int channelCount()
      Returns the number of active channels.
    • removeChannel

      public void removeChannel(String name)
      Removes and closes a channel.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isClosed

      public boolean isClosed()