Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phil-guo/ketchup
ketchup (番茄酱) 是一个基于dotnet core的微服务框架。
https://github.com/phil-guo/ketchup
consul docker dotnet-core grpc k8s microservice rabbitmq redis
Last synced: about 1 month ago
JSON representation
ketchup (番茄酱) 是一个基于dotnet core的微服务框架。
- Host: GitHub
- URL: https://github.com/phil-guo/ketchup
- Owner: phil-guo
- License: mit
- Created: 2020-03-15T06:35:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-31T00:16:13.000Z (almost 2 years ago)
- Last Synced: 2023-11-07T17:19:18.511Z (about 1 year ago)
- Topics: consul, docker, dotnet-core, grpc, k8s, microservice, rabbitmq, redis
- Language: C#
- Homepage:
- Size: 5.36 MB
- Stars: 183
- Watchers: 6
- Forks: 34
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![](https://img.shields.io/badge/.NET%20Core-3.1-brightgreen.svg?style=flat-square)](https://www.microsoft.com/net/download/core)
[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/simple-gr/ketchup/blob/master/LICENSE)# ketchup -- 番茄酱
### 文档: [WiKi](https://github.com/simple-gr/ketchup/wiki).
### ketchup 是一个基于dotnet core的微服务框架。
### 网关:兼容 kong
### rpc:grpc支持远程调用,
### 注册中心:consul,
### 负载均衡算法:轮询、随机、加权随机算法。
### 缓存:redis、memory,
### 消息中间件:rabbitmq
### 附一个 RBAC 的服务设计实现 地址: [zero](https://github.com/simple-gr/ketchup.zero).
![image](https://github.com/simple-gr/ketchup/blob/master/images/design.jpg)## 如何运行起来
## Program中
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.SetBasePath(Directory.GetCurrentDirectory());
config.AddJsonFile("config/server.json", true, true);
}).ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.ConfigureKestrel(options =>
{
var config = AppConfig.ServerOptions;
//使用http2协议
options.Listen(new IPEndPoint(IPAddress.Any, config.Port),
listenOptions => { listenOptions.Protocols = HttpProtocols.Http2; });
})
.UseStartup();
});
}
## Startup中
### 配置config
public Startup(IConfiguration configuration)
{
AppConfig.Configuration = (IConfigurationRoot)configuration;
}
### 添加grpc服务
public void ConfigureServices(IServiceCollection services)
{
// Add things to the service collection.
services.AddGrpc(grpc => grpc.Interceptors.Add());
}
### 添加autofac 注册服务
public void ConfigureContainer(ContainerBuilder builder)
{
// Add things to the Autofac ContainerBuilder.
builder.AddCoreService().RegisterModules();
}
### 配置中间件
public void Configure(IApplicationBuilder app)
{
// Set up the application for development.
ServiceLocator.Current = app.ApplicationServices.GetAutofacRoot();
app.UseRouting();
app.UseKetchupServer();
}
## 服务端server.json配置
"Server": {
"Name": "sample",//服务名称
"Ip": "127.0.0.1",//服务ip
"Port": "5003",//服务端口
"EnableHttp": true, //是否开启http
"Security": {
"Whitelist": "*", //白名单
"BlackList": "" //黑名单
}
}
"Consul": {
"ConnectionString": "127.0.0.1:8500",//consul 的链接地址
"IsHealthCheck": true//是否进行健康检查
}
## 客户端client.json配置
"Consul": {
"ConnectionString": "127.0.0.1:8500",
"IsHealthCheck": true
}QQ 交流群:592407137