Package io.gorules.zen.loader
Class ApiDecisionLoader
java.lang.Object
io.gorules.zen.loader.ApiDecisionLoader
- All Implemented Interfaces:
DecisionLoader
Decision loader that fetches decisions from an HTTP API.
Supports flexible header configuration, caching, and automatic retries.
ApiLoaderConfig config = ApiLoaderConfig.builder("https://api.example.com/decisions")
.header("Authorization", "Bearer token123")
.header("X-Custom-Header", "value")
.timeout(Duration.ofSeconds(30))
.caching(true)
.build();
ApiDecisionLoader loader = new ApiDecisionLoader(config);
// Load decision from: GET https://api.example.com/decisions/pricing.json
CompletableFuture<JsonBuffer> decision = loader.load("pricing.json");
-
Constructor Summary
ConstructorsConstructorDescriptionApiDecisionLoader(ApiLoaderConfig config) Create a new ApiDecisionLoader with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the cache.voidEvict a specific decision from cache.Get the configuration for this loader.booleanCheck if a decision is cached.CompletableFuture<io.gorules.zen_engine.JsonBuffer> Load a decision by its key.
-
Constructor Details
-
ApiDecisionLoader
Create a new ApiDecisionLoader with the given configuration.- Parameters:
config- API loader configuration
-
-
Method Details
-
load
Description copied from interface:DecisionLoaderLoad a decision by its key.- Specified by:
loadin interfaceDecisionLoader- Parameters:
key- Decision key/filename- Returns:
- CompletableFuture with decision content as JsonBuffer
-
clearCache
public void clearCache()Clear the cache. -
evict
Evict a specific decision from cache.- Parameters:
key- Decision key
-
isCached
Check if a decision is cached.- Parameters:
key- Decision key- Returns:
- true if cached
-
getConfig
Get the configuration for this loader.- Returns:
- ApiLoaderConfig
-