Class ConnectorApiKeyContext

java.lang.Object
ai.pipestream.connector.ConnectorApiKeyContext

public final class ConnectorApiKeyContext extends Object
Holds the connector call credentials captured from gRPC metadata by ConnectorApiKeyInterceptor, exposing them to the handler thread.

Consolidates the per-connector GrpcRequestContext classes. Credentials enter only via gRPC metadata (x-api-key / x-datasource-id) — never a protobuf body field — matching the platform's api-key-in-metadata convention.

  • Method Details

    • apiKey

      public static String apiKey()
      The calling request's api key, or "" when the header was absent. Valid on any thread carrying the call's gRPC Context.
      Returns:
      the x-api-key value, never null
    • datasourceId

      public static String datasourceId()
      The calling request's datasource id, or "" when the header was absent.
      Returns:
      the x-datasource-id value, never null
    • callWith

      public static <T> T callWith(String apiKey, String datasourceId, Callable<T> body) throws Exception
      Runs body with the given credentials bound, for in-process callers that bypass the gRPC server (tests, internal replays). Over the wire the interceptor binds them from metadata instead.
      Type Parameters:
      T - the body's result type
      Parameters:
      apiKey - the api key to bind
      datasourceId - the datasource id to bind
      body - the work to run with the credentials bound
      Returns:
      body's result
      Throws:
      Exception - whatever body throws