diff --git a/backend/pom.xml b/backend/pom.xml index 5ebb7f5..9734656 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -7,7 +7,7 @@ gameyfin de.grimsi - 1.0.0 + 1.0.1 gameyfin-backend @@ -131,6 +131,7 @@ + gameyfin-${project.parent.version} ${basedir}/src/main/resources diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/WebClientConfig.java b/backend/src/main/java/de/grimsi/gameyfin/config/WebClientConfig.java index cdc1b09..a91fe01 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/config/WebClientConfig.java +++ b/backend/src/main/java/de/grimsi/gameyfin/config/WebClientConfig.java @@ -5,7 +5,9 @@ import io.github.resilience4j.bulkhead.BulkheadConfig; import io.github.resilience4j.ratelimiter.RateLimiter; import io.github.resilience4j.ratelimiter.RateLimiterConfig; import io.netty.handler.logging.LogLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.reactive.function.client.WebClientCustomizer; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; @@ -20,24 +22,32 @@ import reactor.netty.transport.logging.AdvancedByteBufFormat; import java.time.Duration; @Slf4j +@Getter @Configuration public class WebClientConfig implements WebClientCustomizer { - // The IGDB API has a rate limit of 4 req/s - public static final RateLimiter IGDB_RATE_LIMITER = RateLimiter.of("igdb-rate-limiter", - RateLimiterConfig.custom() - .limitForPeriod(4) - .limitRefreshPeriod(Duration.ofSeconds(1)) - .timeoutDuration(Duration.ofMinutes(1)) - .build()); + private final RateLimiter igdbRateLimiter; + private final Bulkhead igdbConcurrencyLimiter; - // According to the docs, there is a maximum of 8 concurrent requests, but in my tests the actual limit was 4 - // and even then it sometimes failed, so I set it to 3 to be sure - public static final Bulkhead IGDB_CONCURRENCY_LIMITER = Bulkhead.of("igdb-concurrency-limiter", - BulkheadConfig.custom() - .maxConcurrentCalls(2) - .maxWaitDuration(Duration.ofMinutes(1)) - .build()); + + public WebClientConfig(@Value("${gameyfin.igdb.api.max-concurrent-requests}") int maxConcurrentRequestsToIgdb, + @Value("${gameyfin.igdb.api.max-requests-per-second}") int maxRequestsPerSecondToIgdb) { + + log.info("IGDB API connection properties: max. {} req/s, max. {} concurrent requests", maxRequestsPerSecondToIgdb, maxConcurrentRequestsToIgdb); + + igdbRateLimiter = RateLimiter.of("igdb-rate-limiter", + RateLimiterConfig.custom() + .limitForPeriod(maxRequestsPerSecondToIgdb) + .limitRefreshPeriod(Duration.ofSeconds(1)) + .timeoutDuration(Duration.ofMinutes(1)) + .build()); + + igdbConcurrencyLimiter = Bulkhead.of("igdb-concurrency-limiter", + BulkheadConfig.custom() + .maxConcurrentCalls(maxConcurrentRequestsToIgdb) + .maxWaitDuration(Duration.ofMinutes(1)) + .build()); + } @Override public void customize(WebClient.Builder webClientBuilder) { diff --git a/backend/src/main/java/de/grimsi/gameyfin/igdb/IgdbWrapper.java b/backend/src/main/java/de/grimsi/gameyfin/igdb/IgdbWrapper.java index 61868f0..26fe5ad 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/igdb/IgdbWrapper.java +++ b/backend/src/main/java/de/grimsi/gameyfin/igdb/IgdbWrapper.java @@ -38,6 +38,9 @@ public class IgdbWrapper { @Autowired private WebClient.Builder webclientBuilder; + @Autowired + private WebClientConfig webClientConfig; + private WebClient twitchApiClient; private WebClient igdbApiClient; @@ -173,8 +176,8 @@ public class IgdbWrapper { .bodyValue(query) .retrieve() .bodyToMono(responseClass) - .transformDeferred(BulkheadOperator.of(WebClientConfig.IGDB_CONCURRENCY_LIMITER)) - .transformDeferred(RateLimiterOperator.of(WebClientConfig.IGDB_RATE_LIMITER)) + .transformDeferred(BulkheadOperator.of(webClientConfig.getIgdbConcurrencyLimiter())) + .transformDeferred(RateLimiterOperator.of(webClientConfig.getIgdbRateLimiter())) .block(); } } diff --git a/backend/src/main/resources/config/gameyfin.properties b/backend/src/main/resources/config/gameyfin.properties index 048b187..776836d 100644 --- a/backend/src/main/resources/config/gameyfin.properties +++ b/backend/src/main/resources/config/gameyfin.properties @@ -14,8 +14,15 @@ gameyfin.db=${gameyfin.root}/.gameyfin/db # File extensions which gameyfin will recognize as game files gameyfin.file-extensions=iso, zip, rar, 7z, exe -# List of IGDB platform enums to limit search results. FOr possible values see: https://api-docs.igdb.com/#platform +# List of IGDB platform enums to limit search results. For possible values see: https://api-docs.igdb.com/#platform gameyfin.igdb.config.preferred-platforms=6 + # Twitch Client ID and Client Secret gameyfin.igdb.api.client-id= -gameyfin.igdb.api.client-secret= \ No newline at end of file +gameyfin.igdb.api.client-secret= + +# The IGDB API has a rate limit of 4 req/s +gameyfin.igdb.api.max-requests-per-second=4 + +# According to the docs, there is a maximum of 8 concurrent requests, but in my tests the actual limit was 4 and even then it sometimes failed, so I set it to 2 to be sure +gameyfin.igdb.api.max-concurrent-requests=2 \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6820593..a3cd74f 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "frontend", - "version": "0.0.1-SNAPSHOT", + "version": "@project.version@", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "frontend", - "version": "0.0.1-SNAPSHOT", + "version": "@project.version@", "dependencies": { "@angular/animations": "^14.0.0", "@angular/cdk": "^14.1.0", diff --git a/frontend/package.json b/frontend/package.json index 8b4d859..1a5a3a5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "0.0.1-SNAPSHOT", + "version": "@project.version@", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/frontend/pom.xml b/frontend/pom.xml index f53d4db..db25e89 100644 --- a/frontend/pom.xml +++ b/frontend/pom.xml @@ -5,7 +5,7 @@ gameyfin de.grimsi - 1.0.0 + 1.0.1 4.0.0 @@ -18,6 +18,13 @@ + + + ./dist/frontend + static + + + @@ -63,19 +70,12 @@ npm - run build --prod + run build --omit=dev - - - - ./dist/frontend - static - - diff --git a/pom.xml b/pom.xml index 57ab03d..dab9593 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.grimsi gameyfin - 1.0.0 + 1.0.1 gameyfin gameyfin