diff options
Diffstat (limited to 'src/csharp/Grpc.Core/CallOptions.cs')
-rw-r--r-- | src/csharp/Grpc.Core/CallOptions.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/CallOptions.cs b/src/csharp/Grpc.Core/CallOptions.cs index 35548cfc96..ce43dae171 100644 --- a/src/csharp/Grpc.Core/CallOptions.cs +++ b/src/csharp/Grpc.Core/CallOptions.cs @@ -50,6 +50,7 @@ namespace Grpc.Core WriteOptions writeOptions; ContextPropagationToken propagationToken; CallCredentials credentials; + CallFlags flags; /// <summary> /// Creates a new instance of <c>CallOptions</c> struct. @@ -69,6 +70,7 @@ namespace Grpc.Core this.writeOptions = writeOptions; this.propagationToken = propagationToken; this.credentials = credentials; + this.flags = default(CallFlags); } /// <summary> @@ -126,6 +128,24 @@ namespace Grpc.Core } /// <summary> + /// If <c>true</c> and and channel is in <c>ChannelState.TransientFailure</c>, the call will attempt waiting for the channel to recover + /// instead of failing immediately (which is the default "FailFast" semantics). + /// Note: experimental API that can change or be removed without any prior notice. + /// </summary> + public bool IsWaitForReady + { + get { return (this.flags & CallFlags.WaitForReady) == CallFlags.WaitForReady; } + } + + /// <summary> + /// Flags to use for this call. + /// </summary> + internal CallFlags Flags + { + get { return this.flags; } + } + + /// <summary> /// Returns new instance of <see cref="CallOptions"/> with /// <c>Headers</c> set to the value provided. Values of all other fields are preserved. /// </summary> @@ -198,6 +218,32 @@ namespace Grpc.Core } /// <summary> + /// Returns new instance of <see cref="CallOptions"/> with "WaitForReady" semantics enabled/disabled. + /// <see cref="IsWaitForReady"/>. + /// Note: experimental API that can change or be removed without any prior notice. + /// </summary> + public CallOptions WithWaitForReady(bool waitForReady = true) + { + if (waitForReady) + { + return WithFlags(this.flags | CallFlags.WaitForReady); + } + return WithFlags(this.flags & ~CallFlags.WaitForReady); + } + + /// <summary> + /// Returns new instance of <see cref="CallOptions"/> with + /// <c>Flags</c> set to the value provided. Values of all other fields are preserved. + /// </summary> + /// <param name="flags">The call flags.</param> + internal CallOptions WithFlags(CallFlags flags) + { + var newOptions = this; + newOptions.flags = flags; + return newOptions; + } + + /// <summary> /// Returns a new instance of <see cref="CallOptions"/> with /// all previously unset values set to their defaults and deadline and cancellation /// token propagated when appropriate. |