Skip to main content

Class: NexusClient

Experimental

Client for standalone Nexus operations. Access via Client.nexus.

Use createServiceClient to get a typed service client, or call the namespace-wide list, count, and getHandle methods directly.

See​

Client

Nexus Standalone Operations are experimental.

Extends​

  • BaseClient

Constructors​

Constructor​

new NexusClient(options?): NexusClient

Experimental

Parameters​

options?​

NexusClientOptions

Returns​

NexusClient

Overrides​

BaseClient.constructor

Properties​

connection​

readonly connection: ConnectionLike

Experimental

The underlying connection or NativeConnection | native connection used by this client.

Clients are cheap to create, but connections are expensive. Where it makes sense, a single connection may and should be reused by multiple Clients.

Inherited from​

BaseClient.connection


options​

readonly options: LoadedNexusClientOptions

Experimental

Methods​

count()​

count(query?): Promise<NexusOperationExecutionCount>

Experimental

Count standalone Nexus operations matching a visibility query.

Nexus Standalone Operations are experimental.

Parameters​

query?​

string

Returns​

Promise<NexusOperationExecutionCount>


createServiceClient()​

createServiceClient<T>(options): NexusServiceClient<T>

Experimental

Create a typed service client for starting and executing Nexus operations on a specific endpoint + service.

Nexus Standalone Operations are experimental.

Type Parameters​

T​

T extends ServiceDefinition<OperationMap>

Parameters​

options​
endpoint​

string

service​

T

Returns​

NexusServiceClient<T>


getHandle()​

Call Signature​

getHandle<Op>(operationId, options): NexusOperationHandle<OperationOutput<Op>>

Experimental

Get a handle to an existing standalone Nexus operation.

If GetNexusOperationHandleOptions.runId is not provided, operations on the handle (like NexusOperationHandle.result) will target the latest run.

Nexus Standalone Operations are experimental.

Type Parameters​
Op​

Op extends OperationDefinition<any, any>

Parameters​
operationId​

string

options​

NexusOperationHandleDefinitionOptions<Op>

Returns​

NexusOperationHandle<OperationOutput<Op>>

Call Signature​

getHandle<T>(operationId, options?): NexusOperationHandle<NexusOperationHandleResult<T>>

Experimental

Get a handle to an existing standalone Nexus operation.

If GetNexusOperationHandleOptions.runId is not provided, operations on the handle (like NexusOperationHandle.result) will target the latest run.

Nexus Standalone Operations are experimental.

Type Parameters​
T​

T

Parameters​
operationId​

string

options?​

GetNexusOperationHandleOptions<NexusOperationHandleResult<T>>

Returns​

NexusOperationHandle<NexusOperationHandleResult<T>>


list()​

list(options?): AsyncIterable<NexusOperationExecution>

Experimental

List standalone Nexus operations matching a visibility query.

Nexus Standalone Operations are experimental.

Parameters​

options?​

ListNexusOperationsOptions

Returns​

AsyncIterable<NexusOperationExecution>


withAbortSignal()​

withAbortSignal<R>(abortSignal, fn): Promise<R>

Experimental

Set an AbortSignal that, when aborted, cancels any ongoing service requests executed in fn's scope. This will locally result in the request call throwing a _grpc.ServiceError|ServiceError with code _grpc.status.CANCELLED|CANCELLED; see isGrpcCancelledError.

This method is only a convenience wrapper around Connection.withAbortSignal.

Type Parameters​

R​

R

Parameters​

abortSignal​

AbortSignal

fn​

() => Promise<R>

Returns​

Promise<R>

value returned from fn

See​

https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal

Inherited from​

BaseClient.withAbortSignal


withDeadline()​

withDeadline<R>(deadline, fn): Promise<R>

Experimental

Set a deadline for any service requests executed in fn's scope.

The deadline is a point in time after which any pending gRPC request will be considered as failed; this will locally result in the request call throwing a _grpc.ServiceError|ServiceError with code _grpc.status.DEADLINE_EXCEEDED|DEADLINE_EXCEEDED; see isGrpcDeadlineError.

It is stronly recommended to explicitly set deadlines. If no deadline is set, then it is possible for the client to end up waiting forever for a response.

This method is only a convenience wrapper around Connection.withDeadline.

Type Parameters​

R​

R

Parameters​

deadline​

number | Date

a point in time after which the request will be considered as failed; either a Date object, or a number of milliseconds since the Unix epoch (UTC).

fn​

() => Promise<R>

Returns​

Promise<R>

the value returned from fn

See​

https://grpc.io/docs/guides/deadlines/

Inherited from​

BaseClient.withDeadline


withMetadata()​

withMetadata<R>(metadata, fn): Promise<R>

Experimental

Set metadata for any service requests executed in fn's scope.

This method is only a convenience wrapper around Connection.withMetadata.

Type Parameters​

R​

R

Parameters​

metadata​

Metadata

fn​

() => Promise<R>

Returns​

Promise<R>

returned value of fn

Inherited from​

BaseClient.withMetadata