{"id":19990815,"url":"https://github.com/phil-guo/ketchup","last_synced_at":"2025-04-28T17:43:27.440Z","repository":{"id":39016625,"uuid":"247414805","full_name":"phil-guo/ketchup","owner":"phil-guo","description":"ketchup （番茄酱） 是一个基于dotnet core的微服务框架。","archived":false,"fork":false,"pushed_at":"2022-12-31T00:16:13.000Z","size":5618,"stargazers_count":193,"open_issues_count":24,"forks_count":36,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-30T11:41:37.327Z","etag":null,"topics":["consul","docker","dotnet-core","grpc","k8s","microservice","rabbitmq","redis"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phil-guo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-15T06:35:45.000Z","updated_at":"2025-02-18T18:58:48.000Z","dependencies_parsed_at":"2023-01-31T17:16:21.621Z","dependency_job_id":null,"html_url":"https://github.com/phil-guo/ketchup","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-guo%2Fketchup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-guo%2Fketchup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-guo%2Fketchup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-guo%2Fketchup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phil-guo","download_url":"https://codeload.github.com/phil-guo/ketchup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251357665,"owners_count":21576751,"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":["consul","docker","dotnet-core","grpc","k8s","microservice","rabbitmq","redis"],"created_at":"2024-11-13T04:51:28.993Z","updated_at":"2025-04-28T17:43:27.424Z","avatar_url":"https://github.com/phil-guo.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"[![](https://img.shields.io/badge/.NET%20Core-3.1-brightgreen.svg?style=flat-square)](https://www.microsoft.com/net/download/core) \n[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/simple-gr/ketchup/blob/master/LICENSE) \n\n# ketchup -- 番茄酱\n### 文档： [WiKi](https://github.com/simple-gr/ketchup/wiki).\n### ketchup 是一个基于dotnet core的微服务框架。\n### 网关：兼容 kong\n### rpc：grpc支持远程调用，\n### 注册中心：consul，\n### 负载均衡算法：轮询、随机、加权随机算法。\n### 缓存：redis、memory，\n### 消息中间件：rabbitmq\n### 附一个 RBAC 的服务设计实现 地址： [zero](https://github.com/simple-gr/ketchup.zero).\n![image](https://github.com/simple-gr/ketchup/blob/master/images/design.jpg)\n\n## 如何运行起来\n## Program中\n        public static IHostBuilder CreateHostBuilder(string[] args)\n        {\n            return Host.CreateDefaultBuilder(args)\n                .UseServiceProviderFactory(new AutofacServiceProviderFactory())\n                .ConfigureAppConfiguration((hostingContext, config) =\u003e\n                {\n                    config.SetBasePath(Directory.GetCurrentDirectory());                    \n                    config.AddJsonFile(\"config/server.json\", true, true); \n                }).ConfigureWebHostDefaults(webBuilder =\u003e\n                {\n                    webBuilder\n                        .ConfigureKestrel(options =\u003e\n                        {\n                            var config = AppConfig.ServerOptions;\n                            //使用http2协议\n                            options.Listen(new IPEndPoint(IPAddress.Any, config.Port),\n                                listenOptions =\u003e { listenOptions.Protocols = HttpProtocols.Http2; });\n                        })\n                        .UseStartup\u003cStartup\u003e();\n                });\n        }\n## Startup中\n###  配置config\n          public Startup(IConfiguration configuration)\n          {\n            AppConfig.Configuration = (IConfigurationRoot)configuration;\n          }\n### 添加grpc服务\n          public void ConfigureServices(IServiceCollection services)\n          {\n            // Add things to the service collection.\n             services.AddGrpc(grpc =\u003e grpc.Interceptors.Add\u003cHystrixCommandIntercept\u003e());\n          }\n### 添加autofac 注册服务\n          public void ConfigureContainer(ContainerBuilder builder)\n          {\n            // Add things to the Autofac ContainerBuilder.\n            builder.AddCoreService().RegisterModules();\n          }\n### 配置中间件\n          public void Configure(IApplicationBuilder app)\n          {\n            // Set up the application for development.\n            ServiceLocator.Current = app.ApplicationServices.GetAutofacRoot();\n            app.UseRouting();\n            app.UseKetchupServer();\n          }\n## 服务端server.json配置\n    \"Server\": {\n       \"Name\": \"sample\",//服务名称\n       \"Ip\": \"127.0.0.1\",//服务ip\n       \"Port\": \"5003\",//服务端口\n       \"EnableHttp\": true, //是否开启http\n       \"Security\": {\n          \"Whitelist\": \"*\", //白名单\n          \"BlackList\": \"\" //黑名单\n       }\n     }\n    \"Consul\": {\n      \"ConnectionString\": \"127.0.0.1:8500\",//consul 的链接地址\n      \"IsHealthCheck\": true//是否进行健康检查\n    }\n## 客户端client.json配置\n     \"Consul\": {\n         \"ConnectionString\": \"127.0.0.1:8500\",\n         \"IsHealthCheck\": true\n     }\n\nQQ 交流群：592407137\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphil-guo%2Fketchup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphil-guo%2Fketchup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphil-guo%2Fketchup/lists"}