当前位置: 首页 > news >正文

马格南摄影网站怎样让google收录网站

马格南摄影网站,怎样让google收录网站,重庆市建设节能中心网站,网站空间和数据库空间微软官方文档#xff1a;快速入门#xff1a;使用 ASP.NET Core 生成第一个 Orleans 应用 - .NET | Microsoft Learn 项目及引入的nuget库#xff1a; 1、接口项目#xff1b;2、接口实现项目#xff1b;3、silo项目#xff1b;4、客户端项目 其中Microsoft.Orleans.St…微软官方文档快速入门使用 ASP.NET Core 生成第一个 Orleans 应用 - .NET | Microsoft Learn 项目及引入的nuget库 1、接口项目2、接口实现项目3、silo项目4、客户端项目 其中Microsoft.Orleans.Streaming为测试流功能额外添加。  //IHello.cs代码 using System.Reflection;namespace GrainInterfaces {/// summary/// Grain接口/// 从IGrainWithStringKey继承可以使用字符串作为Grain的唯一标识便于理解/// 从IGrainObserver继承为了支持订阅方式双向通信/// /summarypublic interface IHello : IGrainWithStringKey, IGrainObserver{/// summary/// 默认测试接口/// /summary/// param namegreeting/param/// returns/returnsValueTaskstring SayHello(string greeting);/// summary/// 传递复杂对象测试/// /summary/// param nameparam/param/// returns/returnsValueTaskResultA GetResultA(ParamA param);#region 用订阅方式实现双向通信Task NotifyOtherGrain(string grainID, string message);/// summary/// 客户端订阅Grain上的通知消息/// 需要额外的一个IGrainObserver类型对象IChat支持/// /summary/// param nameobserver/param/// returns/returnsTask Subscribe(IChat observer);/// summary/// 解除订阅/// /summary/// param nameobserver/param/// returns/returnsTask Unsubscribe(IChat observer);/// summary/// Grains直接通信,只要有Grains的id,就可以很方便的从客户端或其他grains中拿到grains的引用/// /summary/// param namesender目标grains的id/param/// param namemessage要转发的消息/param/// returns/returnsTask ReceiveBrotherMessage(string sender, string message);#endregion}#region 订阅方式支持类定义/// summary/// Grain类不允许出现属性,为了方便客户端订阅,额外定义一个带Action委托的接口让Chat对象实现/// /summarypublic interface IChatNotify{/// summary/// 收到服务端通知触发事件,客户端指定处理事件/// /summaryActionstring ReceiveAct { get; set; }}/// summary/// 消息订阅支持接口/// /summary[Alias(GrainInterfaces.IChat)]public interface IChat : IGrainObserver{/// summary/// 定义订阅模式消息接收函数/// 注意IChat在客户端实例化,此函数在客户端执行/// /summary/// param namemessage/param/// returns/returns[Alias(ReceiveMessage)]Task ReceiveMessage(string message);}/// summary/// 消息订阅类实现(在客户端实例化)/// /summarypublic class Chat : IChat, IChatNotify{public Actionstring ReceiveAct { get; set; } null;public Task ReceiveMessage(string message){var log ${message} {Assembly.GetEntryAssembly()?.FullName};Console.WriteLine(log);ReceiveAct?.Invoke(message);return Task.CompletedTask;}}#endregion/// summary/// 定义复杂函数参数类型/// 注解GenerateSerializer:告诉Orleans使用其默认的序列化反序列化方式/// /summary[GenerateSerializer]public class ParamA{[Id(0)]public int ID { get; set; }[Id(1)]public int DataLen { get; set; }[Id(2)]public required string Name { get; set; }}/// summary/// 定义复杂函数返回类型/// 注解GenerateSerializer:告诉Orleans使用其默认的序列化反序列化方式/// /summary[GenerateSerializer]public class ResultA{[Id(0)]public int ID { get; set; }[Id(1)]public required string Name { get; set; }[Id(2)]public required byte[] Data { get; set; }}/// summary/// 测试用全局数据定义/// /summarypublic static class GlobalValueDefinition{public const string StreamProviderName StreamProvider;public const string GrainStorageName PubSubStore;public const string ImplicitStreamSubscriptionName RANDOMDATA;} } //HelloGrains.cs using GrainInterfaces; using Microsoft.Extensions.Logging; using Orleans; using Orleans.Streams; using Orleans.Utilities; using System.Net.NetworkInformation;namespace Grains {/// summary/// Hello Grain定义/// [ImplicitStreamSubscription(GlobalValueDefinition.ImplicitStreamSubscriptionName)]/// 这个注解告诉Orleans使用隐式订阅流(简化测试)/// /summary[ImplicitStreamSubscription(GlobalValueDefinition.ImplicitStreamSubscriptionName)]public class HelloGrains :Grain, IHello{private readonly ILogger _logger;private readonly ObserverManagerIChat _subManager;public HelloGrains(ILoggerHelloGrains logger){_logger logger;_subManager new ObserverManagerIChat(TimeSpan.FromMinutes(5), logger);Console.WriteLine(${GrainContext.GrainId});}private IAsyncStreamstring _demoStream;public override Task OnActivateAsync(CancellationToken cancellationToken){#region 流的支持CreateStreamSubscribe().GetAwaiter().GetResult();#endregionreturn base.OnActivateAsync(cancellationToken);}private async Task CreateStreamSubscribe(){var guid this.GetPrimaryKeyString();var streamProvider this.GetStreamProvider(GlobalValueDefinition.StreamProviderName);var streamId StreamId.Create(GlobalValueDefinition.ImplicitStreamSubscriptionName, guid);_demoStream streamProvider.GetStreamstring(streamId);await _demoStream.SubscribeAsyncstring(async (data, token) { Console.WriteLine($*****Hello {data});await Task.CompletedTask;});}#region 订阅支持public Task Subscribe(IChat observer) {_subManager.Subscribe(observer, observer);return Task.CompletedTask;}public Task Unsubscribe(IChat observer) { _subManager.Unsubscribe(observer); return Task.CompletedTask; }//向订阅者发送消息public Task SendUpdateMessage(string message){_subManager.Notify(ss.ReceiveMessage(message));return Task.CompletedTask;}#endregionpublic ValueTaskstring SayHello(string greeting){var response $Client {GrainContext.GrainId} said:{greeting}, so HelloGrain says: Hello;_logger.LogInformation(response);SendUpdateMessage(SendUpdateMessage response);return ValueTask.FromResult(response);}public ValueTaskResultA GetResultA(ParamA param){_logger.LogInformation($Invoke GetResultA({param.ID} {param.Name}));var res new ResultA{ID param.ID 1,Name param.Name,Data new byte[param.DataLen],};return ValueTask.FromResult(res);}public Task NotifyOtherGrain(string otherGrainID, string message){var otherGrainHello GrainFactory.GetGrainIHello(otherGrainID);otherGrainHello.ReceiveBrotherMessage(this.GetPrimaryKeyString(), message);return Task.CompletedTask;}public Task ReceiveBrotherMessage(string sender, string message){SendUpdateMessage($GetBrotherMessage({sender},{message}));return Task.CompletedTask;}} }//Silo服务启动源码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Orleans.Configuration; using Orleans.Serialization; using System.Net; using GrainInterfaces;namespace Silo {public partial class Form1 : Form{public Form1(){InitializeComponent();}private async void button1_Click(object sender, EventArgs e){//本地集群方式部署var primarySiloEndPoint new IPEndPoint(IPAddress.Parse(textBox_IPAddr.Text), 11_111);var silo new HostBuilder().UseOrleans(builder {builder.UseDevelopmentClustering(primarySiloEndPoint).ConfigureClusterOptions(options {options.ClusterId cluster001;options.ServiceId service001;}).ConfigureEndpoints(siloPort: 11_111, gatewayPort: 30_001).ConfigureLogging(logging logging.AddConsole()).AddMemoryStreams(GlobalValueDefinition.StreamProviderName) //unget引入 Microsoft.Orleans.Streaming.AddMemoryGrainStorage(GlobalValueDefinition.GrainStorageName);}).Build();await silo.RunAsync();}//#region 本地测试模式IHostBuilder builder Host.CreateDefaultBuilder(args).UseOrleans(silo {silo.UseLocalhostClustering(11111, 30001, serviceId: service001, clusterId: cluster001).ConfigureLogging(logging logging.AddConsole());}).UseConsoleLifetime();using IHost host builder.Build();await host.RunAsync();//#endregion//#region 专用服务器集群部署//var primarySiloEndPoint new IPEndPoint(IPAddress.Parse(192.168.0.109), 11_111);//var silo new HostBuilder()// .UseOrleans(builder // {// builder.UseDevelopmentClustering(primarySiloEndPoint)// .ConfigureClusterOptions(options // {// options.ClusterId cluster001;// options.ServiceId service001;// })// .ConfigureEndpoints(siloPort: 11_111, gatewayPort: 30_001)// .ConfigureLogging(logging logging.AddConsole());// }).Build();//await silo.RunAsync();//#endregion} }//客户端代码 using GrainInterfaces; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Orleans.Configuration; using Orleans.Serialization.WireProtocol; using Orleans.Streams; using System.Net; using System.Security.AccessControl;namespace WinFormsApp1 {public partial class Form1 : Form{public Form1(){InitializeComponent();}private IClusterClient client null;private IHost host null;private IHello friend1;private IHello friend2;private IChat chat;private async void button1_Click(object sender, EventArgs e){#region 开发者模式连接//IHostBuilder builder Host.CreateDefaultBuilder()// .UseOrleansClient(client // {// client.UseLocalhostClustering(30001, service001, cluster001);// })// .ConfigureLogging(logging logging.AddConsole())// .UseConsoleLifetime();//host builder.Build();//await host.StartAsync();//client host.Services.GetRequiredServiceIClusterClient();#endregionvar PRIMARY_SILO_IP_ADDRESS IPAddress.Parse(textBox_IPAddr.Text);//var PRIMARY_SILO_IP_ADDRESS_1 IPAddress.Parse(192.168.100.101);#region 专用服务器群集模式连接var gateways new IPEndPoint[] {new IPEndPoint(PRIMARY_SILO_IP_ADDRESS, 30_001)};host Host.CreateDefaultBuilder().UseOrleansClient(clientBuilder clientBuilder.UseStaticClustering(gateways).ConfigureClusterOptions(options {options.ClusterId cluster001;options.ServiceId service001;})#region Stream测试.AddMemoryStreams(GlobalValueDefinition.StreamProviderName)#endregion).Build();await host.StartAsync();client host.Services.GetRequiredServiceIClusterClient();#endregion#region 订阅friend1 client.GetGrainIHello(user1);friend2 client.GetGrainIHello(user2);Chat c new Chat();(c as IChatNotify).ReceiveAct ShowLog;chat client.CreateObjectReferenceIChat(c);await friend1.Subscribe(chat);#endregion#region StreamTestawait CreateStreamSubscribe();#endregion}private IAsyncStreamstring _demoStream;private async Task CreateStreamSubscribe(){var clientStreamName clientStream001;var streamProvider client.GetStreamProvider(GlobalValueDefinition.StreamProviderName);var streamId StreamId.Create(GlobalValueDefinition.ImplicitStreamSubscriptionName, clientStreamName);_demoStream streamProvider.GetStreamstring(streamId);await _demoStream.SubscribeAsyncstring(async (data, token) {ShowLog($*****Hello {data});await Task.CompletedTask;});}private async void button2_Click(object sender, EventArgs e){await host.StopAsync();}private async void button3_Click(object sender, EventArgs e){string response await friend1.SayHello(Hi friend!);ShowLog(${friend1.GetPrimaryKeyString()} {response});}private void ShowLog(string log){Invoke(new Action(() {textBox1.AppendText(${log}\r\n);}));}private async void button4_Click(object sender, EventArgs e){string response await friend2.SayHello(Hi friend!);ShowLog(${friend2.GetPrimaryKeyString()} {response});}private async void button5_Click(object sender, EventArgs e){IHello friend client.GetGrainIHello(user1);var dateLen Convert.ToInt32(textBox_DataLen.Text);var result await friend.GetResultA(new ParamA { ID 1, Name henreash, DataLen dateLen });ShowLog($GetResultA({result.ID} {result.Name} {result.Data.Length}));}private void button6_Click(object sender, EventArgs e){friend2.NotifyOtherGrain(friend1.GetPrimaryKeyString(), 让user2转告user1);}private async void button7_Click(object sender, EventArgs e){await _demoStream.OnNextAsync(Send test stream message!);}} }结论:Orleans部署不需要额外的平台,编译后的进程直接启动;通过配置即可做集群扩展.grain和grain间,grain和客户端间很方便实现双向tcp通信.关闭silo服务,客户端访问失败,启动soli服务后客户端可继续访问. 服务器增加Dashboard silo引入nuget库OleansDashboard(8.2.0),配置增加如下内容 可方便查看silo服务器的性能数据
http://www.dnsts.com.cn/news/165680.html

