Skip to main content

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:

type RpcServerConf struct {
service.ServiceConf
ListenOn string
Etcd discov.EtcdConf `json:",optional,inherit"`
Auth bool `json:",optional"`
Redis redis.RedisKeyConf `json:",optional"`
StrictControl bool `json:",optional"`
// setting 0 means no timeout
Timeout int64 `json:",default=2000"`
CpuThreshold int64 `json:",default=900,range=[0:1000]"`
// grpc health check switch
Health bool `json:",default=true"`
Middlewares ServerMiddlewaresConf
}

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.

type EtcdConf struct {
Hosts []string
Key string
ID int64 `json:",optional"`
User string `json:",optional"`
Pass string `json:",optional"`
CertFile string `json:",optional"`
CertKeyFile string `json:",optional=CertFile"`
CACertFile string `json:",optional=CertFile"`
InsecureSkipVerify bool `json:",optional"`
}
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.

type (
// A RedisConf is a redis config.
RedisConf struct {
Host string
Type string `json:",default=node,options=node|cluster"`
Pass string `json:",optional"`
Tls bool `json:",optional"`
}

// A RedisKeyConf is a redis config with key.
RedisKeyConf struct {
RedisConf
Key string
}
)
NameDataTypeMeaningDefault valueRequired?
Hoststringredis address, host+portNoneYES
Typestringredis typenodeNO
PassstringRedis passwordNoneNO
TlsboolEnable tlsfalseNO
Keystringredis keyNoneYES

ServerMiddlewaresConf Configuration:

ServerMiddlewaresConf struct {
Trace bool `json:",default=true"`
Recover bool `json:",default=true"`
Stat bool `json:",default=true"`
Prometheus bool `json:",default=true"`
Breaker bool `json:",default=true"`
}
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