Search in sources :

Example 1 with ResilienceRegistries

use of org.knowm.xchange.client.ResilienceRegistries in project XChange by knowm.

the class OkexResilience method createRegistries.

public static ResilienceRegistries createRegistries() {
    final ResilienceRegistries registries = new ResilienceRegistries();
    Okex.publicPathRateLimits.forEach((path, limit) -> {
        registries.rateLimiters().rateLimiter(path, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofSeconds(limit.get(1))).limitForPeriod(limit.get(0)).drainPermissionsOnResult(e -> ResilienceUtils.matchesHttpCode(e, TOO_MANY_REQUESTS)).build());
    });
    OkexAuthenticated.privatePathRateLimits.forEach((path, limit) -> {
        registries.rateLimiters().rateLimiter(path, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofSeconds(limit.get(1))).limitForPeriod(limit.get(0)).drainPermissionsOnResult(e -> ResilienceUtils.matchesHttpCode(e, TOO_MANY_REQUESTS)).build());
    });
    return registries;
}
Also used : ResilienceRegistries(org.knowm.xchange.client.ResilienceRegistries)

Example 2 with ResilienceRegistries

use of org.knowm.xchange.client.ResilienceRegistries in project XChange by knowm.

the class BinanceResilience method createRegistries.

public static ResilienceRegistries createRegistries() {
    ResilienceRegistries registries = new ResilienceRegistries();
    registries.rateLimiters().rateLimiter(REQUEST_WEIGHT_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).timeoutDuration(Duration.ofMinutes(1)).limitRefreshPeriod(Duration.ofMinutes(1)).limitForPeriod(1200).build());
    registries.rateLimiters().rateLimiter(ORDERS_PER_SECOND_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofSeconds(1)).limitForPeriod(10).build());
    registries.rateLimiters().rateLimiter(ORDERS_PER_DAY_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).timeoutDuration(Duration.ZERO).limitRefreshPeriod(Duration.ofDays(1)).limitForPeriod(200000).build());
    return registries;
}
Also used : ResilienceRegistries(org.knowm.xchange.client.ResilienceRegistries)

Example 3 with ResilienceRegistries

use of org.knowm.xchange.client.ResilienceRegistries in project XChange by knowm.

the class CoinbaseProResilience method createRegistries.

public static ResilienceRegistries createRegistries() {
    final ResilienceRegistries registries = new ResilienceRegistries();
    registries.rateLimiters().rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofSeconds(1)).limitForPeriod(10).drainPermissionsOnResult(e -> ResilienceUtils.matchesHttpCode(e, TOO_MANY_REQUESTS)).build());
    registries.rateLimiters().rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofSeconds(1)).limitForPeriod(15).drainPermissionsOnResult(e -> ResilienceUtils.matchesHttpCode(e, TOO_MANY_REQUESTS)).build());
    return registries;
}
Also used : ResilienceRegistries(org.knowm.xchange.client.ResilienceRegistries)

Example 4 with ResilienceRegistries

use of org.knowm.xchange.client.ResilienceRegistries in project XChange by knowm.

the class BitfinexResilience method createRegistries.

public static ResilienceRegistries createRegistries() {
    ResilienceRegistries registries = new ResilienceRegistries();
    registries.rateLimiters().rateLimiter(BITFINEX_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofMinutes(1)).limitForPeriod(90).build());
    return registries;
}
Also used : ResilienceRegistries(org.knowm.xchange.client.ResilienceRegistries)

Example 5 with ResilienceRegistries

use of org.knowm.xchange.client.ResilienceRegistries in project XChange by knowm.

the class KucoinResilience method createRegistries.

public static ResilienceRegistries createRegistries() {
    final ResilienceRegistries registries = new ResilienceRegistries();
    registries.rateLimiters().rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofSeconds(10)).limitForPeriod(30).drainPermissionsOnResult(e -> ResilienceUtils.matchesHttpCode(e, TOO_MANY_REQUESTS)).build());
    registries.rateLimiters().rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER, RateLimiterConfig.from(registries.rateLimiters().getDefaultConfig()).limitRefreshPeriod(Duration.ofSeconds(3)).limitForPeriod(30).drainPermissionsOnResult(e -> ResilienceUtils.matchesHttpCode(e, TOO_MANY_REQUESTS)).build());
    return registries;
}
Also used : ResilienceRegistries(org.knowm.xchange.client.ResilienceRegistries)

Aggregations

ResilienceRegistries (org.knowm.xchange.client.ResilienceRegistries)7