相关文章:

  • 公司网站建设需要考虑什么问题哪个网站是专做宝宝饭的
  • 网站建设丿选择金手指排名15做网站哪些方面会侵权
  • 网站改版 百度地产行业网站建设图片
  • 自己做网站花多少钱东莞seo整站优化代理
  • 做一个交易平台网站的成本制作音乐的软件下载
  • 微信网站开发rem px泉州做网站seo的
  • 网站更新问题张家界百度seo
  • 取名字的网站 优帮云wordpress网站加入商城
  • 网站开发总体设计阳江企业网站建设
  • 定制网站的好处刷赞业务推广网站
  • p2p网站做牛报纸做垂直门户网站
  • 大黔门官方网站建设大气的公司名称大全
  • 驻马店怎么建设自己的网站宁波小程序开发公司
  • 网站怎么提高百度权重禅城南庄网站制作
  • 广州招聘网网站开发h5制作软件app
  • 镇江建设集团网站网站建立需要什么
  • 专业建站源码wordpress仿 模板
  • 某公司网站策划建设网站建设技术网站建设
  • 洛阳霞光建设网站网站建设构想
  • wordpress 本地 搭建网站凡科网站可以做seo优化
  • 太原建站网站模板建网站的支付安全
  • 南京百度网站快速优化天津百度建网站
  • 湛江网站制作江网站制作静态页面加wordpress
  • 装饰公司营销网站建设设计师网站十大网站
  • 沙田东莞网站建设免费做网站有哪些
  • 常德天鹰建设有限公司网站从化营销网站建设
  • 在哪网站建设手机优化怎么关闭
  • 企业网站管理系统 软件著作权注册公司费用深圳
  • 企业网站做的好网站前期准备
  • 凡客vancl的网站标题2018做网站 工具