Overview
Doradilla-core
Doradilla-core is a job manage system which will handle the job request in reactive way.
Dependency
- sbt
libraryDependencies += "io.github.wherby" %% "doradilla-core" % "1.7.3.1"
- Maven
<dependency> <groupId>io.github.wherby</groupId> <artifactId>doradilla-core_2.12</artifactId> <version>1.7.3.1</version> </dependency>
- Gradle
dependencies { compile group: 'io.github.wherby', name: 'doradilla-core_2.12', version: '1.7.3.1' }
What’s the problem the library resolve?
The library provide a reactive way to handle resource consuming(CPU, Memory, DB connection) tasks.
For example, an OCR application which will trigger OCR tasks based on requests, for each OCR task there needs one CPU core occupied. If there is no implementation of job management, the CPUs will be easily taken by OCR jobs. The CPU competition will easily slow down the processing and block other function.
What’s the traditional way to solve the issue is create a job queue, and use a worker to takes job from the queue.
Is there any universal way to resolve this type of question and makes the implementation easy to use?
Yes, just use the Doradilla library.
How the Doradilla library works?
Simple version:
The Doradilla library use a queue to keep job requests and FSMActor will pull job request to process.
Is the same way as traditional way?
Yes, but not, because the user will not aware of the library implementation. The example shows user call the job api. The Doradilla library will handle the travail work.
Quick start
To use doradilla library to handle request see:
- run job sync
-
"start and run command " in { val backendServer = BackendServer.startup(Some(1600)) backendServer.registFSMActor() val msg = TestVars.processCallMsgTest val processJob = JobMsg("SimpleProcess", msg) val res = BackendServer.runProcessCommand(processJob).map { res => println(res) assert(true) } Await.ready(res, ConstVars.timeout1S * 10) }
- run job async
-
"start the command and qurey result " in { ProcessService.nameToClassOpt = ProcessServiceSpec.safeProcessServiceNameToClassOpt val backendServer = BackendServer.startup(Some(1600)) backendServer.registFSMActor() val msg = TestVars.processCallMsgTest val processJob = JobMsg("SimpleProcess", msg) val receiveActor = BackendServer.startProcessCommand(processJob).get val res= BackendServer.queryProcessResult(receiveActor).map { result => (result.result.asInstanceOf[ProcessResult]).jobStatus shouldBe (JobStatus.Finished) println(result) } Await.ready(res, ConstVars.timeout1S*4) }
For more usage see : BackendSpec.scala