Class WebServiceExecutor

java.lang.Object
com.tnsai.actions.executors.WebServiceExecutor
All Implemented Interfaces:
TypedActionExecutor

public class WebServiceExecutor extends Object implements TypedActionExecutor
Executor for WEB_SERVICE actions. Makes HTTP API calls based on @WebService annotation metadata.

Idempotency (issue #91 phase 2)

Actions whose method (or declaring class) carries Idempotent are routed through IdempotencyResolver before the HTTP request is sent: cache hits short-circuit the call, and on a miss the framework injects an Idempotency-Key header on the request — the same header Stripe, SendGrid, Twilio, GitHub Issues, etc. honour for upstream-side dedup. Tools without @Idempotent bypass the resolver entirely (zero overhead).

The header is only injected on POST, PUT, PATCH, and DELETE — the methods where duplicate calls have observable side-effects. GET, HEAD, and OPTIONS are safe by definition; injecting the header would be cosmetic noise. The same client-side cache still applies to those methods (a cached response can short-circuit them too).

For KeyStrategy.EXPLICIT, the Role can implement IdempotencyKeySupplier to supply its own key — same mechanism as @Tool-annotated POJOs in ToolMethodDispatcher. EXPLICIT suppliers must be deterministic: the framework calls the supplier twice per call (once for the header, once for the cache lookup).

  • Constructor Details

    • WebServiceExecutor

      public WebServiceExecutor()
    • WebServiceExecutor

      public WebServiceExecutor(IdempotencyStore idempotencyStore)
      Constructor with explicit IdempotencyStore. Use to wire a Redis / Postgres adapter (when those land) or to share one store instance across multiple executors / agents in the same process.
      Parameters:
      idempotencyStore - store consulted for Idempotent actions; pass InMemoryIdempotencyStore for the default per-process behaviour
      Since:
      0.8.6 (issue #91 phase 2)
  • Method Details

    • idempotencyStore

      public IdempotencyStore idempotencyStore()
      Returns:
      the IdempotencyStore consulted for Idempotent actions. Useful for tests that need to inspect or pre-populate the cache.
      Since:
      0.8.6 (issue #91 phase 2)
    • execute

      public Object execute(ActionMetadata action, Role role, Map<String,Object> parameters, Map<String,Object> context)
      Description copied from interface: TypedActionExecutor
      Executes an action with the given parameters and context.
      Specified by:
      execute in interface TypedActionExecutor
      Parameters:
      action - The action metadata containing annotation details
      role - The role instance that contains the method
      parameters - The parameters for the action (from message or executeAction call)
      context - Additional context (e.g., LLM client reference, agent reference)
      Returns:
      The execution result