Service Configuration

Overview

The zRPC service configuration is mainly used to control rpc’s listener addresses, service registration findings, link tracking, logs, intermediaries, etc.

Configuration

zRPC Server Configuration Structure states below:

  1. type RpcServerConf struct {
  2. service.ServiceConf
  3. ListenOn string
  4. Etcd discov.EtcdConf `json:",optional,inherit"`
  5. Auth bool `json:",optional"`
  6. Redis redis.RedisKeyConf `json:",optional"`
  7. StrictControl bool `json:",optional"`
  8. // setting 0 means no timeout
  9. Timeout int64 `json:",default=2000"`
  10. CpuThreshold int64 `json:",default=900,range=[0:1000]"`
  11. // grpc health check switch
  12. Health bool `json:",default=true"`
  13. Middlewares ServerMiddlewaresConf
  14. }

RpcServerConf

NameDataTypeMeaningDefault valueRequired?
ServiceConfServiceConfBasic Service ConfigurationNoneYES
ListenOnstringListening addressNoneYES
EtcdEtcdConfetcd Configuration ItemNoneNO
AuthboolAuth enabledNoneNO
RedisRedisKeyConfrpc authentication, only if Auth is trueNoneNO
StrictControlboolWhether Strict Mode, if an error is Auth failed, otherwise it can be considered successfulNoneNO
Timeoutint64Timeout2000msNO
CpuThresholdint64Downloading threshold,Default 900(90%),Allow range 0 to 1000900NO
HealthboolEnable health checktrueNO
MiddlewaresServerMiddlewaresConfEnable MiddlewareNoneNO

ServiceConfig General Configuration please refer to Basic Service Configuration

EtcdConf

EtcdConf is the parameter that needs to be configured when using the etcd to register a service. If you do not need to register a service using the etcd, you can not configure it.

  1. type EtcdConf struct {
  2. Hosts []string
  3. Key string
  4. ID int64 `json:",optional"`
  5. User string `json:",optional"`
  6. Pass string `json:",optional"`
  7. CertFile string `json:",optional"`
  8. CertKeyFile string `json:",optional=CertFile"`
  9. CACertFile string `json:",optional=CertFile"`
  10. InsecureSkipVerify bool `json:",optional"`
  11. }
NameDataTypeMeaningDefault valueRequired?
HostsString Type Arrayetcd cluster addressNoneYES
KeystringDefines the unique expression of the service, used for service registration discoveryNoneYES
Userstringetcd usernameNoneNO
Passstringetcd passwordNoneNO
CertFiletringCertificate fileNoneNO
CertKeyFilestringPrivate key fileNoneNO
CACertFileStringCA Certificate FileNoneNO

RedisKeyConf

RedisKeyConf is the parameter that needs to be configured when you need to use redis to manage rpc authentication. If you do not need rpc authentication, you can not configure it.

  1. type (
  2. // A RedisConf is a redis config.
  3. RedisConf struct {
  4. Host string
  5. Type string `json:",default=node,options=node|cluster"`
  6. Pass string `json:",optional"`
  7. Tls bool `json:",optional"`
  8. }
  9. // A RedisKeyConf is a redis config with key.
  10. RedisKeyConf struct {
  11. RedisConf
  12. Key string
  13. }
  14. )
NameDataTypeMeaningDefault valueRequired?
Hoststringredis address, host+portNoneYES
Typestringredis typenodeNO
PassstringRedis passwordNoneNO
TlsboolEnable tlsfalseNO
Keystringredis keyNoneYES

ServerMiddlewaresConf Configuration:

  1. ServerMiddlewaresConf struct {
  2. Trace bool `json:",default=true"`
  3. Recover bool `json:",default=true"`
  4. Stat bool `json:",default=true"`
  5. Prometheus bool `json:",default=true"`
  6. Breaker bool `json:",default=true"`
  7. }
NameDataTypeMeaningDefault valueRequired?
TraceboolEnable link trackingtrueNO
RecoverboolWhether or not to enable abnormal capture intermediationtrueNO
StatboolWhether to turn on stats intermediatetrueNO
PrometheusboolEnable Prometheus MiddlewaretrueNO
BreakerboolEnable breaker intermediatetrueNo