{"id":21968462,"url":"https://github.com/duyanming/annodemo","last_synced_at":"2025-04-24T07:18:38.982Z","repository":{"id":35945610,"uuid":"219461990","full_name":"duyanming/AnnoDemo","owner":"duyanming","description":"Anno 是一个微服务快速开发框架，底层通讯可以随意切换 grpc、thrift。自带服务发现、调用链追踪、Cron 调度、限流、事件总线、CQRS 、DDD、类似MVC的开发体验，插件化开发。.  Anno is a microservices rapid development framework, the underlying communication can be arbitrary switch GRPC, thrift.Built-in service discovery, call chain tracking, Cron scheduling, current limiting, event bus, CQRS, DDD, similar MVC development experience, plug-in development.","archived":false,"fork":false,"pushed_at":"2022-12-08T09:26:51.000Z","size":1743,"stargazers_count":16,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T07:18:30.144Z","etag":null,"topics":["anno","eventbus","grpc","ioc","microservice","netcore","ratelimit","thrift"],"latest_commit_sha":null,"homepage":"https://duyanming.github.io/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duyanming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-04T09:20:02.000Z","updated_at":"2024-09-05T13:18:08.000Z","dependencies_parsed_at":"2023-01-16T09:45:29.166Z","dependency_job_id":null,"html_url":"https://github.com/duyanming/AnnoDemo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FAnnoDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FAnnoDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FAnnoDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FAnnoDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duyanming","download_url":"https://codeload.github.com/duyanming/AnnoDemo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250580756,"owners_count":21453538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anno","eventbus","grpc","ioc","microservice","netcore","ratelimit","thrift"],"created_at":"2024-11-29T13:56:04.160Z","updated_at":"2025-04-24T07:18:38.956Z","avatar_url":"https://github.com/duyanming.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# AnnoDemo\n    Anno 分布式开发框架 Demo\n\n##  [Java 实现 ](https://github.com/duyanming/anno.thrift-parent) : https://github.com/duyanming/anno.thrift-parent\n\n##  [Demo 在线演示地址](http://140.143.207.244) :http://140.143.207.244\n    账号：anno\n    密码：123456\n# Anno 分布式开发框架\n\n    Anno 是一个分布式开发框架，同时支持 .net core3.1 、.net frameworker4.6.1\n\n## 1、运行Demo\n\n```\n第一步：启动注册中心\n```\n\n\n\n    进入项目文件夹 AnnoDemo\\registryCenter\\bin\\Debug\\netcoreapp3.1 \n    运行命令 dotnet registryCenter.dll\n    看到下图 说明运行成功\n![第一步](https://s1.ax1x.com/2020/07/30/anl5P1.png)\n\n```\n第二步：启动Server \n```\n\n\n\n    Server可以和 AppCenter 不在同一台电脑，也可以运行多个server 也可以负载均衡，高级用法随后介绍\n    进入项目文件夹 AAnnoDemo\\hostingService\\bin\\Debug\\netcoreapp3.1 \n    运行命令 dotnet hostingService.dll\n    看到下图 说明 Server 成功运行 并且已经注册到 注册中心（APPCenter）运行成功\n![第二步](https://s1.ax1x.com/2020/07/30/anlh5R.png)\n\n启动AnnoWeb\n\n    第三步：调用链追踪\n\n![第三步](https://s1.ax1x.com/2020/07/30/anlo26.png)\n\n```\n调用链详情\n```\n\n![第三步](https://s1.ax1x.com/2020/07/30/anlI8x.png)\n\n 第四步：集群路由信息\n\n![第三步](https://s1.ax1x.com/2020/07/30/anGPsK.png)\n\n   ![第三步](https://s1.ax1x.com/2020/07/30/anGNzq.png)\n\n```\n调试邮件接口成功\n```\n\n![第三步](https://s1.ax1x.com/2020/07/30/anJipn.png)\n\n\n\n第五步：服务性能监控\n       \n![第四步](https://s1.ax1x.com/2020/07/30/anlHKO.png)\n\n\n\n# Anno EventBus\n    Eventbus Support  InMemory and Rabbitmq\n## 1、Server配置\n\n```c#\n\t//指定EventHandler的 所在程序集\n\tvar funcs = Anno.Const.Assemblys.Dic.Values.ToList();\n                #region RabbitMQEventBus\n                //消费失败通知\n\n                RabbitMQEventBus.Instance.ErrorNotice += (string exchange, string routingKey, Exception exception, string body) =\u003e\n                        {\n                            Log.Fatal(new { exchange, routingKey, exception, body }, typeof(RabbitMQEventBus));\n                        };\n                EventBusSetting.Default.RabbitConfiguration = new RabbitConfiguration()\n                {\n                    HostName = \"192.168.100.173\",\n                    VirtualHost = \"dev\",\n                    UserName = \"dev\",\n                    Password = \"dev\",\n                    Port = 5672\n                };\n                RabbitMQEventBus.Instance.SubscribeAll(funcs);\n\n                #endregion\n                #region InMemory EventBus\n                EventBus.Instance.ErrorNotice += (string exchange, string routingKey, Exception exception, string body) =\u003e\n                {\n                    Log.Fatal(new { exchange, routingKey, exception, body }, typeof(EventBus));\n                };\n                EventBus.Instance.SubscribeAll(funcs);\n\n```\n\n## 2、EventData配置\n\n```c#\n\n\tusing Anno.EventBus;\n\t\n\tnamespace Events\n\t{\n\t    public class FirstMessageEvent:EventData\n\t    {\n\t        public string Message { get; set; }\n\t    }\n\t}\n\n```\n\n\n## 3、EventHandler配置\n\n```c#\n\t\n\tnamespace Anno.Plugs.SamsundotService.EventHandler\n\t{\n\t    using Anno.EventBus;\n\t    using Events;\n\t\n\t    class FirstMessageEventHandler : IEventHandler\u003cFirstMessageEvent\u003e\n\t    {\n\t        public void Handler(FirstMessageEvent entity)\n\t        {\n\t            Log.Log.Info(new { Plugs= \"Samsundot\",Entity=entity },typeof(FirstMessageEventHandler));\n\t        }\n\t    }\n\t}\n\n```\n\n ```c#\n\t\n\tnamespace Anno.Plugs.YYTestService.EventHandler\n\t{\n\t    using Anno.EventBus;\n\t    using Events;\n\t\n\t    class FirstMessageEventHandler : IEventHandler\u003cFirstMessageEvent\u003e\n\t    {\n\t        public void Handler(FirstMessageEvent entity)\n\t        {\n\t            Log.Log.Info(new { Plugs = \"YYTest\", Entity = entity }, typeof(FirstMessageEventHandler));\n\t        }\n\t    }\n\t    /// \u003csummary\u003e\n\t    /// 异常消费演示，测试 消费失败通知\n\t    /// \u003c/summary\u003e\n\t    class FirstMessageExceptionEventHandler : IEventHandler\u003cFirstMessageEvent\u003e\n\t    {\n\t        public void Handler(FirstMessageEvent entity)\n\t        {\n\t            Log.Log.Info(new { Plugs = \"YYTest\",Handle= \"FirstMessageExceptionEventHandler\", Entity = entity }, typeof(FirstMessageEventHandler));\n\t            throw new Exception(\"异常消费演示，测试 消费失败通知 From FirstMessageExceptionEventHandler!\");\n\t        }\n\t    }\n\t}\n\n ```\n\n## 4、中间件\n### 4.1 缓存中间件\n#### nuget install\n\n```shell\n\nInstall-Package Anno.EngineData.Cache\n\n```\n\n ```c#\n\t\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing Anno.EngineData;\nusing Anno.EngineData.Cache;\n\n\nnamespace Anno.Plugs.CacheRateLimitService\n{\n    public class CacheModule : BaseModule\n    {\n        /*\n        参数1：缓存长度\n        参数2：缓存存活时间\n        参数3：缓存存活时间是否滑动\n        */\n        [CacheLRU(5,6,true)]\n        public ActionResult Cache(string msg)\n        {\n            Console.WriteLine(msg);\n            return new ActionResult(true, null,null,msg);\n        }\n    }\n}\n\n ```\n\n ### 4.2 限流中间件\n#### nuget install\n\n```shell\n\nInstall-Package Anno.EngineData.RateLimit\n\n```\n\n ```c#\n\t\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing Anno.EngineData;\nusing Anno.RateLimit;\n\nnamespace Anno.Plugs.CacheRateLimitService\n{\n    public class LimitModule : BaseModule\n    {\n        /*\n        参数1：限流算法是令牌桶还是漏桶\n        参数2：限流时间片段单位秒\n        参数3：单位时间可以通过的请求个数\n        参数4：桶容量\n        */\n        [EngineData.Limit.RateLimit(LimitingType.TokenBucket,1,5,5)]\n        public ActionResult Limit(string msg)\n        {\n            Console.WriteLine(msg);\n            return new ActionResult(true, null, null, msg);\n        }\n    }\n}\n\n ```\n\n\n\n\n#dotnet\ndotnet publish \"E:\\gitProject\\Anno\\DCS\\AppCenter\\AppCenter.csproj\" -c Release -r linux-x64 -o \"E:\\gitProject\\Anno\\DCS\\AppCenter\\bin\"\n\n#配置文件说明\n```json\n{\n  \"Target\": {\n    \"AppName\": \"traceWeb\",--服务名称\n    \"IpAddress\": \"127.0.0.1\",--注册中心地址\n    \"Port\": 6660,--注册中心端口\n    \"TraceOnOff\": true--启用调用链追踪\n  },\n  \"Limit\": {--限流\n    \"Enable\": true,--是否启用限流\n    \"TagLimits\": [--标签限流\n      {\n        \"channel\": \"*\",--管道\n        \"router\": \"*\",--路由\n        \"timeSpan\": \"10\",--时间片单位秒\n        \"rps\": 1,--时间片内的 有效请求个数\n        \"limitSize\": 2--漏桶容量大小 做缓冲用\n      }\n    ],\n    \"IpLimit\": {--IP限流\n      \"timeSpan\": 1,\n      \"rps\": 20,\n      \"limitSize\": 200\n    },\n    \"WhiteList\": [--白名单\n      \"192.168.1.1\",\n      \"192.168.2.18\"\n    ]\n  }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduyanming%2Fannodemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduyanming%2Fannodemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduyanming%2Fannodemo/lists"}