配置

优质
小牛编辑
134浏览
2023-12-01

Uragano支持硬编码通过方法参数传入配置,也支持Json文件配置,还支持 环境变量 配置

本分只介绍json文件配置,以下是一个完整的Json配置示例

{
  "Uragano": {
    "Server": {
      "Address": "{LOCALIP}",
      "Port": 5001,
      "Weight": 100,
      "certUrl": "",
      "certPwd": "",
    },
    "Client": {
      "DefaultCert": {
        "url": "",
        "pwd": ""
      },
      "ServicesCert": {
        "RPC": {
          "url": "",
          "pwd": ""
        }
      }
    },
    "ServiceDiscovery": {
      "Consul": {
        "Client": {
          "Address": "http://192.168.1.254:8500",
          "Token": "5ece74af-19d1-0e61-b25c-b9665d29f50b",
          "datacenter": "dc1",
          "timeout": 10
        },
        "Service": {
          "Id": null,
          "Name": "RPC",
          "tags": ["tag"],
          "EnableTagOverride": false,
          "meta": {"k":"v"},
          "HealthCheckInterval": 10
        }
      },
      "ZooKeeper": {
        "Client": {
          "ConnectionString": "localhost:2181",
          "SessionTimeout": 10000,
          "CanBeReadOnly": false
        },
        "Service": {
          "Name": "RPC",
          "Id": null
        }
      }
    },
    "CircuitBreaker": {
      "Polly": {
        "timeout": 2000,
        "retry": 3,
        "ExceptionsAllowedBeforeBreaking": 10,
        "DurationOfBreak": 60000,
        "MaxParallelization": 0,
        "MaxQueuingActions": 0
      }
    },
    "Caching": {
      "Redis": {
        "KeyPrefix": "Uragano",
        "ExpireSeconds": 3600,
        "ConnectionStrings": [
          {
            "Host": "192.168.1.254",
            "Port": 6379,
            "Password": "nihao123",
            "DefaultDatabase": 13,
            "PoolSize": 50,
            "SSL": false,
            "ConnectionTimeout": -1,
            "PreHeat": true,
            "WriteBuffer": 10240,
            "TryIt": 0,
            "Name": ""
          }
        ]
      },
      "Memory": {
        "ExpireSeconds": 60
      }
    },
    "Logging": {
      "Exceptionless": {
        "apiKey": "avtkum3kDogGmLjMCQim9wgC8zHDbcrzQEpDNNJ7",
        "ServerUrl": "" 
      }
    },
    "Options": {
      "ThreadPool_MinThreads": 100,
      "DotNetty_Event_Loop_Count": 100,
      "Output_DynamicProxy_SourceCode": true
    }
  }
}
配置说明
Uragano:Server:Address服务监听地址,可使用{LOCALIP}占位符代替使用本机局域网ip
Uragano:Server:Port服务监听端口,默认端口为5730
Uragano:Server:Weight服务权重
Uragano:Server:CertUrlTls证书url,可空,如果填写了此项配置就表示要启用Tls;同一组服务(相同的服务名称)必须使用同一套证书。
Uragano:Service:CertPwdTls证书密码
Uragano:Client:DefaultCert客户端默认证书,当连接的服务器端启用了Tls,并且Uragano:Client:ServicesCert没有配置对应服务的证书时系统会使用默认证书做验证,如此设计是考虑所有服务都使用相同的证书时不需要为每个服务都配置证书。
Uragano:Client:ServicesCert客户端需要访问的服务证书,Key是对应的服务名称,上面示例里的“RPC”即为服务名称。
Uragano:ServiceDiscovery:Consul:Client:Addressconsul agent的地址
Uragano:ServiceDiscovery:Consul:Client:Tokenconsul agent的访问Token
Uragano:ServiceDiscovery:Consul:Client:Datacenterconsul的数据中心,默认为dc1
Uragano:ServiceDiscovery:Consul:Client:Timeoutconsul连接超时时间(秒)
Uragano:ServiceDiscovery:Consul:Service:Id向consul注册的服务id,不设置时默认以{服务地址}:{服务端口}作为id
Uragano:ServiceDiscovery:Consul:Service:Name向consul注册的服务名称
Uragano:ServiceDiscovery:Consul:Service:Tags注册服务的Tags
Uragano:ServiceDiscovery:Consul:Service:EnableTagOverride是否允许覆盖Tags
Uragano:ServiceDiscovery:Consul:Service:Meta注册服务的Meta数据
Uragano:ServiceDiscovery:Consul:Service:HealthCheckInterval健康检查时间间隔(秒)
Uragano:ServiceDiscovery:ZooKeeper:Client:ConnectionStringZK地址
Uragano:erviceDiscovery:ZooKeeper:Client:SessionTimeoutZK会话超时时间(毫秒)
Uragano:ServiceDiscovery:ZooKeeper:Client:CanBeReadOnly是否允许创建的客户端进入只读模式
Uragano:ServiceDiscovery:ZooKeeper:Service:Id向ZK注册的服务id,不设置时默认以{服务地址}:{服务端口}作为id
Uragano:ServiceDiscovery:ZooKeeper:Service:Name向ZK注册的服务名称
Uragano:CircuitBreaker:Polly:timeout熔断超时策略(毫秒),<=0时不启用
Uragano:CircuitBreaker:Polly:retry熔断重试次数,<=0时不启用
Uragano:CircuitBreaker:Polly:ExceptionsAllowedBeforeBreaking多少次异常后打开断路器,<=0时不启用
Uragano:CircuitBreaker:Polly:DurationOfBreak断路器打开后多长时间(毫秒)尝试关闭断路器
Uragano:CircuitBreaker:Polly:MaxParallelization允许的最大并发数,<=0时不控制
Uragano:CircuitBreaker:Polly:MaxQueuingActions允许最大任务排队数量
Uragano:Caching:Redis:KeyPrefix缓存Key的前缀,默认为Uragano
Uragano:Caching:Redis:ExpireSeconds缓存过期时间(秒)
Uragano:Caching:Redis:ConnectionStringsRedis连接字符串,多个,普通模式时用第一个,分片模式根据算法分配,具体参数请参考CSRedis
Uragano:Logging:Exceptionless:ApiKeyExceptionless的apiKey
Uragano:Logging:Exceptionless:ServerUrlExceptionless的服务地址,更多参数请参考Exceptionless