This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove RepositoryHost(s) #1283
Merged
grokys
merged 21 commits into
refactor/connections-master
from
refactor/connections/remove-repositoryhosts
Nov 8, 2017
Merged
Remove RepositoryHost(s) #1283
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
470ea13
Removed `IConnection.Repositories`.
grokys d98ec51
Refactored ConnectionManager/Connection.
grokys aa78f03
Refactored RepositoryHost(s).
grokys 7cf89c9
Added DebuggerDisplay back in.
grokys 213a7fc
Moved LocalRepositories to GitHub.VisualStudio.
grokys 90c35c5
Track login metrics.
grokys 9db05a7
Fix failing tests.
grokys f854b79
WIP: Removing RepositoryHost(s)
grokys 3240372
WIP: Still removing RepositoryHost(s)
grokys 038f232
WIP: Removing RepositoryHost(s) from tests.
grokys a57a759
Finished migrating tests (I think).
grokys 95cd0b1
Added IModelServiceFactory implemenation.
grokys 6034643
Added IGlobalConnection.
grokys 17aebf8
Removed ConnectionManager.ConnectionCreated.
grokys 01aad33
Merge branch 'refactor/connections-master' into refactor/connections/…
grokys 217e415
Merge branch 'refactor/connections/local-repositories' into refactor/…
grokys 7e57621
Insert AccountCacheItem for connection.
grokys 8f6d218
Merge branch 'refactor/connections-master' into refactor/connections/…
grokys 32f073a
Merge branch 'refactor/connections/local-repositories' into refactor/…
grokys 9f15db6
Merge branch 'refactor/connection-manager' into refactor/connections/…
grokys cd546bb
Fix CA errors.
grokys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using GitHub.Caches; | ||
using GitHub.Models; | ||
using GitHub.Services; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace GitHub.Factories | ||
{ | ||
[Export(typeof(IModelServiceFactory))] | ||
[PartCreationPolicy(CreationPolicy.Shared)] | ||
public sealed class ModelServiceFactory : IModelServiceFactory, IDisposable | ||
{ | ||
readonly IApiClientFactory apiClientFactory; | ||
readonly IHostCacheFactory hostCacheFactory; | ||
readonly IAvatarProvider avatarProvider; | ||
readonly Dictionary<IConnection, ModelService> cache = new Dictionary<IConnection, ModelService>(); | ||
readonly SemaphoreSlim cacheLock = new SemaphoreSlim(1); | ||
|
||
[ImportingConstructor] | ||
public ModelServiceFactory( | ||
IApiClientFactory apiClientFactory, | ||
IHostCacheFactory hostCacheFactory, | ||
IAvatarProvider avatarProvider) | ||
{ | ||
this.apiClientFactory = apiClientFactory; | ||
this.hostCacheFactory = hostCacheFactory; | ||
this.avatarProvider = avatarProvider; | ||
} | ||
|
||
public async Task<IModelService> CreateAsync(IConnection connection) | ||
{ | ||
ModelService result; | ||
|
||
await cacheLock.WaitAsync(); | ||
|
||
try | ||
{ | ||
if (!cache.TryGetValue(connection, out result)) | ||
{ | ||
result = new ModelService( | ||
await apiClientFactory.Create(connection.HostAddress), | ||
await hostCacheFactory.Create(connection.HostAddress), | ||
avatarProvider); | ||
result.InsertUser(AccountCacheItem.Create(connection.User)); | ||
cache.Add(connection, result); | ||
} | ||
} | ||
finally | ||
{ | ||
cacheLock.Release(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public IModelService CreateBlocking(IConnection connection) | ||
{ | ||
return ThreadHelper.JoinableTaskFactory.Run(() => CreateAsync(connection)); | ||
} | ||
|
||
public void Dispose() => cacheLock.Dispose(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted. 4965
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use
ISimpleApiClientFactory
here, so we can slowly move away fromIApiClientFactory
and get rid of it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but
ModelService
still relies onIApiClient
rather thanISimpleApiClient
and needs the reactive stuff, so if we want to make that change it will have to be later I think.