Skip to content

Latest commit

 

History

History
100 lines (88 loc) · 2.92 KB

README.md

File metadata and controls

100 lines (88 loc) · 2.92 KB

Logo

Elect.Consul

Author Top Nguyen

Overview

  • Support auto Register and Deregister Service to the Consul Service.
  • Auto generate Name of Service, ID and Tags support for Fabio Load Balancing.

Installation

Consul Service

  • Download Consul

    • If MacOS, can install via brew
    brew install consul
  • Create a setting file named 'consul-config.json'

    {
      "primary_datacenter": "dc1",
      "data_dir": "<directory folder path>",
      "server": true,
      "bootstrap": true,
      "ui": true,
      "ports": {
        "http": 8500
      },
      "addresses": {
        "http": "0.0.0.0"
      },
      "acl" : {
        "enabled": true,
        "default_policy": "deny",
        "enable_token_persistence": true,
        "tokens": {
          "master": "<your generation unique key>",
          "default": "<your generation unique key>"
        }
      }
    }
    • Please adjust the data_dir (Folder to save Consul Data) and acl.tokens.default (Access Token).
      • The acl.tokens.default use for protect both UI and Agent services.
      • When you access the Consul Service, need key-in the token to view the registered services.
  • Run Consul Agent with config

    consul agent -config-file="<Your Path>/consul-config.json" -bind={{GetPrivateIP}}
  • Consul by default

Fabio Service (Optional)

Elect Consul Nuget

  • Package Manager

    PM> Install-Package Elect.Consul
    
  • .NET CLI

    dotnet add package Elect.Consul
    

See more information in Nuget.

Usage

  • Add Service
    • You can config endpoint via ElectConsulOptions.
    • By defaut already bind to the default endpoint, port from Consul Service.
    services.AddElectHealthCheck();
    services.AddElectConsul();
  • Use Service
    app.UseElectHealthCheck();
  • Note
    • You must add the Elect.HealthCheck service before use Elect.Consul service.
    • The HealCheck needed for healthy check to make Fabio Service work well.

      Fabio only load balancing for pass health check services.

License

Elect.Consul is licensed under the MIT License.