Restate Typescript SDK
    Preparing search index...

    A remote client for a Restate service.

    Use the following client to interact with services defined

    • serviceClient to create a client for a service.
    • workflowClient to create a client for a workflow.
    • objectClient to create a client for a virtual object.
    interface Ingress {
        call<I = Uint8Array<ArrayBufferLike>, O = Uint8Array<ArrayBufferLike>>(
            opts: {
                handler: string;
                key?: string;
                opts?: Opts<I, O>;
                parameter: I;
                scope?: string;
                service: string;
            },
        ): Promise<O>;
        objectClient<D>(
            opts: VirtualObjectDefinitionFrom<D>,
            key: string,
        ): IngressClient<VirtualObject<D>>;
        objectSendClient<D>(
            opts: VirtualObjectDefinitionFrom<D>,
            key: string,
        ): IngressSendClient<VirtualObject<D>>;
        rejectAwakeable(id: string, reason: string): Promise<void>;
        resolveAwakeable<T>(
            id: string,
            payload?: T,
            payloadSerde?: Serde<T>,
        ): Promise<void>;
        result<T>(
            send: Send<T> | WorkflowSubmission<T>,
            resultSerde?: Serde<T>,
        ): Promise<T>;
        scope(scopeKey: string): ScopedIngress;
        send<I = Uint8Array<ArrayBufferLike>>(
            opts: {
                handler: string;
                key?: string;
                opts?: SendOpts<I>;
                parameter: I;
                scope?: string;
                service: string;
            },
        ): Promise<Send<unknown>>;
        serviceClient<D>(opts: ServiceDefinitionFrom<D>): IngressClient<Service<D>>;
        serviceSendClient<D>(
            opts: ServiceDefinitionFrom<D>,
        ): IngressSendClient<Service<D>>;
        workflowClient<D>(
            opts: WorkflowDefinitionFrom<D>,
            key: string,
        ): IngressWorkflowClient<Workflow<D>>;
    }
    Index

    Methods

    • Generic request-response call. Routes directly by service name without a typed definition.

      Type Parameters

      • I = Uint8Array<ArrayBufferLike>
      • O = Uint8Array<ArrayBufferLike>

      Parameters

      • opts: {
            handler: string;
            key?: string;
            opts?: Opts<I, O>;
            parameter: I;
            scope?: string;
            service: string;
        }
        • handler: string
        • Optionalkey?: string
        • Optionalopts?: Opts<I, O>
        • parameter: I
        • Optional Experimentalscope?: string

          Route this call within the given scope. See Ingress.scope.

          NOTE: This API is experimental. To use it you need a restate-server >= 1.7, configured to enable service protocol v7 and flow control. For example, start the restate-server with the environment variables RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true and RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true.

        • service: string

      Returns Promise<O>

    • Resolve an awakeable from the ingress client.

      Type Parameters

      • T

      Parameters

      • id: string
      • Optionalpayload: T
      • OptionalpayloadSerde: Serde<T>

      Returns Promise<void>

    • Experimental

      Returns a ScopedIngress that routes all calls within the given scope.

      NOTE: This API is in preview and is not enabled by default. To use it in restate-server 1.7, enable the flow control and protocol v7 experimental features, via RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true and RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true. These can be enabled only on new clusters, for more info check out https://docs.restate.dev/services/flow-control#enabling-flow-control. If these experimental features aren't enabled, the invocation won't be ingested and the client request fails.

      A scope is a sub-grouping of resources (invocations, virtual object instances, workflow instances, concurrency limits) within the Restate cluster. It becomes part of the target identity tuple:

      • scope, service, handler, idempotencyKey?
      • scope, virtualObject, objectKey, handler, idempotencyKey?
      • scope, workflow, workflowKey, handler

      Under the hood, the scope contributes to the partition key, so all resources in a scope get co-located by the restate-server.

      Omitting the scope (i.e. using the regular serviceClient / workflowClient methods) is equivalent to calling with no scope, which is the existing behavior.

      The scope key must consist only of [a-zA-Z0-9_.-] characters, with 1 <= length <= 36 chars.

      Parameters

      • scopeKey: string

        the scope identifier

      Returns ScopedIngress

      // Route a call into a named scope
      await ingress.scope("tenant-123").serviceClient(MyService).process(payload);

      // Idempotency keys are scoped — "req-1" in "tenant-123" is distinct from "req-1" in "tenant-456"
      await ingress.scope("tenant-123").serviceClient(MyService)
      .process(payload, rpc.opts({ idempotencyKey: "req-1" }));

      // Combine with a limit key to enforce per-scope concurrency limits
      await ingress.scope("tenant-123").workflowClient(MyWorkflow, "wf-key")
      .run(input, rpc.opts({ limitKey: "api-key/user42" }));
    • Generic fire-and-forget send. Routes directly by service name without a typed definition.

      Type Parameters

      • I = Uint8Array<ArrayBufferLike>

      Parameters

      • opts: {
            handler: string;
            key?: string;
            opts?: SendOpts<I>;
            parameter: I;
            scope?: string;
            service: string;
        }
        • handler: string
        • Optionalkey?: string
        • Optionalopts?: SendOpts<I>
        • parameter: I
        • Optional Experimentalscope?: string

          Route this send within the given scope. See Ingress.scope.

          NOTE: This API is experimental. To use it you need a restate-server >= 1.7, configured to enable service protocol v7 and flow control. For example, start the restate-server with the environment variables RESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=true and RESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true.

        • service: string

      Returns Promise<Send<unknown>>