tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
GitHubServiceFactory.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4
5using Microsoft.Extensions.Logging;
6using Microsoft.Extensions.Options;
7
8using Octokit;
9
11
13{
16 {
21
25 readonly ILoggerFactory loggerFactory;
26
31
40 ILoggerFactory loggerFactory,
41 IOptions<UpdatesConfiguration> updatesConfigurationOptions)
42 {
43 this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory));
44 this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
45 updatesConfiguration = updatesConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions));
46 }
47
49 public async ValueTask<IGitHubService> CreateService(CancellationToken cancellationToken)
51 await gitHubClientFactory.CreateClient(cancellationToken));
52
54 public async ValueTask<IAuthenticatedGitHubService> CreateService(string accessToken, CancellationToken cancellationToken)
57 accessToken ?? throw new ArgumentNullException(nameof(accessToken)),
58 cancellationToken));
59
61 public async ValueTask<IAuthenticatedGitHubService?> CreateService(string accessString, RepositoryIdentifier repositoryIdentifier, CancellationToken cancellationToken)
62 {
64 accessString ?? throw new ArgumentNullException(nameof(accessString)),
65 repositoryIdentifier,
66 cancellationToken);
67 if (client == null)
68 return null;
69
70 return CreateServiceImpl(client);
71 }
72
78 GitHubService CreateServiceImpl(IGitHubClient gitHubClient)
79 => new(
80 gitHubClient,
81 loggerFactory.CreateLogger<GitHubService>(),
83 }
84}
Configuration for the automatic update system.
async ValueTask< IAuthenticatedGitHubService?> CreateService(string accessString, RepositoryIdentifier repositoryIdentifier, CancellationToken cancellationToken)
Create an IAuthenticatedGitHubService.A ValueTask<TResult> resulting in a new IAuthenticatedGitHubSer...
readonly UpdatesConfiguration updatesConfiguration
The UpdatesConfiguration for the GitHubServiceFactory.
GitHubService CreateServiceImpl(IGitHubClient gitHubClient)
Create a GitHubService.
async ValueTask< IGitHubService > CreateService(CancellationToken cancellationToken)
Create a IGitHubService.A ValueTask<TResult> resulting in a new IGitHubService.
readonly ILoggerFactory loggerFactory
The ILoggerFactory for the GitHubServiceFactory.
readonly IGitHubClientFactory gitHubClientFactory
The IGitHubClientFactory for the GitHubServiceFactory.
GitHubServiceFactory(IGitHubClientFactory gitHubClientFactory, ILoggerFactory loggerFactory, IOptions< UpdatesConfiguration > updatesConfigurationOptions)
Initializes a new instance of the GitHubServiceFactory class.
async ValueTask< IAuthenticatedGitHubService > CreateService(string accessToken, CancellationToken cancellationToken)
Create an IAuthenticatedGitHubService.A ValueTask<TResult> resulting in a new IAuthenticatedGitHubSer...
Service for interacting with the GitHub API. Authenticated or otherwise.
Identifies a repository either by its RepositoryId or Owner and Name.
ValueTask< IGitHubClient?> CreateClientForRepository(string accessString, RepositoryIdentifier repositoryIdentifier, CancellationToken cancellationToken)
Creates a GitHub client that will only be used for a given repositoryIdentifier .
ValueTask< IGitHubClient > CreateClient(CancellationToken cancellationToken)
Create a IGitHubClient client. Low rate limit unless the server's GitHubAccessToken is set to bypass ...