Use Case for Database and akka actors


I have certain design issues. I can not change the main class and it's like the following:

object Main { ... implicit val schema = "schema" implicit val db= Database.forURL("url") val impl = new ImplA() val implB = new ImplB() system.actorOf(ActorA.props(impl, implB)) }

The implementation classes are like:

class ImplA(implicit val schema: String, db: Database) { val queryA = TableQuery[STable] def getData() = { ... db.run(query) } } class ImplB(implicit val schema: String, db: Database) { val queryB = TableQuery[BTable] def getDataB() = { ... db.run(query) } }

I am using slick and the table structures are like:

class BTable(tag: Tag)(implicit val schema: String) extends Table[CaseClass](tag, Some(schema), "table") { def a = column[String]("a") def b = column[String]("b") def * = (a,b).shaped <> (CaseClass.tupled, CaseClass.unapply) }

There are two problems that i need to solve:

<ol><li>PROBLEM 1 - I want to take the following lines out of actor and put it in ImplA or ImplB but it is a mixed query. So it i put it in ImplA then implB will not be available. And they are classes.</li> <li>PROBLEM 2-I totally want to eliminate the db and schema from Actor but have a use class where a class which is initialized from inside the actor requies the db implicitly.</li> </ol> class ActorA(implAa: ImplA, implB: ImplB)(implicit db: Database, schema: String) extends Actor { // PROBLEM 1 val query = (for { sc <- implAa c <- implB } yield(sc,c) db.run(query) // PROBLEM 2 new DemoClass(param).methodCall } class DemoClass(param: String)(implicit db: Database) { def methodCall = ... }

Without changing the main class, how can i address the problems? I can change Impls or table class make them trait or object or anything that can solve the issues.



  • How to run python commands using groovy in Jenkins slaves' Script Console?
  • Looping through elements in a struct in C for extracting value and datatype of the individual elemen
  • How to display image from http request to external API with Node.js
  • How can I delete an array from a plist using commitEditingStyle?
  • Calling 'ls' with execv
  • inserting to a local table from a linked stored procedure
  • Adding a binary file to resource in Visual Studio
  • How to create JSON from a dictionary in Swift 4?
  • Mapping a flat view to class hierarchy in fluent nHibernate
  • Can Java's JConsole be used to automatically configure memory?
  • How to create custom font family with bold font
  • Returning jint array from c to java through jni
  • Mapbox GL Popup .setDOMContent example
  • create magento 1.8 custom module
  • Read certain line in text file and display the next
  • Go Flush() doesn't work
  • How do I catch unhandled exceptions in ASP .NET Core 2.0 before the page is rendered?
  • How to build a TinyDB with values from CheckBox and TextBox in App Inventor2?
  • SQL Transpose row to columns
  • iOS notifications sporadic (FMX)
  • Start up error in App Engine - Jersey
  • Get All IP and Mac Address in lan
  • React Current Image in Image Gallery
  • Facebook like button redirect? [closed]
  • Webdriver 3.14 IE11: session lost when click link/button that opens a window/popup
  • javax.net.ssl.SSLException: SSL handshake aborted Connection reset by peer while calling webservice
  • Checking for valid enum types from protobufs
  • Add checkbox dynamically using angular 2
  • How to join two tables from different databases
  • how to run a different select statement based on condition in Hive SQL
  • How to define something in JavaScript [closed]
  • Neo4j…how to get a visual representation of my data?
  • Drag and drop unicode TText in DelphiXe4
  • Bitrate JWplayer
  • Accessing Arguments, Workflow Variables from custom activities