Show / Hide Table of Contents

    Class GrpcEnvironment

    Encapsulates initialization and shutdown of gRPC library.

    Inheritance
    System.Object
    GrpcEnvironment
    Inherited Members
    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 GrpcEnvironment

    Properties

    Logger

    Gets application-wide logger used by gRPC.

    Declaration
    public static ILogger Logger { get; }
    Property Value
    Type Description
    ILogger

    The logger.

    Methods

    KillServersAsync()

    Requests immediate shutdown of all servers created by the current process.

    Declaration
    public static Task KillServersAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    SetBatchContextPoolParams(Int32, Int32)

    Sets the parameters for a pool that caches batch context instances. Reusing batch context instances instead of creating a new one for every C core operation helps reducing the GC pressure. Can be only invoked before the GrpcEnviroment is started and cannot be changed afterwards. This is an advanced setting and you should only use it if you know what you are doing. Most users should rely on the default value provided by gRPC library. Note: this method is part of an experimental API that can change or be removed without any prior notice.

    Declaration
    public static void SetBatchContextPoolParams(int sharedCapacity, int threadLocalCapacity)
    Parameters
    Type Name Description
    System.Int32 sharedCapacity
    System.Int32 threadLocalCapacity

    SetCompletionQueueCount(Int32)

    Sets the number of completion queues in the gRPC thread pool that polls for internal RPC events. Can be only invoked before the GrpcEnviroment is started and cannot be changed afterwards. Setting the number of completions queues is an advanced setting and you should only use it if you know what you are doing. Most users should rely on the default value provided by gRPC library. Note: this method is part of an experimental API that can change or be removed without any prior notice.

    Declaration
    public static void SetCompletionQueueCount(int completionQueueCount)
    Parameters
    Type Name Description
    System.Int32 completionQueueCount

    SetHandlerInlining(Boolean)

    By default, gRPC's internal event handlers get offloaded to .NET default thread pool thread (inlineHandlers=false). Setting inlineHandlers to true will allow scheduling the event handlers directly to GrpcThreadPool internal threads. That can lead to significant performance gains in some situations, but requires user to never block in async code (incorrectly written code can easily lead to deadlocks). Inlining handlers is an advanced setting and you should only use it if you know what you are doing. Most users should rely on the default value provided by gRPC library. Note: this method is part of an experimental API that can change or be removed without any prior notice. Note: inlineHandlers=true was the default in gRPC C# v1.4.x and earlier.

    Declaration
    public static void SetHandlerInlining(bool inlineHandlers)
    Parameters
    Type Name Description
    System.Boolean inlineHandlers

    SetLogger(ILogger)

    Sets the application-wide logger that should be used by gRPC.

    Declaration
    public static void SetLogger(ILogger customLogger)
    Parameters
    Type Name Description
    ILogger customLogger

    SetRequestCallContextPoolParams(Int32, Int32)

    Sets the parameters for a pool that caches request call context instances. Reusing request call context instances instead of creating a new one for every requested call in C core helps reducing the GC pressure. Can be only invoked before the GrpcEnviroment is started and cannot be changed afterwards. This is an advanced setting and you should only use it if you know what you are doing. Most users should rely on the default value provided by gRPC library. Note: this method is part of an experimental API that can change or be removed without any prior notice.

    Declaration
    public static void SetRequestCallContextPoolParams(int sharedCapacity, int threadLocalCapacity)
    Parameters
    Type Name Description
    System.Int32 sharedCapacity
    System.Int32 threadLocalCapacity

    SetThreadPoolSize(Int32)

    Sets the number of threads in the gRPC thread pool that polls for internal RPC events. Can be only invoked before the GrpcEnviroment is started and cannot be changed afterwards. Setting thread pool size is an advanced setting and you should only use it if you know what you are doing. Most users should rely on the default value provided by gRPC library. Note: this method is part of an experimental API that can change or be removed without any prior notice.

    Declaration
    public static void SetThreadPoolSize(int threadCount)
    Parameters
    Type Name Description
    System.Int32 threadCount

    ShutdownChannelsAsync()

    Requests shutdown of all channels created by the current process.

    Declaration
    public static Task ShutdownChannelsAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    Events

    ShuttingDown

    Occurs when GrpcEnvironment is about the start the shutdown logic. If GrpcEnvironment is later initialized and shutdown, the event will be fired again (unless unregistered first).

    Declaration
    public static event EventHandler ShuttingDown
    Event Type
    Type Description
    System.EventHandler
    Back to top Generated by DocFX