Skip to content

Commit f929e2e

Browse files
committed
.
1 parent f6b4067 commit f929e2e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/Runner.Listener/Runner.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public sealed class Runner : RunnerService, IRunner
3232
private bool _inConfigStage;
3333
private ManualResetEvent _completedCommand = new(false);
3434
private IRunnerServer _runnerServer;
35-
private RunnerSettings _runnerSettings;
3635

3736
// <summary>
3837
// Helps avoid excessive calls to Run Service when encountering non-retriable errors from /acquirejob.
@@ -52,7 +51,7 @@ public override void Initialize(IHostContext hostContext)
5251
{
5352
base.Initialize(hostContext);
5453
_term = HostContext.GetService<ITerminal>();
55-
_acquireJobThrottler = HostContext.GetService<IErrorThrottler>();
54+
_acquireJobThrottler = HostContext.CreateService<IErrorThrottler>();
5655
_runnerServer = HostContext.GetService<IRunnerServer>();
5756
}
5857

@@ -255,7 +254,7 @@ public async Task<int> ExecuteCommand(CommandSettings command)
255254
}
256255
}
257256

258-
_runnerSettings = configManager.LoadSettings();
257+
RunnerSettings settings = configManager.LoadSettings();
259258

260259
var store = HostContext.GetService<IConfigurationStore>();
261260
bool configuredAsService = store.IsServiceConfigured();
@@ -304,7 +303,7 @@ public async Task<int> ExecuteCommand(CommandSettings command)
304303
}
305304

306305
// Run the runner interactively or as service
307-
return await RunAsync(_runnerSettings, command.RunOnce || _runnerSettings.Ephemeral);
306+
return await RunAsync(settings, command.RunOnce || settings.Ephemeral);
308307
}
309308
else
310309
{

src/Test/L0/Listener/RunnerL0.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task TestRunAsync()
6969
hc.SetSingleton<IPromptManager>(_promptManager.Object);
7070
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
7171
hc.SetSingleton<IConfigurationStore>(_configStore.Object);
72-
hc.SetSingleton<IErrorThrottler>(_acquireJobThrottler.Object);
72+
hc.EnqueueInstance<IErrorThrottler>(_acquireJobThrottler.Object);
7373
runner.Initialize(hc);
7474
var settings = new RunnerSettings
7575
{
@@ -178,7 +178,7 @@ public async Task TestExecuteCommandForRunAsService(string[] args, bool configur
178178
hc.SetSingleton<IMessageListener>(_messageListener.Object);
179179
hc.SetSingleton<IConfigurationStore>(_configStore.Object);
180180
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
181-
hc.SetSingleton<IErrorThrottler>(_acquireJobThrottler.Object);
181+
hc.EnqueueInstance<IErrorThrottler>(_acquireJobThrottler.Object);
182182

183183
var command = new CommandSettings(hc, args);
184184

@@ -211,7 +211,7 @@ public async Task TestMachineProvisionerCLI()
211211
hc.SetSingleton<IMessageListener>(_messageListener.Object);
212212
hc.SetSingleton<IConfigurationStore>(_configStore.Object);
213213
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
214-
hc.SetSingleton<IErrorThrottler>(_acquireJobThrottler.Object);
214+
hc.EnqueueInstance<IErrorThrottler>(_acquireJobThrottler.Object);
215215

216216
var command = new CommandSettings(hc, new[] { "run" });
217217

@@ -249,7 +249,7 @@ public async Task TestRunOnce()
249249
hc.SetSingleton<IPromptManager>(_promptManager.Object);
250250
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
251251
hc.SetSingleton<IConfigurationStore>(_configStore.Object);
252-
hc.SetSingleton<IErrorThrottler>(_acquireJobThrottler.Object);
252+
hc.EnqueueInstance<IErrorThrottler>(_acquireJobThrottler.Object);
253253
runner.Initialize(hc);
254254
var settings = new RunnerSettings
255255
{
@@ -346,7 +346,7 @@ public async Task TestRunOnceOnlyTakeOneJobMessage()
346346
hc.SetSingleton<IPromptManager>(_promptManager.Object);
347347
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
348348
hc.SetSingleton<IConfigurationStore>(_configStore.Object);
349-
hc.SetSingleton<IErrorThrottler>(_acquireJobThrottler.Object);
349+
hc.EnqueueInstance<IErrorThrottler>(_acquireJobThrottler.Object);
350350
runner.Initialize(hc);
351351
var settings = new RunnerSettings
352352
{
@@ -448,7 +448,7 @@ public async Task TestRunOnceHandleUpdateMessage()
448448
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
449449
hc.SetSingleton<IConfigurationStore>(_configStore.Object);
450450
hc.SetSingleton<ISelfUpdater>(_updater.Object);
451-
hc.SetSingleton<IErrorThrottler>(_acquireJobThrottler.Object);
451+
hc.EnqueueInstance<IErrorThrottler>(_acquireJobThrottler.Object);
452452

453453
runner.Initialize(hc);
454454
var settings = new RunnerSettings
@@ -533,7 +533,7 @@ public async Task TestRemoveLocalRunnerConfig()
533533
hc.SetSingleton<IConfigurationStore>(_configStore.Object);
534534
hc.SetSingleton<IPromptManager>(_promptManager.Object);
535535
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
536-
hc.SetSingleton<IErrorThrottler>(_acquireJobThrottler.Object);
536+
hc.EnqueueInstance<IErrorThrottler>(_acquireJobThrottler.Object);
537537

538538
var command = new CommandSettings(hc, new[] { "remove", "--local" });
539539

0 commit comments

Comments
 (0)