Class InProcessEventPublisher

java.lang.Object
at.aimon.session.web.internal.InProcessEventPublisher
All Implemented Interfaces:
AutoCloseable

public final class InProcessEventPublisher extends Object implements AutoCloseable
Backing publisher for WebAgentSessionManager.events(ConversationId).

Maintains one SubmissionPublisher per ConversationId, lazily created on first emit or subscribe. Multi-subscriber: every Flow.Subscriber attached to a publisher receives the same event stream.

Producer non-blocking invariant (design §5.5.1): emit(ConversationId, AgentExecutionEvent) must never block the turn thread. We use SubmissionPublisher.offer(item, 0L, NANOS, onDrop) so demand-saturated subscribers cause oldest events to be dropped rather than parking the producer.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    complete(at.aimon.core.agent.conversation.ConversationId id)
    Emit onComplete() on the publisher for id and remove it from the map.
    void
    emit(at.aimon.core.agent.conversation.ConversationId id, at.aimon.core.agent.stream.AgentExecutionEvent event)
    Push event to subscribers of id's publisher (lazy-creating one if needed).
    Flow.Publisher<at.aimon.core.agent.stream.AgentExecutionEvent>
    publisherFor(at.aimon.core.agent.conversation.ConversationId id)
    Returns the publisher for id, creating one on first use.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InProcessEventPublisher

      public InProcessEventPublisher()
  • Method Details

    • publisherFor

      public Flow.Publisher<at.aimon.core.agent.stream.AgentExecutionEvent> publisherFor(at.aimon.core.agent.conversation.ConversationId id)
      Returns the publisher for id, creating one on first use.
      Parameters:
      id - the conversation (must not be null)
      Returns:
      a non-null publisher
    • emit

      public void emit(at.aimon.core.agent.conversation.ConversationId id, at.aimon.core.agent.stream.AgentExecutionEvent event)
      Push event to subscribers of id's publisher (lazy-creating one if needed).

      Slow subscribers cause the oldest queued event to be dropped — never block the producer.

      Parameters:
      id - the conversation (must not be null)
      event - the event (must not be null)
    • complete

      public void complete(at.aimon.core.agent.conversation.ConversationId id)
      Emit onComplete() on the publisher for id and remove it from the map. Subsequent emit/publisherFor for the same id transparently allocate a fresh publisher.
      Parameters:
      id - the conversation (must not be null)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable