sl-express/sentinel/sentinel-extension/sentinel-datasource-consul/README.md

29 lines
841 B
Markdown
Raw Normal View History

2023-09-04 16:40:17 +08:00
# Sentinel DataSource Consul
Sentinel DataSource Consul provides integration with Consul. The data source leverages blocking query (backed by
long polling) of Consul.
## Usage
To use Sentinel DataSource Consul, you could add the following dependency:
```xml
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-consul</artifactId>
<version>x.y.z</version>
</dependency>
```
Then you can create a `ConsulDataSource` and register to rule managers.
For instance:
```java
ReadableDataSource<String, List<FlowRule>> dataSource = new ConsulDataSource<>(host, port, ruleKey, waitTimeoutInSecond, flowConfigParser);
FlowRuleManager.register2Property(dataSource.getProperty());
```
- `ruleKey`: the rule persistence key
- `waitTimeoutInSecond`: long polling timeout (in second) of the Consul API client