类 ConsulDataSource<T>

java.lang.Object
com.alibaba.csp.sentinel.datasource.AbstractDataSource<String,T>
com.alibaba.csp.sentinel.datasource.consul.ConsulDataSource<T>
所有已实现的接口:
com.alibaba.csp.sentinel.datasource.ReadableDataSource<String,T>

public class ConsulDataSource<T> extends com.alibaba.csp.sentinel.datasource.AbstractDataSource<String,T>

A read-only DataSource with Consul backend.

The data source first initial rules from a Consul during initialization. Then it start a watcher to observe the updates of rule date and update to memory. Consul do not provide http api to watch the update of KV,so it use a long polling and blocking queries of the Consul's feature to watch and update value easily.When Querying data by index will blocking until change or timeout. If the index of the current query is larger than before, it means that the data has changed.

作者:
wavesZh, Zhiguo.Chen
  • 构造器详细资料

    • ConsulDataSource

      public ConsulDataSource(String host, String ruleKey, int watchTimeoutInSecond, com.alibaba.csp.sentinel.datasource.Converter<String,T> parser)
    • ConsulDataSource

      public ConsulDataSource(String host, int port, String ruleKey, int watchTimeout, com.alibaba.csp.sentinel.datasource.Converter<String,T> parser)
      Constructor of ConsulDataSource.
      参数:
      host - consul agent host
      port - consul agent port
      ruleKey - data key in Consul
      watchTimeout - request for querying data will be blocked until new data or timeout. The unit is second (s)
      parser - customized data parser, cannot be empty
    • ConsulDataSource

      public ConsulDataSource(String host, int port, String token, String ruleKey, int watchTimeout, com.alibaba.csp.sentinel.datasource.Converter<String,T> parser)
      Constructor of ConsulDataSource.
      参数:
      host - consul agent host
      port - consul agent port
      token - consul agent acl token
      ruleKey - data key in Consul
      watchTimeout - request for querying data will be blocked until new data or timeout. The unit is second (s)
      parser - customized data parser, cannot be empty
  • 方法详细资料