-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* working version of new timed rules cache (cherry picked from commit 38841b6) * working changes for check in and check out (cherry picked from commit 941de6e) * tests passing (cherry picked from commit 6da9625) * code cleanup (cherry picked from commit 92abe63) * making rules object thread-safe (cherry picked from commit 6fd4275) * now clearing only tenant cache (cherry picked from commit e8897dd) * removing source of code smell (cherry picked from commit 7773c95) * moving reload to stand-alone endpoint (cherry picked from commit 7c54fd3) * working test of new endpoint (cherry picked from commit 24b7f9f) * code cleanup (cherry picked from commit 17d598f) * incorporating review comments (cherry picked from commit 9722702) * Reload rules when new rules are submitted (cherry picked from commit 83d9f8d) * Extract method for getting rules as text CIRC-1783 (cherry picked from commit 58ef216) * Reduce duplication when reloading rules CIRC-1783 (cherry picked from commit 69e9001) * incorporating review comments (cherry picked from commit 0f43b8c) * review feedback (cherry picked from commit 423d9d4) * adding logging to timer endpoint (cherry picked from commit 2639b21) * changing log level to debug (cherry picked from commit 9958e92) * removing completeablefuture (cherry picked from commit f3203c3) * fixing code smells * Update NEWS * [maven-release-plugin] prepare release v23.5.5 * [maven-release-plugin] prepare for next development iteration --------- Co-authored-by: felkerk <[email protected]> Co-authored-by: Marc Johnson <[email protected]>
- Loading branch information
1 parent
8e74b85
commit 491772d
Showing
11 changed files
with
170 additions
and
153 deletions.
There are no files selected for viewing
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
61 changes: 61 additions & 0 deletions
61
src/main/java/org/folio/circulation/resources/CirculationRulesReloadResource.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,61 @@ | ||
package org.folio.circulation.resources; | ||
|
||
import static org.folio.circulation.support.results.MappingFunctions.toFixedValue; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.folio.circulation.rules.cache.CirculationRulesCache; | ||
import org.folio.circulation.support.Clients; | ||
import org.folio.circulation.support.http.server.NoContentResponse; | ||
import org.folio.circulation.support.http.server.WebContext; | ||
import org.folio.circulation.support.results.CommonFailures; | ||
|
||
import io.vertx.core.http.HttpClient; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
/** | ||
* Write and read the circulation rules. | ||
*/ | ||
public class CirculationRulesReloadResource extends Resource { | ||
private final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass()); | ||
private final String rootPath; | ||
|
||
/** | ||
* Set the URL path. | ||
* @param rootPath URL path | ||
* @param client HTTP client | ||
*/ | ||
public CirculationRulesReloadResource(String rootPath, HttpClient client) { | ||
super(client); | ||
this.rootPath = rootPath; | ||
} | ||
|
||
/** | ||
* Register the path set in the constructor. | ||
* @param router where to register | ||
*/ | ||
@Override | ||
public void register(Router router) { | ||
router.post(rootPath).handler(this::reload); | ||
} | ||
|
||
private void reload(RoutingContext routingContext) { | ||
log.debug("reload:: starting reload of circulation rules"); | ||
final WebContext context = new WebContext(routingContext); | ||
CirculationRulesCache.getInstance().reloadRules(context.getTenantId(), | ||
Clients.create(context, client).circulationRulesStorage()) | ||
.thenApply(r -> { | ||
if(r.failed()) { | ||
log.debug("reload:: reload failed: {}", r.cause()); | ||
} else { | ||
log.debug("reload:: reload succeeded."); | ||
} | ||
return r.map(toFixedValue(NoContentResponse::noContent)); | ||
}) | ||
.exceptionally(CommonFailures::failedDueToServerError) | ||
.thenAccept(context::writeResultToHttpResponse); | ||
} | ||
} |
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.