Struct CallOptions (2.48.0)

public struct CallOptions

Options for calls made by client.

Namespace

Grpc.Core

Assembly

Grpc.Core.Api.dll

Constructors

CallOptions(Metadata, Nullable<DateTime>, CancellationToken, WriteOptions, ContextPropagationToken, CallCredentials)

public CallOptions(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = null, WriteOptions writeOptions = null, ContextPropagationToken propagationToken = null, CallCredentials credentials = null)

Creates a new instance of CallOptions struct.

Parameters
NameDescription
headersMetadata

Headers to be sent with the call.

deadlineNullable<DateTime>

Deadline for the call to finish. null means no deadline.

cancellationTokenCancellationToken

Can be used to request cancellation of the call.

writeOptionsWriteOptions

Write options that will be used for this call.

propagationTokenContextPropagationToken

Context propagation token obtained from ServerCallContext.

credentialsCallCredentials

Credentials to use for this call.

Properties

CancellationToken

public readonly CancellationToken CancellationToken { get; }

Token that can be used for cancelling the call on the client side. Cancelling the token will request cancellation of the remote call. Best effort will be made to deliver the cancellation notification to the server and interaction of the call with the server side will be terminated. Unless the call finishes before the cancellation could happen (there is an inherent race), the call will finish with StatusCode.Cancelled status.

Property Value
TypeDescription
CancellationToken

Credentials

public readonly CallCredentials Credentials { get; }

Credentials to use for this call.

Property Value
TypeDescription
CallCredentials

Deadline

public readonly DateTime? Deadline { get; }

Call deadline.

Property Value
TypeDescription
Nullable<DateTime>

Headers

public readonly Metadata Headers { get; }

Headers to send at the beginning of the call.

Property Value
TypeDescription
Metadata

IsWaitForReady

public readonly bool IsWaitForReady { get; }

If true and channel is in ChannelState.TransientFailure, 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.

Property Value
TypeDescription
Boolean

PropagationToken

public readonly ContextPropagationToken PropagationToken { get; }

Token for propagating parent call context.

Property Value
TypeDescription
ContextPropagationToken

WriteOptions

public readonly WriteOptions WriteOptions { get; }

Write options that will be used for this call.

Property Value
TypeDescription
WriteOptions

Methods

WithCancellationToken(CancellationToken)

public CallOptions WithCancellationToken(CancellationToken cancellationToken)

Returns new instance of CallOptions with CancellationToken set to the value provided. Values of all other fields are preserved.

Parameter
NameDescription
cancellationTokenCancellationToken

The cancellation token.

Returns
TypeDescription
CallOptions

WithCredentials(CallCredentials)

public CallOptions WithCredentials(CallCredentials credentials)

Returns new instance of CallOptions with Credentials set to the value provided. Values of all other fields are preserved.

Parameter
NameDescription
credentialsCallCredentials

The call credentials.

Returns
TypeDescription
CallOptions

WithDeadline(DateTime)

public CallOptions WithDeadline(DateTime deadline)

Returns new instance of CallOptions with Deadline set to the value provided. Values of all other fields are preserved.

Parameter
NameDescription
deadlineDateTime

The deadline.

Returns
TypeDescription
CallOptions

WithHeaders(Metadata)

public CallOptions WithHeaders(Metadata headers)

Returns new instance of CallOptions with Headers set to the value provided. Values of all other fields are preserved.

Parameter
NameDescription
headersMetadata

The headers.

Returns
TypeDescription
CallOptions

WithPropagationToken(ContextPropagationToken)

public CallOptions WithPropagationToken(ContextPropagationToken propagationToken)

Returns new instance of CallOptions with PropagationToken set to the value provided. Values of all other fields are preserved.

Parameter
NameDescription
propagationTokenContextPropagationToken

The context propagation token.

Returns
TypeDescription
CallOptions

WithWaitForReady(Boolean)

public CallOptions WithWaitForReady(bool waitForReady = true)

Returns new instance of CallOptions with "WaitForReady" semantics enabled/disabled. IsWaitForReady. Note: experimental API that can change or be removed without any prior notice.

Parameter
NameDescription
waitForReadyBoolean
Returns
TypeDescription
CallOptions

WithWriteOptions(WriteOptions)

public CallOptions WithWriteOptions(WriteOptions writeOptions)

Returns new instance of CallOptions with WriteOptions set to the value provided. Values of all other fields are preserved.

Parameter
NameDescription
writeOptionsWriteOptions

The write options.

Returns
TypeDescription
CallOptions