Giter VIP home page Giter VIP logo

ketchup's Introduction

GitHub license

ketchup -- 番茄酱

文档: WiKi.

ketchup 是一个基于dotnet core的微服务框架。

网关:兼容 kong

rpc:grpc支持远程调用,

注册中心:consul,

负载均衡算法:轮询、随机、加权随机算法。

缓存:redis、memory,

消息中间件:rabbitmq

附一个 RBAC 的服务设计实现 地址: zero.

image

如何运行起来

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>();
            });
    }

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<HystrixCommandIntercept>());
      }

添加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
 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.