From f218fb52291de70d0b0a96eb3e4b4cfc935c453b Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 1 Feb 2024 18:28:38 +0900 Subject: [PATCH] Mark GrpcChannelProvider(GrpcChannelOptions) as Obsolete --- README.md | 10 +++++----- .../MagicOnion.Unity/DefaultGrpcChannelProvider.cs | 3 ++- .../GrpcNetClientGrpcChannelProvider.cs | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6369159ab..d40bd5c78 100644 --- a/README.md +++ b/README.md @@ -1066,12 +1066,12 @@ Before creating a channel in your application, you need to initialize the provid public static void OnRuntimeInitialize() { // Initialize gRPC channel provider when the application is loaded. - GrpcChannelProviderHost.Initialize(new DefaultGrpcChannelProvider(new [] + GrpcChannelProviderHost.Initialize(new DefaultGrpcChannelProvider(() => new GrpcChannelOptions() { - // send keepalive ping every 5 second, default is 2 hours - new ChannelOption("grpc.keepalive_time_ms", 5000), - // keepalive ping time out after 5 seconds, default is 20 seconds - new ChannelOption("grpc.keepalive_timeout_ms", 5 * 1000), + HttpHandler = new YetAnotherHttpHandler() + { + Http2Only = true, + }, })); } ``` diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/DefaultGrpcChannelProvider.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/DefaultGrpcChannelProvider.cs index 525c31905..004226bbe 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/DefaultGrpcChannelProvider.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/DefaultGrpcChannelProvider.cs @@ -23,7 +23,8 @@ public DefaultGrpcChannelProvider(GrpcCCoreChannelOptions channelOptions) : base public class DefaultGrpcChannelProvider : GrpcNetClientGrpcChannelProvider { public DefaultGrpcChannelProvider() : base() {} - public DefaultGrpcChannelProvider(GrpcChannelOptions channelOptions) : base(channelOptions) {} + [Obsolete("Use constructor with a GrpcChannelOptions factory overload instead. If you pass a GrpcChannelOptions directly, HttpClient/HttpHandler may be reused unintentionally.")] + public DefaultGrpcChannelProvider(GrpcChannelOptions channelOptions) : base(channelOptions) { } public DefaultGrpcChannelProvider(Func channelOptionsFactory) : base(channelOptionsFactory) {} } #endif diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcNetClientGrpcChannelProvider.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcNetClientGrpcChannelProvider.cs index b5a1a47db..d491f41a9 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcNetClientGrpcChannelProvider.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcNetClientGrpcChannelProvider.cs @@ -13,10 +13,11 @@ public class GrpcNetClientGrpcChannelProvider : GrpcChannelProviderBase { readonly Func defaultChannelOptionsFactory; public GrpcNetClientGrpcChannelProvider() - : this(new GrpcChannelOptions()) + : this(() => new GrpcChannelOptions()) { } + [Obsolete("Use constructor with a GrpcChannelOptions factory overload instead. If you pass a GrpcChannelOptions directly, HttpClient/HttpHandler may be reused unintentionally.")] public GrpcNetClientGrpcChannelProvider(GrpcChannelOptions options) : this(() => options) {