// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseStaticFiles(); app.UseAuthentication(); app.UseStatusCodePages(); // jimu client var host = new ServiceHostClientBuilder(new ContainerBuilder()) .UseLog4netLogger(new LogOptions { EnableConsoleLog = true, EnableFileLog = true, FileLogLevel = LogLevel.Info | LogLevel.Error, }) .UseConsulForDiscovery("127.0.0.1", 8500, "JimuService") .UseDotNettyForTransfer() .UseHttpForTransfer() .UsePollingAddressSelector() .UseServerHealthCheck(1) .SetRemoteCallerRetryTimes(3) .SetDiscoveryAutoUpdateJobInterval(1) .UseToken(() => { var headers = JimuHttpContext.Current.Request.Headers["Authorization"]; return(headers.Any() ? headers[0] : null); }) .Build(); app.UseJimu(host); host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //app.UseMvc(); var host = new ServiceHostClientBuilder(new Autofac.ContainerBuilder()) .UseLog4netLogger() .UsePollingAddressSelector() .UseDotNettyForTransfer() .UseInServerForDiscovery(new Jimu.DotNettyAddress("127.0.0.1", 8001)) .Build(); app.UseJimu(host); host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // start jimu client host; var host = new ServiceHostClientBuilder(new ContainerBuilder()) .UseConsulForDiscovery("127.0.0.1", 8500, "JimuService-") .UseDotNettyForTransfer() .UseHttpForTransfer() .UsePollingAddressSelector() .Build(); app.UseJimu(host); host.Run(); }
static void Main(string[] args) { Console.WriteLine("Hello client!"); var container = new ContainerBuilder(); var host = new ServiceHostClientBuilder(container) .UseLog4netLogger(new LogOptions { EnableConsoleLog = true }) .UsePollingAddressSelector() .UseInServerForDiscovery(new HttpAddress("127.0.0.1", 8007)) .UseHttpForTransfer() .UseToken(() => "token") .UseServiceProxy(new[] { "IServices" }) .Build(); host.Run(); var proxy = host.Container.Resolve <IServiceProxy>(); var echo = proxy.GetService <IEchoService>(); var name = echo.GetEcho("test"); Console.WriteLine("return: " + name); Console.ReadKey(); }