Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala Soundness scenario 9 to use mend/.within instead of try/catch #561

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions scala-soundness/src/main/scala/EasyRacerClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ def scenario8(scenarioUrl: Text => HttpUrl): Text raises HttpError raises Concur
supervise:
Seq(async(reqRes), async(reqRes)).race()

def scenario9(scenarioUrl: Text => HttpUrl): Text raises HttpError raises ConcurrencyError =
val url = scenarioUrl(t"9")
def scenario9(scenarioUrl: Text => HttpUrl): Text raises ConcurrencyError =
// Explicitly specify type so that it doesn't get inferred as `Text`
def req: Text raises HttpError = scenarioUrl(t"9").get().as[Text]
supervise:
Seq.fill(10):
async:
try url.get().as[Text]
catch case _ => t""
mend:
case HttpError(_, _) => t""
.within(req)
.map(System.nanoTime() -> _)
.sequence
.map(_.sortBy(_._1).map(_._2).reduce(_ + _))
Expand Down
Loading