Show / Hide Table of Contents

    Class Channel

    Represents a gRPC channel. Channels are an abstraction of long-lived connections to remote servers. More client objects can reuse the same channel. Creating a channel is an expensive operation compared to invoking a remote call so in general you should reuse a single channel for as many calls as possible.

    Inheritance
    System.Object
    ChannelBase
    Channel
    Inherited Members
    ChannelBase.Target
    ChannelBase.ShutdownAsync()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Grpc.Core
    Assembly: Grpc.Core.dll
    Syntax
    public class Channel : ChannelBase

    Constructors

    Channel(String, ChannelCredentials)

    Creates a channel that connects to a specific host. Port will default to 80 for an unsecure channel and to 443 for a secure channel.

    Declaration
    public Channel(string target, ChannelCredentials credentials)
    Parameters
    Type Name Description
    System.String target

    Target of the channel.

    ChannelCredentials credentials

    Credentials to secure the channel.

    Channel(String, ChannelCredentials, IEnumerable<ChannelOption>)

    Creates a channel that connects to a specific host. Port will default to 80 for an unsecure channel or to 443 for a secure channel.

    Declaration
    public Channel(string target, ChannelCredentials credentials, IEnumerable<ChannelOption> options)
    Parameters
    Type Name Description
    System.String target

    Target of the channel.

    ChannelCredentials credentials

    Credentials to secure the channel.

    System.Collections.Generic.IEnumerable<ChannelOption> options

    Channel options.

    Channel(String, Int32, ChannelCredentials)

    Creates a channel that connects to a specific host and port.

    Declaration
    public Channel(string host, int port, ChannelCredentials credentials)
    Parameters
    Type Name Description
    System.String host

    The name or IP address of the host.

    System.Int32 port

    The port.

    ChannelCredentials credentials

    Credentials to secure the channel.

    Channel(String, Int32, ChannelCredentials, IEnumerable<ChannelOption>)

    Creates a channel that connects to a specific host and port.

    Declaration
    public Channel(string host, int port, ChannelCredentials credentials, IEnumerable<ChannelOption> options)
    Parameters
    Type Name Description
    System.String host

    The name or IP address of the host.

    System.Int32 port

    The port.

    ChannelCredentials credentials

    Credentials to secure the channel.

    System.Collections.Generic.IEnumerable<ChannelOption> options

    Channel options.

    Properties

    ResolvedTarget

    Resolved address of the remote endpoint in URI format.

    Declaration
    public string ResolvedTarget { get; }
    Property Value
    Type Description
    System.String

    ShutdownToken

    Returns a token that gets cancelled once ShutdownAsync is invoked.

    Declaration
    public CancellationToken ShutdownToken { get; }
    Property Value
    Type Description
    System.Threading.CancellationToken

    State

    Gets current connectivity state of this channel. After channel has been shutdown, ChannelState.Shutdown will be returned.

    Declaration
    public ChannelState State { get; }
    Property Value
    Type Description
    ChannelState

    Methods

    ConnectAsync(Nullable<DateTime>)

    Allows explicitly requesting channel to connect without starting an RPC. Returned task completes once state Ready was seen. If the deadline is reached, or channel enters the Shutdown state, the task is cancelled. There is no need to call this explicitly unless your use case requires that. Starting an RPC on a new channel will request connection implicitly.

    Declaration
    public Task ConnectAsync(DateTime? deadline = default(DateTime? ))
    Parameters
    Type Name Description
    System.Nullable<System.DateTime> deadline

    The deadline. null indicates no deadline.

    Returns
    Type Description
    System.Threading.Tasks.Task

    CreateCallInvoker()

    Create a new CallInvoker for the channel.

    Declaration
    public override CallInvoker CreateCallInvoker()
    Returns
    Type Description
    CallInvoker

    A new CallInvoker.

    Overrides
    ChannelBase.CreateCallInvoker()

    ShutdownAsyncCore()

    Provides implementation of a non-virtual public member.

    Declaration
    protected override Task ShutdownAsyncCore()
    Returns
    Type Description
    System.Threading.Tasks.Task
    Overrides
    ChannelBase.ShutdownAsyncCore()

    TryWaitForStateChangedAsync(ChannelState, Nullable<DateTime>)

    Returned tasks completes once channel state has become different from given lastObservedState (true is returned) or if the wait has timed out (false is returned).

    Declaration
    public Task<bool> TryWaitForStateChangedAsync(ChannelState lastObservedState, DateTime? deadline = default(DateTime? ))
    Parameters
    Type Name Description
    ChannelState lastObservedState
    System.Nullable<System.DateTime> deadline
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Boolean>

    WaitForStateChangedAsync(ChannelState, Nullable<DateTime>)

    Returned tasks completes once channel state has become different from given lastObservedState. If deadline is reached or an error occurs, returned task is cancelled.

    Declaration
    public Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime? deadline = default(DateTime? ))
    Parameters
    Type Name Description
    ChannelState lastObservedState
    System.Nullable<System.DateTime> deadline
    Returns
    Type Description
    System.Threading.Tasks.Task
    Back to top Generated by DocFX