Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/Temporalio/Worker/TemporalWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@ public TemporalWorker(IWorkerClient client, TemporalWorkerOptions options)

var bridgeClient = client.BridgeClientProvider.BridgeClient ??
throw new InvalidOperationException("Cannot use unconnected lazy client for worker");

if (options.Activities.Count == 0 && options.Workflows.Count == 0 && options.NexusServices.Count == 0)
{
throw new ArgumentException("Must have at least one workflow, activity, or Nexus service");
}

BridgeWorker = new(
(Bridge.Client)bridgeClient,
client.Options.Namespace,
options,
loggerFactory,
client.Options.Plugins);
if (options.Activities.Count == 0 && options.Workflows.Count == 0)
{
throw new ArgumentException("Must have at least one workflow and/or activity");
}

MetricMeter = MetricMeterBridge.LazyFromRuntime(BridgeWorker.Runtime);

Expand Down Expand Up @@ -128,6 +130,11 @@ public TemporalWorker(IWorkerClient client, TemporalWorkerOptions options)
DeploymentOptions: options.DeploymentOptions));
}

if (options.NexusServices.Count > 0)
{
nexusWorker = new(this);
}

disposer = new Disposer(activityWorker, BridgeWorker, workflowTracingEventListenerEnabled);
}
catch (Exception)
Expand All @@ -140,10 +147,6 @@ public TemporalWorker(IWorkerClient client, TemporalWorkerOptions options)
}
throw;
}
if (options.NexusServices.Count > 0)
{
nexusWorker = new(this);
}
}

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions tests/Temporalio.Tests/Worker/GeneralWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ public GeneralWorkerTests(ITestOutputHelper output, WorkflowEnvironment env)
{
}

[Fact]
public void Constructor_NoTaskTypes_Throws()
{
var exc = Assert.Throws<ArgumentException>(() =>
new TemporalWorker(
Env.Client,
new TemporalWorkerOptions($"tq-{Guid.NewGuid()}")));
}

[Fact]
public async Task ExecuteAsync_PropagatesException()
{
Expand Down
Loading