Java源码示例:com.orbitz.consul.option.ImmutableQueryOptions

示例1
private void setupWatcher(String serviceName) {
    if (watchers.containsKey(serviceName)) {
        return;
    }
    QueryOptions options = ImmutableQueryOptions.builder()
            .build();

    ServiceHealthCache healthCache = ServiceHealthCache.newCache(
            this.healthClientInjector.getValue(),
            serviceName,
            true,
            options,
            5
    );

    try {
        healthCache.addListener(new ServiceCacheListener(serviceName, this.topologyManagerInjector.getValue()));
        healthCache.start();
        healthCache.awaitInitialized(1, TimeUnit.SECONDS);
        this.watchers.put(serviceName, healthCache);
    } catch (Exception e) {
        ConsulTopologyMessages.MESSAGES.errorSettingUpCatalogWatcher(serviceName, e);
    }
}
 
示例2
/**
 * Method to build an ACL token in a query option.
 * 
 * @param token
 * @return QueryOption
 */
public static QueryOptions getAclToken(String token){
	
	if(token == null || token.trim().isEmpty()){
		return ImmutableQueryOptions.BLANK;
	}
	
	//ACL token for registering as a service on consul, check health and get service catalog
	ImmutableQueryOptions.Builder optionBuilder = ImmutableQueryOptions.builder().token(token);
	return optionBuilder.build();
}