Skip to content

Commit

Permalink
feature/added futureWithLimits function - use 503 for ServiceIsTooBusy
Browse files Browse the repository at this point in the history
  • Loading branch information
hongwei1 committed Aug 24, 2023
1 parent 7fc63dc commit 6adb007
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions obp-api/src/main/scala/code/api/v3_0_0/APIMethods300.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import code.scope.Scope
import code.search.elasticsearchWarehouse
import code.users.Users
import code.util.Helper
import code.util.Helper.booleanToBox
import code.util.Helper.{booleanToBox, booleanToFuture}
import code.views.Views
import code.views.system.ViewDefinition
import com.github.dwickern.macros.NameOf.nameOf
Expand Down Expand Up @@ -2378,13 +2378,10 @@ trait APIMethods300 {
cc =>
for {
(_, callContext) <- anonymousAccess(cc)
(banks, callContext) <- if(canOpenFuture("NewStyle.function.getBanks")) {
FutureUtil.futureWithLimits(NewStyle.function.getBanks(callContext), "NewStyle.function.getBanks")
} else {
Future {
throw new RuntimeException(ServiceIsTooBusy +"Current Service(NewStyle.function.getBanks) ")
}
_ <- booleanToFuture(ServiceIsTooBusy +"Current Service(NewStyle.function.getBanks)", 503, callContext) {
canOpenFuture("NewStyle.function.getBanks")
}
(banks, callContext) <- FutureUtil.futureWithLimits(NewStyle.function.getBanks(callContext), "NewStyle.function.getBanks")
} yield
(JSONFactory300.createBanksJson(banks), HttpCode.`200`(callContext))
}
Expand Down

0 comments on commit 6adb007

Please sign in to comment.