-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: register self provider factory to each client
- Loading branch information
1 parent
f2329ac
commit 25cce94
Showing
3 changed files
with
42 additions
and
5 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
16 changes: 16 additions & 0 deletions
16
src/Sitko.Core.Grpc.Client/IGrpcMetadataProviderFactory.cs
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,16 @@ | ||
using Grpc.Core; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Sitko.Core.Grpc.Client; | ||
|
||
internal interface IGrpcMetadataProviderFactory<TClient> where TClient : ClientBase<TClient> | ||
{ | ||
public IGrpcMetadataProvider GetProvider(IServiceProvider serviceProvider); | ||
} | ||
|
||
internal class GrpcMetadataProviderFactory<TClient, TMetadataProvider> : IGrpcMetadataProviderFactory<TClient> where TClient : ClientBase<TClient> | ||
where TMetadataProvider : class, IGrpcMetadataProvider | ||
|
||
{ | ||
public IGrpcMetadataProvider GetProvider(IServiceProvider serviceProvider) => serviceProvider.GetService<TMetadataProvider>()!; | ||
} |
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,16 @@ | ||
using Grpc.Core; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Sitko.Core.Grpc.Client; | ||
|
||
public interface IGrpcTokenProviderFactory<TClient> where TClient : ClientBase<TClient> | ||
{ | ||
public IGrpcTokenProvider GetProvider(IServiceProvider serviceProvider); | ||
} | ||
|
||
internal class GrpcTokenProviderFactory<TClient, TTokenProvider> : IGrpcTokenProviderFactory<TClient> where TClient : ClientBase<TClient> | ||
where TTokenProvider : class, IGrpcTokenProvider | ||
|
||
{ | ||
public IGrpcTokenProvider GetProvider(IServiceProvider serviceProvider) => serviceProvider.GetService<TTokenProvider>()!; | ||
} |