Class JoinBinding

java.lang.Object
ai.badmonkey.agentspaces.agent.join.JoinBinding
All Implemented Interfaces:
AutoCloseable

public final class JoinBinding extends Object implements AutoCloseable
The binder's runtime for one @SpaceJoin method (SPEC ยง10.3, issue #16). It owns what a hand-written join owns: a subscription per part, the per-key state of which parts have arrived, the seed of that state from the space on start (and again for any key it meets for the first time, so a key forgotten after within is picked up from what the space still holds), the re-read of the parts by key when a key completes, and the "once" rule of the mode: an in-memory set in SpaceJoin.Mode.LOCAL, a JoinTicket taken under a lease in SpaceJoin.Mode.LEASED, and a ticket taken through the ordered-log coordinator in SpaceJoin.Mode.ORDERED, where the first committed ticket claim per key, as every member sees it in the same order, is the one that fires.

Constructed and started by AgentBinder; the action and the dispatch it is given are the binder's method invocation and return handling, so this class never reflects on the agent itself.

  • Constructor Details

    • JoinBinding

      public JoinBinding(JoinBinding.Config config, Function<Joined,Object> action, Consumer<Object> dispatch, InstantSource clock)
      Parameters:
      config - what the binder resolved from the annotation
      action - invokes the agent's method on the bag and returns its result
      dispatch - the binder's return handling (entry, Tagged, Contribution, null)
      clock - the binder's clock
  • Method Details

    • name

      public String name()
      The join's name, as tickets and the card carry it.
    • start

      public void start()
      Seeds the per-key state from the space, subscribes to every part, and starts the mode's loop.
    • close

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