-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw Exception on startup if bucket4j is enabled but no cache is con…
…figured. #262
- Loading branch information
1 parent
651b000
commit bf6a2e6
Showing
22 changed files
with
218 additions
and
76 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...main/java/com/giffing/bucket4j/spring/boot/starter/Bucket4jStartupCheckConfiguration.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,39 @@ | ||
package com.giffing.bucket4j.spring.boot.starter; | ||
|
||
import com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver; | ||
import com.giffing.bucket4j.spring.boot.starter.config.cache.Bucket4jCacheConfiguration; | ||
import com.giffing.bucket4j.spring.boot.starter.config.cache.SyncCacheResolver; | ||
import jakarta.annotation.Nullable; | ||
import jakarta.annotation.PostConstruct; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Configuration | ||
@AutoConfigureAfter( value = { | ||
CacheAutoConfiguration.class, | ||
Bucket4jCacheConfiguration.class | ||
}) | ||
@RequiredArgsConstructor | ||
public class Bucket4jStartupCheckConfiguration { | ||
|
||
|
||
@Nullable | ||
private final SyncCacheResolver syncCacheResolver; | ||
|
||
@Nullable | ||
private final AsyncCacheResolver asyncCacheResolver; | ||
|
||
|
||
@PostConstruct | ||
public void checkCache() { | ||
// TODO check filter configuration, check method configuration | ||
if(syncCacheResolver == null && asyncCacheResolver == null) { | ||
// TODO throw proper exception | ||
throw new IllegalStateException("cache not configured properly"); | ||
} | ||
} | ||
|
||
} |
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
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
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
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
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
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
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
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
Oops, something went wrong.