0
点赞
收藏
分享

微信扫一扫

spring cloud consul的默认配置和配置项

半秋L 2022-11-06 阅读 91

前缀为 

spring.cloud.consul.discovery


通过这个类,可以看出有哪些配置项。

许多都是有默认值的,如果不喜欢默认值,就可以自己写,然后就会覆盖默认值了。


@Value("${consul.token:${CONSUL_TOKEN:${spring.cloud.consul.token:${SPRING_CLOUD_CONSUL_TOKEN:}}}}")
private String aclToken;

/** Tags to use when registering service. */
private List<String> tags = new ArrayList<>();

/** Is service discovery enabled? */
private boolean enabled = true;

/** Tags to use when registering management service. */
private List<String> managementTags = new ArrayList<>();

/** Alternate server path to invoke for health checking. */
private String healthCheckPath = "/actuator/health";

/** Custom health check url to override default. */
private String healthCheckUrl;

/** Headers to be applied to the Health Check calls. */
private Map<String, List<String>> healthCheckHeaders = new HashMap<>();

/** How often to perform the health check (e.g. 10s), defaults to 10s. */
private String healthCheckInterval = "10s";

/** Timeout for health check (e.g. 10s). */
private String healthCheckTimeout;

/**
* Timeout to deregister services critical for longer than timeout (e.g. 30m).
* Requires consul version 7.x or higher.
*/
private String healthCheckCriticalTimeout;

/**
* IP address to use when accessing service (must also set preferIpAddress to use).
*/
private String ipAddress;

/** Hostname to use when accessing server. */
private String hostname;

/** Port to register the service under (defaults to listening port). */
private Integer port;

/** Port to register the management service under (defaults to management port). */
private Integer managementPort;

private Lifecycle lifecycle = new Lifecycle();

/** Use ip address rather than hostname during registration. */
private boolean preferIpAddress = false;

/** Source of how we will determine the address to use. */
private boolean preferAgentAddress = false;

/** The delay between calls to watch consul catalog in millis, default is 1000. */
private int catalogServicesWatchDelay = 1000;

/** The number of seconds to block while watching consul catalog, default is 2. */
private int catalogServicesWatchTimeout = 2;

/** Service name. */
private String serviceName;

/** Unique service instance id. */
private String instanceId;

/** Service instance zone. */
private String instanceZone;

/** Service instance group. */
private String instanceGroup;

/**
* Service instance zone comes from metadata. This allows changing the metadata tag
* name.
*/
private String defaultZoneMetadataName = "zone";

/** Whether to register an http or https service. */
private String scheme = "http";

/** Suffix to use when registering management service. */
private String managementSuffix = MANAGEMENT;

/**
* Map of serviceId's -> tag to query for in server list. This allows filtering
* services by a single tag.
*/
private Map<String, String> serverListQueryTags = new HashMap<>();

/**
* Map of serviceId's -> datacenter to query for in server list. This allows looking
* up services in another datacenters.
*/
private Map<String, String> datacenters = new HashMap<>();

/** Tag to query for in service list if one is not listed in serverListQueryTags. */
private String defaultQueryTag;

/**
* Add the 'passing` parameter to /v1/health/service/serviceName. This pushes health
* check passing to the server.
*/
private boolean queryPassing = false;

/** Register as a service in consul. */
private boolean register = true;

/** Disable automatic de-registration of service in consul. */
private boolean deregister = true;

/** Register health check in consul. Useful during development of a service. */
private boolean registerHealthCheck = true;

/**
* Throw exceptions during service registration if true, otherwise, log warnings
* (defaults to true).
*/
private boolean failFast = true;

/**
* Skips certificate verification during service checks if true, otherwise runs
* certificate verification.
*/
private Boolean healthCheckTlsSkipVerify;

举报

相关推荐

0 条评论