"use strict";(self.webpackChunkgrpc_workshop_doc=self.webpackChunkgrpc_workshop_doc||[]).push([[8466],{3905:(e,t,r)=>{r.d(t,{Zo:()=>s,kt:()=>y});var n=r(7294);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var l=n.createContext({}),p=function(e){var t=n.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},s=function(e){var t=p(e.components);return n.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},f=n.forwardRef((function(e,t){var r=e.components,a=e.mdxType,o=e.originalType,l=e.parentName,s=i(e,["components","mdxType","originalType","parentName"]),u=p(r),f=a,y=u["".concat(l,".").concat(f)]||u[f]||d[f]||o;return r?n.createElement(y,c(c({ref:t},s),{},{components:r})):n.createElement(y,c({ref:t},s))}));function y(e,t){var r=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=r.length,c=new Array(o);c[0]=f;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i[u]="string"==typeof e?e:a,c[1]=i;for(var p=2;p<o;p++)c[p]=r[p];return n.createElement.apply(null,c)}return n.createElement.apply(null,r)}f.displayName="MDXCreateElement"},6603:(e,t,r)=>{r.r(t),r.d(t,{assets:()=>l,contentTitle:()=>c,default:()=>d,frontMatter:()=>o,metadata:()=>i,toc:()=>p});var n=r(7462),a=(r(7294),r(3905));const o={},c="Client factory",i={unversionedId:"Day 1/project-work/mvc-app/client-factory/index",id:"Day 1/project-work/mvc-app/client-factory/index",title:"Client factory",description:"gRPC client factory can be configured to use load balancing:",source:"@site/docs/Day 1/21 - project-work/03-mvc-app/01-client-factory/index.md",sourceDirName:"Day 1/21 - project-work/03-mvc-app/01-client-factory",slug:"/Day 1/project-work/mvc-app/client-factory/",permalink:"/docs/Day 1/project-work/mvc-app/client-factory/",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/Day 1/21 - project-work/03-mvc-app/01-client-factory/index.md",tags:[],version:"current",frontMatter:{},sidebar:"day1",previous:{title:"MVC consumer app",permalink:"/docs/Day 1/project-work/mvc-app/"},next:{title:"Talk Service",permalink:"/docs/Day 1/project-work/talk-service/"}},l={},p=[],s={toc:p},u="wrapper";function d(e){let{components:t,...r}=e;return(0,a.kt)(u,(0,n.Z)({},s,r,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"client-factory"},"Client factory"),(0,a.kt)("p",null,"gRPC client factory can be configured to use load balancing:"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"Configures the client with a load-balancing address."),(0,a.kt)("li",{parentName:"ul"},"Specifies channel credentials."),(0,a.kt)("li",{parentName:"ul"},"Registers DI types with the app's IServiceCollection.")),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-csharp",metastring:"title='Title'",title:"'Title'"},'var builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services\n    .AddGrpcClient<Greeter.GreeterClient>(o =>\n    {\n        o.Address = new Uri("dns:///my-example-host");\n    })\n    .ConfigureChannel(o => o.Credentials = ChannelCredentials.Insecure);\n\nbuilder.Services.AddSingleton<ResolverFactory>(\n    sp => new DnsResolverFactory(refreshInterval: TimeSpan.FromSeconds(30)));\n\nvar app = builder.Build();\n\n')))}d.isMDXComponent=!0}}]);