44import { TokenCredential } from "@azure/identity" ;
55import * as grpc from "@grpc/grpc-js" ;
66import { DurableTaskAzureManagedWorkerOptions } from "./options" ;
7- import { TaskHubGrpcWorker , TOrchestrator , TActivity , TInput , TOutput , Logger , ConsoleLogger } from "@microsoft/durabletask-js" ;
7+ import {
8+ TaskHubGrpcWorker ,
9+ TOrchestrator ,
10+ TActivity ,
11+ TInput ,
12+ TOutput ,
13+ Logger ,
14+ ConsoleLogger ,
15+ VersioningOptions ,
16+ } from "@microsoft/durabletask-js" ;
817
918/**
1019 * Builder for creating DurableTaskWorker instances that connect to Azure-managed Durable Task service.
@@ -17,6 +26,7 @@ export class DurableTaskAzureManagedWorkerBuilder {
1726 private _activities : { name ?: string ; fn : TActivity < TInput , TOutput > } [ ] = [ ] ;
1827 private _logger : Logger = new ConsoleLogger ( ) ;
1928 private _shutdownTimeoutMs ?: number ;
29+ private _versioning ?: VersioningOptions ;
2030
2131 /**
2232 * Creates a new instance of DurableTaskAzureManagedWorkerBuilder.
@@ -198,6 +208,18 @@ export class DurableTaskAzureManagedWorkerBuilder {
198208 return this ;
199209 }
200210
211+ /**
212+ * Configures versioning options for the worker.
213+ * This allows filtering orchestrations by version using different match strategies.
214+ *
215+ * @param options The versioning options including version, matchStrategy, and failureStrategy.
216+ * @returns This builder instance.
217+ */
218+ versioning ( options : VersioningOptions ) : DurableTaskAzureManagedWorkerBuilder {
219+ this . _versioning = options ;
220+ return this ;
221+ }
222+
201223 /**
202224 * Builds and returns a configured TaskHubGrpcWorker.
203225 *
@@ -219,18 +241,17 @@ export class DurableTaskAzureManagedWorkerBuilder {
219241 ...this . _grpcChannelOptions ,
220242 } ;
221243
222- // Use the core TaskHubGrpcWorker with custom credentials and metadata generator
223- // For insecure connections, metadata is passed via the metadataGenerator parameter
224- // For secure connections, metadata is included in the channel credentials
225- const worker = new TaskHubGrpcWorker (
244+ // Use the core TaskHubGrpcWorker with options-based constructor
245+ const worker = new TaskHubGrpcWorker ( {
226246 hostAddress,
227- combinedOptions ,
228- true ,
229- channelCredentials ,
247+ options : combinedOptions ,
248+ useTLS : true ,
249+ credentials : channelCredentials ,
230250 metadataGenerator,
231- this . _logger ,
232- this . _shutdownTimeoutMs ,
233- ) ;
251+ logger : this . _logger ,
252+ shutdownTimeoutMs : this . _shutdownTimeoutMs ,
253+ versioning : this . _versioning ,
254+ } ) ;
234255
235256 // Register all orchestrators
236257 for ( const { name, fn } of this . _orchestrators ) {
0 commit comments