@@ -8,6 +8,8 @@ namespace Microsoft.Extensions.Hosting;
88using DependencyInjection ;
99using Escendit . Extensions . Hosting . Abstractions ;
1010using Escendit . Extensions . Hosting . Exceptions ;
11+ using Temporalio . Extensions . Hosting ;
12+ using Temporalio . Extensions . OpenTelemetry ;
1113
1214/// <summary>
1315/// Provides extension methods for configuring and customizing the <see cref="HostApplicationBuilder"/>.
@@ -111,4 +113,47 @@ public static HostApplicationBuilder AddKeyedTemporalClient(
111113 . AddKeyedTemporalClient ( clientName , temporalHost . Authority , clientNamespace ) ;
112114 return builder ;
113115 }
116+
117+ /// <summary>
118+ /// Adds a Temporal server runtime to the application builder with the specified configuration settings.
119+ /// </summary>
120+ /// <param name="builder">The <see cref="HostApplicationBuilder"/> used to configure the application.</param>
121+ /// <param name="name">The name of the Temporal server runtime to configure.</param>
122+ /// <param name="configureOptions">An action to configure the <see cref="ITemporalWorkerServiceOptionsBuilder"/> for the server runtime.</param>
123+ /// <returns>The <see cref="HostApplicationBuilder"/> instance for further configuration.</returns>
124+ public static HostApplicationBuilder AddTemporalServerRuntime (
125+ this HostApplicationBuilder builder ,
126+ string name ,
127+ Action < ITemporalWorkerServiceOptionsBuilder > configureOptions )
128+ {
129+ ArgumentNullException . ThrowIfNull ( builder ) ;
130+ ArgumentNullException . ThrowIfNull ( name ) ;
131+ ArgumentNullException . ThrowIfNull ( configureOptions ) ;
132+
133+ return builder
134+ . AddServiceDefaults ( tracerProviderBuilder => tracerProviderBuilder
135+ . AddSource (
136+ name ,
137+ TracingInterceptor . ClientSource . Name ,
138+ TracingInterceptor . WorkflowsSource . Name ,
139+ TracingInterceptor . ActivitiesSource . Name ) )
140+ . AddTemporalHostedService ( name , server => server
141+ . ConfigureWorkerOptions ( configureOptions ) ) ;
142+ }
143+
144+ /// <summary>
145+ /// Adds a Temporal server runtime to the application builder with the specified configuration settings.
146+ /// </summary>
147+ /// <param name="builder">The <see cref="HostApplicationBuilder"/> used to configure the application.</param>
148+ /// <param name="configureOptions">An action to configure the <see cref="ITemporalWorkerServiceOptionsBuilder"/> for the server runtime.</param>
149+ /// <returns>The <see cref="HostApplicationBuilder"/> instance for further configuration.</returns>
150+ public static HostApplicationBuilder AddTemporalServerRuntime (
151+ this HostApplicationBuilder builder ,
152+ Action < ITemporalWorkerServiceOptionsBuilder > configureOptions )
153+ {
154+ ArgumentNullException . ThrowIfNull ( builder ) ;
155+ ArgumentNullException . ThrowIfNull ( configureOptions ) ;
156+
157+ return builder . AddTemporalServerRuntime ( DefaultTemporalServiceName , configureOptions ) ;
158+ }
114159}
0 commit comments