Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
18 views

Multiple streamed response combined in a single iterator in Scala

I have multiple replicas of a service from which I am receiving a stream of response: // RPC call to server that returns a stream of response. def getResult(input: Request): Iterator[ResultItem] On ...
Kyuubi's user avatar
  • 1,228
0 votes
0 answers
51 views

Postgres, implement optimistic lock

I have multiple service instances, they compete for job execution. My goals a job must be assigned to one of service instances. service can't run more than 2 jobs at a time Here is my SQL query: ...
Capacytron's user avatar
  • 3,709
1 vote
0 answers
59 views

implementing mapAsync in scala

I'm trying to implement a mapAsync method for general sequences. Somehow it works when used independently, but it doesn't work when used inside a flatMap. Example code import akka.actor.ActorSystem ...
prongs's user avatar
  • 9,574
1 vote
1 answer
272 views

Scala Akka Quickstart: Java Version Mismatch and Compilation Error

I am relatively new to Scala and Akka, transitioning from a Java, Spring, and REST API background. Currently, I am working through the Akka Actors Quickstart with Scala tutorial. Upon attempting to ...
Kailash's user avatar
  • 89
0 votes
1 answer
50 views

Creating an empty Scala Future to be completed externally

Is it possible / how to create an empty Future, set the necessary callbacks for its completion, and then set its result at a different point in time? In pseudocode (uncompilable) that would look like ...
R A's user avatar
  • 273
1 vote
2 answers
455 views

When to use scala.concurrent.blocking?

I am asking myself the question: "When should you use scala.concurrent.blocking?" If I understood correctly, the blocking {} only makes sense to be used in conjunction with the ForkJoinPool. ...
Felix's user avatar
  • 1,207
0 votes
2 answers
188 views

How to demonstrate thread safety issue

A coworker told me this Cache object needs to be made thread-safe: import scala.collection.mutable object Cache { private val data = mutable.Map[Int, String]() def get(key: Int): Option[...
Big McLargeHuge's user avatar
0 votes
1 answer
240 views

Scala: Prevent race condition when performing some action after one Future fails out of a sequence of futures

I have a mutable list of futures: ArrayBuffer[Future[Seq[T]]] While my program is running, new Futures are added to that list over time, and complete on their own eventually. After each Future ...
B. Kwok's user avatar
  • 893
1 vote
1 answer
179 views

Scala thread safety

I'm running this code in Scala: def injectFunction(body: =>Unit): Thread = { val t = new Thread { override def run() = body } t } private var counter: Int = 0 def ...
matti1499's user avatar
-1 votes
1 answer
57 views

Why does my code not return query results?

Creating the database works. SQLite editor returns correct values. Yet, running below code does not return results. I added println("completed") to verify this part of code is reached: val ...
Ni3dzwi3dz's user avatar
-2 votes
1 answer
56 views

I am doing asynchronous processing with scala, but it is not displayed

import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future def now() = new java.util.Date(); (1 to 30).foreach(_ => Future{Thread.sleep(2000);println(now)}) I am ...
panda's user avatar
  • 11
2 votes
1 answer
145 views

Using Scala groupBy(), from method fetchUniqueCodesForARootCode(). I want to get a map from rootCodes to lists of uniqueCodes

I want to to return Future[Map[String, List[String]]] from fetchUniqueCodesForARootCode method import scala.concurrent._ import ExecutionContext.Implicits.global case class DiagnosisCode(...
Always_a_learner's user avatar
1 vote
1 answer
49 views

Return Future[List[DiagnosisCode]] from fetchDiagnosisForUniqueCodes method

I am not able to return Future[List[DiagnosisCode]] from fetchDiagnosisForUniqueCodes import scala.concurrent._ import ExecutionContext.Implicits.global case class DiagnosisCode(rootCode: String, ...
Always_a_learner's user avatar
0 votes
0 answers
47 views

Cleaning the resources in case of failure after applying Future.sequence

Suppose we have a class which allocates some resources on the heap, and creating it takes some time, so it's hidden behind the future class Container(val n: Int) { allocateMemoryOnTheHeap(n) def ...
delabania's user avatar
  • 804
0 votes
0 answers
189 views

How to fire N Requests per Second in Scala

I am developing an application in Scala, which is kind of request processor in batch. It gets the required data from storage and forms the request and calls an API of another service (named ServiceB) ...
Jeevi's user avatar
  • 2,992

15 30 50 per page
1
2 3 4 5
41