-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa32310
commit c30d51d
Showing
9 changed files
with
67 additions
and
130 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
src/main/java/dev/rilling/musicbrainzenricher/api/BucketProvider.java
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
src/main/java/dev/rilling/musicbrainzenricher/api/BucketService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/dev/rilling/musicbrainzenricher/api/discogs/DiscogsApiConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.rilling.musicbrainzenricher.api.discogs; | ||
|
||
import dev.rilling.musicbrainzenricher.api.LoggingBucketListener; | ||
import io.github.bucket4j.Bandwidth; | ||
import io.github.bucket4j.Bucket; | ||
import net.jcip.annotations.ThreadSafe; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.env.Environment; | ||
|
||
import java.time.Duration; | ||
|
||
@Configuration | ||
@ThreadSafe | ||
class DiscogsApiConfiguration { | ||
|
||
@Bean("discogsBucket") | ||
Bucket discogsBucket(Environment environment) { | ||
boolean authenticated = environment.containsProperty("musicbrainz-enricher.discogs.token"); | ||
|
||
// See https://www.discogs.com/developers/#page:home,header:home-rate-limiting, | ||
// further slowed down to adapt for network fluctuations. | ||
int capacity = authenticated ? 60 : 25; | ||
Bandwidth bandwidth = Bandwidth.simple(capacity, Duration.ofSeconds(90)); | ||
|
||
return Bucket.builder().addLimit(bandwidth).build().toListenable(new LoggingBucketListener("discogs")); | ||
} | ||
} |
41 changes: 0 additions & 41 deletions
41
src/main/java/dev/rilling/musicbrainzenricher/api/discogs/DiscogsBucketProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/dev/rilling/musicbrainzenricher/api/spotify/SpotifyApiConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dev.rilling.musicbrainzenricher.api.spotify; | ||
|
||
import dev.rilling.musicbrainzenricher.api.LoggingBucketListener; | ||
import io.github.bucket4j.Bandwidth; | ||
import io.github.bucket4j.Bucket; | ||
import net.jcip.annotations.ThreadSafe; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.time.Duration; | ||
|
||
@Configuration | ||
@ThreadSafe | ||
class SpotifyApiConfiguration { | ||
|
||
@Bean("spotifyBucket") | ||
Bucket spotifyBucket() { | ||
// https://developer.spotify.com/documentation/web-api/guides/rate-limits/ | ||
// Spotify itself does not disclose an exact rate, this is only a guess to avoid running into it. | ||
Bandwidth bandwidth = Bandwidth.simple(10, Duration.ofMinutes(1)); | ||
|
||
return Bucket.builder().addLimit(bandwidth).build().toListenable(new LoggingBucketListener("spotify")); | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
src/main/java/dev/rilling/musicbrainzenricher/api/spotify/SpotifyBucketProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters