Skip to content

Commit

Permalink
Fixed RD-15322: Report user-visible errors to caller instead of retry…
Browse files Browse the repository at this point in the history
…ing (#20)
  • Loading branch information
bgaidioz authored Feb 5, 2025
1 parent 9815010 commit 963bacb
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 177 deletions.
15 changes: 8 additions & 7 deletions src/main/scala/com/rawlabs/das/server/DASSdkManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,17 @@ class DASSdkManager(implicit settings: RawSettings) extends StrictLogging {
* @param dasId The DAS ID to retrieve.
* @return The DAS instance.
*/
def getDAS(dasId: DASId): DASSdk = {
def getDAS(dasId: DASId): Option[DASSdk] = {
// Pick the known config
val config = dasSdkConfigCacheLock.synchronized {
dasSdkConfigCache.getOrElseUpdate(
dasId,
getDASFromRemote(dasId).getOrElse(throw new IllegalArgumentException(s"DAS not found: $dasId"))
)
val maybeConfig = dasSdkConfigCacheLock.synchronized {
dasSdkConfigCache.get(dasId).orElse {
val remote = getDASFromRemote(dasId)
remote.foreach(config => dasSdkConfigCache.put(dasId, config))
remote
}
}
// Get the matching DAS from the cache
dasSdkCache.get(DASConfig(config.dasType, config.options))
maybeConfig.map(config => dasSdkCache.get(DASConfig(config.dasType, config.options)))
}

/**
Expand Down
Loading

0 comments on commit 963bacb

Please sign in to comment.