Skip to content

Commit

Permalink
Mark GrpcChannelProvider(GrpcChannelOptions) as Obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
mayuki committed Feb 1, 2024
1 parent 9b3233d commit f218fb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}));
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GrpcChannelOptions> channelOptionsFactory) : base(channelOptionsFactory) {}
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ public class GrpcNetClientGrpcChannelProvider : GrpcChannelProviderBase
{
readonly Func<GrpcChannelOptions> 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)
{
Expand Down

0 comments on commit f218fb5

Please sign in to comment.