<commit_before>package com.outbrain.ob1k.consul;

import com.outbrain.ob1k.HttpRequestMethodType;
import com.outbrain.ob1k.client.ClientBuilder;
import com.outbrain.ob1k.client.targets.SimpleTargetProvider;
import com.outbrain.ob1k.http.common.ContentType;

import java.util.concurrent.TimeUnit;

/**
 * @author <NAME>
 */
public class ConsulAPI {

    private static final String AGENT_BASE_URL = "http://localhost:8500/v1/";


    public static ConsulServiceRegistry getServiceRegistry() {
        return ConsulServiceRegistryHolder.INSTANCE;
    }

    public static ConsulCatalog getCatalog() {
        return ConsulCatalogHolder.INSTANCE;
    }

    public static ConsulHealth getHealth() {
        return ConsulHealthHolder.INSTANCE;
    }

    private static class ConsulServiceRegistryHolder {
        private static final ConsulServiceRegistry INSTANCE = createServiceRegistry();

        private static ConsulServiceRegistry createServiceRegistry() {
            return new ClientBuilder<>(ConsulServiceRegistry.class)
                    .setTargetProvider(new SimpleTargetProvider(AGENT_BASE_URL + "agent/service/"))
                    .bindEndpoint("deregister", HttpRequestMethodType.GET, "deregister/{serviceId}")
                    .setProtocol(ContentType.JSON)
                    .setRequestTimeout(1000)
                    .build();
        }
    }

    private static class ConsulCatalogHolder {
        private static final ConsulCatalog INSTANCE = createCatalog();

        private static ConsulCatalog createCatalog() {
            return new ClientBuilder<>(ConsulCatalog.class)
                    .setTargetProvider(new SimpleTargetProvider(AGENT_BASE_URL + "catalog"))
                    .bindEndpoint("findInstances", HttpRequestMethodType.GET, "service/{service}?dc={dc}")
                    .bindEndpoint("findDcLocalInstances", HttpRequestMethodType.GET, "service/{service}")
                    .bindEndpoint("filterDcLocalInstances", HttpRequestMethodType.GET, "service/{service}?tag={filterTag}")
                    .bindEndpoint("pollDcLocalInstances", HttpRequestMethodType.GET, "service/{service}?tag={filterTag}&index={index}&wait={maxWaitSec}s")
                    .bindEndpoint("services", HttpRequestMethodType.GET, "services?dc={dc}")
                    .setProtocol(ContentType.JSON)
                    .setRequestTimeout(10000)
                    .build();
        }
    }

    private static class ConsulHealthHolder {
        private static final ConsulHealth INSTANCE = createHealth();

        private static ConsulHealth createHealth() {
            final int timeoutSeconds = 30;
            return new ClientBuilder<>(ConsulHealth.class)
                    .setTargetProvider(new SimpleTargetProvider(AGENT_BASE_URL + "health"))
                    .bindEndpoint("filterDcLocalHealthyInstances", HttpRequestMethodType.GET, "service/{service}?passing=true&tag={filterTag}")
                    .bindEndpoint("pollHealthyInstances", HttpRequestMethodType.GET, "service/{service}?passing=true&tag={filterTag}&index={index}&wait=" + timeoutSeconds + "s")
                    .setProtocol(ContentType.JSON)
                    .setRequestTimeout((int) TimeUnit.SECONDS.toMillis(timeoutSeconds))
                    .build();
        }
    }
<commit_msg>Made service queries consistency level "stale".<commit_after>package com.outbrain.ob1k.consul;

import com.outbrain.ob1k.HttpRequestMethodType;
import com.outbrain.ob1k.client.ClientBuilder;
import com.outbrain.ob1k.client.targets.SimpleTargetProvider;
import com.outbrain.ob1k.http.common.ContentType;

import java.util.concurrent.TimeUnit;

/**
 * @author <NAME>
 */
public class ConsulAPI {

    private static final String AGENT_BASE_URL = "http://localhost:8500/v1/";


    public static ConsulServiceRegistry getServiceRegistry() {
        return ConsulServiceRegistryHolder.INSTANCE;
    }

    public static ConsulCatalog getCatalog() {
        return ConsulCatalogHolder.INSTANCE;
    }

    public static ConsulHealth getHealth() {
        return ConsulHealthHolder.INSTANCE;
    }

    private static class ConsulServiceRegistryHolder {
        private static final ConsulServiceRegistry INSTANCE = createServiceRegistry();

        private static ConsulServiceRegistry createServiceRegistry() {
            return new ClientBuilder<>(ConsulServiceRegistry.class)
                    .setTargetProvider(new SimpleTargetProvider(AGENT_BASE_URL + "agent/service/"))
                    .bindEndpoint("deregister", HttpRequestMethodType.GET, "deregister/{serviceId}")
                    .setProtocol(ContentType.JSON)
                    .setRequestTimeout(1000)
                    .build();
        }
    }

    private static class ConsulCatalogHolder {
        private static final ConsulCatalog INSTANCE = createCatalog();

        private static ConsulCatalog createCatalog() {
            return new ClientBuilder<>(ConsulCatalog.class)
                    .setTargetProvider(new SimpleTargetProvider(AGENT_BASE_URL + "catalog"))
                    .bindEndpoint("findInstances", HttpRequestMethodType.GET, "service/{service}?dc={dc}&stale=true")
                    .bindEndpoint("findDcLocalInstances", HttpRequestMethodType.GET, "service/{service}&stale=true")
                    .bindEndpoint("filterDcLocalInstances", HttpRequestMethodType.GET, "service/{service}?tag={filterTag}&stale=true")
                    .bindEndpoint("pollDcLocalInstances", HttpRequestMethodType.GET, "service/{service}?tag={filterTag}&index={index}&wait={maxWaitSec}s&stale=true")
                    .bindEndpoint("services", HttpRequestMethodType.GET, "services?dc={dc}&stale=true")
                    .setProtocol(ContentType.JSON)
                    .setRequestTimeout(10000)
                    .build();
        }
    }

    private static class ConsulHealthHolder {
        private static final ConsulHealth INSTANCE = createHealth();

        private static ConsulHealth createHealth() {
            final int timeoutSeconds = 30;
            return new ClientBuilder<>(ConsulHealth.class)
                    .setTargetProvider(new SimpleTargetProvider(AGENT_BASE_URL + "health"))
                    .bindEndpoint("filterDcLocalHealthyInstances", HttpRequestMethodType.GET, "service/{service}?passing=true&tag={filterTag}&stale=true")
                    .bindEndpoint("pollHealthyInstances", HttpRequestMethodType.GET, "service/{service}?passing=true&stale=true&tag={filterTag}&index={index}&wait=" + timeoutSeconds + "s")
                    .setProtocol(ContentType.JSON)
                    .setRequestTimeout((int) TimeUnit.SECONDS.toMillis(timeoutSeconds))
                    .build();
        }
    }

{'fraction_non_alphanumeric': 0.10025248774691817, 'fraction_numerical': 0.0062379325709193524, 'mean_word_length': 2.8902368573079147, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1088073', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1706, 'n_words': 287}