Grpc.Core.GrpcEnvironment.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <!DOCTYPE html>
  2. <!--[if IE]><![endif]-->
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <title>Class GrpcEnvironment
  8. | gRPC C# </title>
  9. <meta name="viewport" content="width=device-width">
  10. <meta name="title" content="Class GrpcEnvironment
  11. | gRPC C# ">
  12. <meta name="generator" content="docfx 2.36.0.0">
  13. <link rel="shortcut icon" href="../favicon.ico">
  14. <link rel="stylesheet" href="../styles/docfx.vendor.css">
  15. <link rel="stylesheet" href="../styles/docfx.css">
  16. <link rel="stylesheet" href="../styles/main.css">
  17. <meta property="docfx:navrel" content="../toc.html">
  18. <meta property="docfx:tocrel" content="toc.html">
  19. <meta property="docfx:rel" content="../">
  20. </head>
  21. <body data-spy="scroll" data-target="#affix" data-offset="120">
  22. <div id="wrapper">
  23. <header>
  24. <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
  25. <div class="container">
  26. <div class="navbar-header">
  27. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
  28. <span class="sr-only">Toggle navigation</span>
  29. <span class="icon-bar"></span>
  30. <span class="icon-bar"></span>
  31. <span class="icon-bar"></span>
  32. </button>
  33. <a class="navbar-brand" href="../index.html">
  34. <img id="logo" class="svg" src="../logo.svg" alt="">
  35. </a>
  36. </div>
  37. <div class="collapse navbar-collapse" id="navbar">
  38. <form class="navbar-form navbar-right" role="search" id="search">
  39. <div class="form-group">
  40. <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
  41. </div>
  42. </form>
  43. </div>
  44. </div>
  45. </nav>
  46. <div class="subnav navbar navbar-default">
  47. <div class="container hide-when-search" id="breadcrumb">
  48. <ul class="breadcrumb">
  49. <li></li>
  50. </ul>
  51. </div>
  52. </div>
  53. </header>
  54. <div class="container body-content">
  55. <div id="search-results">
  56. <div class="search-list"></div>
  57. <div class="sr-items">
  58. <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
  59. </div>
  60. <ul id="pagination"></ul>
  61. </div>
  62. </div>
  63. <div role="main" class="container body-content hide-when-search">
  64. <div class="sidenav hide-when-search">
  65. <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
  66. <div class="sidetoggle collapse" id="sidetoggle">
  67. <div id="sidetoc"></div>
  68. </div>
  69. </div>
  70. <div class="article row grid-right">
  71. <div class="col-md-10">
  72. <article class="content wrap" id="_content" data-uid="Grpc.Core.GrpcEnvironment">
  73. <h1 id="Grpc_Core_GrpcEnvironment" data-uid="Grpc.Core.GrpcEnvironment" class="text-break">Class GrpcEnvironment
  74. </h1>
  75. <div class="markdown level0 summary"><p>Encapsulates initialization and shutdown of gRPC library.</p>
  76. </div>
  77. <div class="markdown level0 conceptual"></div>
  78. <div class="inheritance">
  79. <h5>Inheritance</h5>
  80. <div class="level0"><span class="xref">System.Object</span></div>
  81. <div class="level1"><span class="xref">GrpcEnvironment</span></div>
  82. </div>
  83. <div class="inheritedMembers">
  84. <h5>Inherited Members</h5>
  85. <div>
  86. <span class="xref">System.Object.Equals(System.Object)</span>
  87. </div>
  88. <div>
  89. <span class="xref">System.Object.Equals(System.Object, System.Object)</span>
  90. </div>
  91. <div>
  92. <span class="xref">System.Object.GetHashCode()</span>
  93. </div>
  94. <div>
  95. <span class="xref">System.Object.GetType()</span>
  96. </div>
  97. <div>
  98. <span class="xref">System.Object.MemberwiseClone()</span>
  99. </div>
  100. <div>
  101. <span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
  102. </div>
  103. <div>
  104. <span class="xref">System.Object.ToString()</span>
  105. </div>
  106. </div>
  107. <h6><strong>Namespace</strong>: <a class="xref" href="Grpc.Core.html">Grpc.Core</a></h6>
  108. <h6><strong>Assembly</strong>: Grpc.Core.dll</h6>
  109. <h5 id="Grpc_Core_GrpcEnvironment_syntax">Syntax</h5>
  110. <div class="codewrapper">
  111. <pre><code class="lang-csharp hljs">public class GrpcEnvironment</code></pre>
  112. </div>
  113. <h3 id="properties">Properties
  114. </h3>
  115. <a id="Grpc_Core_GrpcEnvironment_Logger_" data-uid="Grpc.Core.GrpcEnvironment.Logger*"></a>
  116. <h4 id="Grpc_Core_GrpcEnvironment_Logger" data-uid="Grpc.Core.GrpcEnvironment.Logger">Logger</h4>
  117. <div class="markdown level1 summary"><p>Gets application-wide logger used by gRPC.</p>
  118. </div>
  119. <div class="markdown level1 conceptual"></div>
  120. <h5 class="decalaration">Declaration</h5>
  121. <div class="codewrapper">
  122. <pre><code class="lang-csharp hljs">public static ILogger Logger { get; }</code></pre>
  123. </div>
  124. <h5 class="propertyValue">Property Value</h5>
  125. <table class="table table-bordered table-striped table-condensed">
  126. <thead>
  127. <tr>
  128. <th>Type</th>
  129. <th>Description</th>
  130. </tr>
  131. </thead>
  132. <tbody>
  133. <tr>
  134. <td><a class="xref" href="Grpc.Core.Logging.ILogger.html">ILogger</a></td>
  135. <td><p>The logger.</p>
  136. </td>
  137. </tr>
  138. </tbody>
  139. </table>
  140. <h3 id="methods">Methods
  141. </h3>
  142. <a id="Grpc_Core_GrpcEnvironment_KillServersAsync_" data-uid="Grpc.Core.GrpcEnvironment.KillServersAsync*"></a>
  143. <h4 id="Grpc_Core_GrpcEnvironment_KillServersAsync" data-uid="Grpc.Core.GrpcEnvironment.KillServersAsync">KillServersAsync()</h4>
  144. <div class="markdown level1 summary"><p>Requests immediate shutdown of all servers created by the current process.</p>
  145. </div>
  146. <div class="markdown level1 conceptual"></div>
  147. <h5 class="decalaration">Declaration</h5>
  148. <div class="codewrapper">
  149. <pre><code class="lang-csharp hljs">public static Task KillServersAsync()</code></pre>
  150. </div>
  151. <h5 class="returns">Returns</h5>
  152. <table class="table table-bordered table-striped table-condensed">
  153. <thead>
  154. <tr>
  155. <th>Type</th>
  156. <th>Description</th>
  157. </tr>
  158. </thead>
  159. <tbody>
  160. <tr>
  161. <td><span class="xref">System.Threading.Tasks.Task</span></td>
  162. <td></td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <a id="Grpc_Core_GrpcEnvironment_SetBatchContextPoolParams_" data-uid="Grpc.Core.GrpcEnvironment.SetBatchContextPoolParams*"></a>
  167. <h4 id="Grpc_Core_GrpcEnvironment_SetBatchContextPoolParams_System_Int32_System_Int32_" data-uid="Grpc.Core.GrpcEnvironment.SetBatchContextPoolParams(System.Int32,System.Int32)">SetBatchContextPoolParams(Int32, Int32)</h4>
  168. <div class="markdown level1 summary"><p>Sets the parameters for a pool that caches batch context instances. Reusing batch context instances
  169. instead of creating a new one for every C core operation helps reducing the GC pressure.
  170. Can be only invoked before the <code>GrpcEnviroment</code> is started and cannot be changed afterwards.
  171. This is an advanced setting and you should only use it if you know what you are doing.
  172. Most users should rely on the default value provided by gRPC library.
  173. Note: this method is part of an experimental API that can change or be removed without any prior notice.</p>
  174. </div>
  175. <div class="markdown level1 conceptual"></div>
  176. <h5 class="decalaration">Declaration</h5>
  177. <div class="codewrapper">
  178. <pre><code class="lang-csharp hljs">public static void SetBatchContextPoolParams(int sharedCapacity, int threadLocalCapacity)</code></pre>
  179. </div>
  180. <h5 class="parameters">Parameters</h5>
  181. <table class="table table-bordered table-striped table-condensed">
  182. <thead>
  183. <tr>
  184. <th>Type</th>
  185. <th>Name</th>
  186. <th>Description</th>
  187. </tr>
  188. </thead>
  189. <tbody>
  190. <tr>
  191. <td><span class="xref">System.Int32</span></td>
  192. <td><span class="parametername">sharedCapacity</span></td>
  193. <td></td>
  194. </tr>
  195. <tr>
  196. <td><span class="xref">System.Int32</span></td>
  197. <td><span class="parametername">threadLocalCapacity</span></td>
  198. <td></td>
  199. </tr>
  200. </tbody>
  201. </table>
  202. <a id="Grpc_Core_GrpcEnvironment_SetCompletionQueueCount_" data-uid="Grpc.Core.GrpcEnvironment.SetCompletionQueueCount*"></a>
  203. <h4 id="Grpc_Core_GrpcEnvironment_SetCompletionQueueCount_System_Int32_" data-uid="Grpc.Core.GrpcEnvironment.SetCompletionQueueCount(System.Int32)">SetCompletionQueueCount(Int32)</h4>
  204. <div class="markdown level1 summary"><p>Sets the number of completion queues in the gRPC thread pool that polls for internal RPC events.
  205. Can be only invoked before the <code>GrpcEnviroment</code> is started and cannot be changed afterwards.
  206. Setting the number of completions queues is an advanced setting and you should only use it if you know what you are doing.
  207. Most users should rely on the default value provided by gRPC library.
  208. Note: this method is part of an experimental API that can change or be removed without any prior notice.</p>
  209. </div>
  210. <div class="markdown level1 conceptual"></div>
  211. <h5 class="decalaration">Declaration</h5>
  212. <div class="codewrapper">
  213. <pre><code class="lang-csharp hljs">public static void SetCompletionQueueCount(int completionQueueCount)</code></pre>
  214. </div>
  215. <h5 class="parameters">Parameters</h5>
  216. <table class="table table-bordered table-striped table-condensed">
  217. <thead>
  218. <tr>
  219. <th>Type</th>
  220. <th>Name</th>
  221. <th>Description</th>
  222. </tr>
  223. </thead>
  224. <tbody>
  225. <tr>
  226. <td><span class="xref">System.Int32</span></td>
  227. <td><span class="parametername">completionQueueCount</span></td>
  228. <td></td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. <a id="Grpc_Core_GrpcEnvironment_SetHandlerInlining_" data-uid="Grpc.Core.GrpcEnvironment.SetHandlerInlining*"></a>
  233. <h4 id="Grpc_Core_GrpcEnvironment_SetHandlerInlining_System_Boolean_" data-uid="Grpc.Core.GrpcEnvironment.SetHandlerInlining(System.Boolean)">SetHandlerInlining(Boolean)</h4>
  234. <div class="markdown level1 summary"><p>By default, gRPC&apos;s internal event handlers get offloaded to .NET default thread pool thread (<code>inlineHandlers=false</code>).
  235. Setting <code>inlineHandlers</code> to <code>true</code> will allow scheduling the event handlers directly to
  236. <code>GrpcThreadPool</code> internal threads. That can lead to significant performance gains in some situations,
  237. but requires user to never block in async code (incorrectly written code can easily lead to deadlocks).
  238. Inlining handlers is an advanced setting and you should only use it if you know what you are doing.
  239. Most users should rely on the default value provided by gRPC library.
  240. Note: this method is part of an experimental API that can change or be removed without any prior notice.
  241. Note: <code>inlineHandlers=true</code> was the default in gRPC C# v1.4.x and earlier.</p>
  242. </div>
  243. <div class="markdown level1 conceptual"></div>
  244. <h5 class="decalaration">Declaration</h5>
  245. <div class="codewrapper">
  246. <pre><code class="lang-csharp hljs">public static void SetHandlerInlining(bool inlineHandlers)</code></pre>
  247. </div>
  248. <h5 class="parameters">Parameters</h5>
  249. <table class="table table-bordered table-striped table-condensed">
  250. <thead>
  251. <tr>
  252. <th>Type</th>
  253. <th>Name</th>
  254. <th>Description</th>
  255. </tr>
  256. </thead>
  257. <tbody>
  258. <tr>
  259. <td><span class="xref">System.Boolean</span></td>
  260. <td><span class="parametername">inlineHandlers</span></td>
  261. <td></td>
  262. </tr>
  263. </tbody>
  264. </table>
  265. <a id="Grpc_Core_GrpcEnvironment_SetLogger_" data-uid="Grpc.Core.GrpcEnvironment.SetLogger*"></a>
  266. <h4 id="Grpc_Core_GrpcEnvironment_SetLogger_Grpc_Core_Logging_ILogger_" data-uid="Grpc.Core.GrpcEnvironment.SetLogger(Grpc.Core.Logging.ILogger)">SetLogger(ILogger)</h4>
  267. <div class="markdown level1 summary"><p>Sets the application-wide logger that should be used by gRPC.</p>
  268. </div>
  269. <div class="markdown level1 conceptual"></div>
  270. <h5 class="decalaration">Declaration</h5>
  271. <div class="codewrapper">
  272. <pre><code class="lang-csharp hljs">public static void SetLogger(ILogger customLogger)</code></pre>
  273. </div>
  274. <h5 class="parameters">Parameters</h5>
  275. <table class="table table-bordered table-striped table-condensed">
  276. <thead>
  277. <tr>
  278. <th>Type</th>
  279. <th>Name</th>
  280. <th>Description</th>
  281. </tr>
  282. </thead>
  283. <tbody>
  284. <tr>
  285. <td><a class="xref" href="Grpc.Core.Logging.ILogger.html">ILogger</a></td>
  286. <td><span class="parametername">customLogger</span></td>
  287. <td></td>
  288. </tr>
  289. </tbody>
  290. </table>
  291. <a id="Grpc_Core_GrpcEnvironment_SetRequestCallContextPoolParams_" data-uid="Grpc.Core.GrpcEnvironment.SetRequestCallContextPoolParams*"></a>
  292. <h4 id="Grpc_Core_GrpcEnvironment_SetRequestCallContextPoolParams_System_Int32_System_Int32_" data-uid="Grpc.Core.GrpcEnvironment.SetRequestCallContextPoolParams(System.Int32,System.Int32)">SetRequestCallContextPoolParams(Int32, Int32)</h4>
  293. <div class="markdown level1 summary"><p>Sets the parameters for a pool that caches request call context instances. Reusing request call context instances
  294. instead of creating a new one for every requested call in C core helps reducing the GC pressure.
  295. Can be only invoked before the <code>GrpcEnviroment</code> is started and cannot be changed afterwards.
  296. This is an advanced setting and you should only use it if you know what you are doing.
  297. Most users should rely on the default value provided by gRPC library.
  298. Note: this method is part of an experimental API that can change or be removed without any prior notice.</p>
  299. </div>
  300. <div class="markdown level1 conceptual"></div>
  301. <h5 class="decalaration">Declaration</h5>
  302. <div class="codewrapper">
  303. <pre><code class="lang-csharp hljs">public static void SetRequestCallContextPoolParams(int sharedCapacity, int threadLocalCapacity)</code></pre>
  304. </div>
  305. <h5 class="parameters">Parameters</h5>
  306. <table class="table table-bordered table-striped table-condensed">
  307. <thead>
  308. <tr>
  309. <th>Type</th>
  310. <th>Name</th>
  311. <th>Description</th>
  312. </tr>
  313. </thead>
  314. <tbody>
  315. <tr>
  316. <td><span class="xref">System.Int32</span></td>
  317. <td><span class="parametername">sharedCapacity</span></td>
  318. <td></td>
  319. </tr>
  320. <tr>
  321. <td><span class="xref">System.Int32</span></td>
  322. <td><span class="parametername">threadLocalCapacity</span></td>
  323. <td></td>
  324. </tr>
  325. </tbody>
  326. </table>
  327. <a id="Grpc_Core_GrpcEnvironment_SetThreadPoolSize_" data-uid="Grpc.Core.GrpcEnvironment.SetThreadPoolSize*"></a>
  328. <h4 id="Grpc_Core_GrpcEnvironment_SetThreadPoolSize_System_Int32_" data-uid="Grpc.Core.GrpcEnvironment.SetThreadPoolSize(System.Int32)">SetThreadPoolSize(Int32)</h4>
  329. <div class="markdown level1 summary"><p>Sets the number of threads in the gRPC thread pool that polls for internal RPC events.
  330. Can be only invoked before the <code>GrpcEnviroment</code> is started and cannot be changed afterwards.
  331. Setting thread pool size is an advanced setting and you should only use it if you know what you are doing.
  332. Most users should rely on the default value provided by gRPC library.
  333. Note: this method is part of an experimental API that can change or be removed without any prior notice.</p>
  334. </div>
  335. <div class="markdown level1 conceptual"></div>
  336. <h5 class="decalaration">Declaration</h5>
  337. <div class="codewrapper">
  338. <pre><code class="lang-csharp hljs">public static void SetThreadPoolSize(int threadCount)</code></pre>
  339. </div>
  340. <h5 class="parameters">Parameters</h5>
  341. <table class="table table-bordered table-striped table-condensed">
  342. <thead>
  343. <tr>
  344. <th>Type</th>
  345. <th>Name</th>
  346. <th>Description</th>
  347. </tr>
  348. </thead>
  349. <tbody>
  350. <tr>
  351. <td><span class="xref">System.Int32</span></td>
  352. <td><span class="parametername">threadCount</span></td>
  353. <td></td>
  354. </tr>
  355. </tbody>
  356. </table>
  357. <a id="Grpc_Core_GrpcEnvironment_ShutdownChannelsAsync_" data-uid="Grpc.Core.GrpcEnvironment.ShutdownChannelsAsync*"></a>
  358. <h4 id="Grpc_Core_GrpcEnvironment_ShutdownChannelsAsync" data-uid="Grpc.Core.GrpcEnvironment.ShutdownChannelsAsync">ShutdownChannelsAsync()</h4>
  359. <div class="markdown level1 summary"><p>Requests shutdown of all channels created by the current process.</p>
  360. </div>
  361. <div class="markdown level1 conceptual"></div>
  362. <h5 class="decalaration">Declaration</h5>
  363. <div class="codewrapper">
  364. <pre><code class="lang-csharp hljs">public static Task ShutdownChannelsAsync()</code></pre>
  365. </div>
  366. <h5 class="returns">Returns</h5>
  367. <table class="table table-bordered table-striped table-condensed">
  368. <thead>
  369. <tr>
  370. <th>Type</th>
  371. <th>Description</th>
  372. </tr>
  373. </thead>
  374. <tbody>
  375. <tr>
  376. <td><span class="xref">System.Threading.Tasks.Task</span></td>
  377. <td></td>
  378. </tr>
  379. </tbody>
  380. </table>
  381. <h3 id="events">Events
  382. </h3>
  383. <h4 id="Grpc_Core_GrpcEnvironment_ShuttingDown" data-uid="Grpc.Core.GrpcEnvironment.ShuttingDown">ShuttingDown</h4>
  384. <div class="markdown level1 summary"><p>Occurs when <code>GrpcEnvironment</code> is about the start the shutdown logic.
  385. If <code>GrpcEnvironment</code> is later initialized and shutdown, the event will be fired again (unless unregistered first).</p>
  386. </div>
  387. <div class="markdown level1 conceptual"></div>
  388. <h5 class="decalaration">Declaration</h5>
  389. <div class="codewrapper">
  390. <pre><code class="lang-csharp hljs">public static event EventHandler ShuttingDown</code></pre>
  391. </div>
  392. <h5 class="eventType">Event Type</h5>
  393. <table class="table table-bordered table-striped table-condensed">
  394. <thead>
  395. <tr>
  396. <th>Type</th>
  397. <th>Description</th>
  398. </tr>
  399. </thead>
  400. <tbody>
  401. <tr>
  402. <td><span class="xref">System.EventHandler</span></td>
  403. <td></td>
  404. </tr>
  405. </tbody>
  406. </table>
  407. </article>
  408. </div>
  409. <div class="hidden-sm col-md-2" role="complementary">
  410. <div class="sideaffix">
  411. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  412. <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
  413. </nav>
  414. </div>
  415. </div>
  416. </div>
  417. </div>
  418. <footer>
  419. <div class="grad-bottom"></div>
  420. <div class="footer">
  421. <div class="container">
  422. <span class="pull-right">
  423. <a href="#top">Back to top</a>
  424. </span>
  425. <span>Generated by <strong>DocFX</strong></span>
  426. </div>
  427. </div>
  428. </footer>
  429. </div>
  430. <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
  431. <script type="text/javascript" src="../styles/docfx.js"></script>
  432. <script type="text/javascript" src="../styles/main.js"></script>
  433. </body>
  434. </html>