forked from actions/runner
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to support specific run service URL (actions#2158)
* changes to support run service url * feedback
- Loading branch information
1 parent
d719a7b
commit d977f4c
Showing
15 changed files
with
1,408 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using GitHub.DistributedTask.Pipelines; | ||
using GitHub.DistributedTask.WebApi; | ||
using GitHub.Services.Common; | ||
using GitHub.Services.WebApi; | ||
|
||
namespace GitHub.Runner.Common | ||
{ | ||
[ServiceLocator(Default = typeof(ActionsRunServer))] | ||
public interface IActionsRunServer : IRunnerService | ||
{ | ||
Task ConnectAsync(Uri serverUrl, VssCredentials credentials); | ||
|
||
Task<AgentJobRequestMessage> GetJobMessageAsync(string id, CancellationToken token); | ||
} | ||
|
||
public sealed class ActionsRunServer : RunnerService, IActionsRunServer | ||
{ | ||
private bool _hasConnection; | ||
private VssConnection _connection; | ||
private TaskAgentHttpClient _taskAgentClient; | ||
|
||
public async Task ConnectAsync(Uri serverUrl, VssCredentials credentials) | ||
{ | ||
_connection = await EstablishVssConnection(serverUrl, credentials, TimeSpan.FromSeconds(100)); | ||
_taskAgentClient = _connection.GetClient<TaskAgentHttpClient>(); | ||
_hasConnection = true; | ||
} | ||
|
||
private void CheckConnection() | ||
{ | ||
if (!_hasConnection) | ||
{ | ||
throw new InvalidOperationException($"SetConnection"); | ||
} | ||
} | ||
|
||
public Task<AgentJobRequestMessage> GetJobMessageAsync(string id, CancellationToken cancellationToken) | ||
{ | ||
CheckConnection(); | ||
var jobMessage = RetryRequest<AgentJobRequestMessage>(async () => | ||
{ | ||
return await _taskAgentClient.GetJobMessageAsync(id, cancellationToken); | ||
}, cancellationToken); | ||
|
||
return jobMessage; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.