Reputation: 3497
I've create an application that has a web server and a ssh server that work together. At the moment the SSH server is a Singleton running in Play. So it is a play application running a SSH server in the background.
I would like that the ssh server doesn't depend 100% on the web part. It would also be nice that they can run on separate servers to make it easier to scale.
Since I am using Play(That is build on Akka) I think Actors are a nice solution. But how should this be implemented?
The web and non-web part both need some classes that are the same, example: They both need to have the User
class that can be send between the 2 applications. These have to be send over the Actors. But the web and non-web part are different things.
Is it possible to build the 2 projects into 1 project with different entry points? This way I can still use the same classes and they will serialize correctly when send over actors because they are exactly the same. Or is there a different/better way?
I've found this page in the Play documentation https://www.playframework.com/documentation/2.6.x/SBTSubProjects. But it is "Play first", I would like that both applications are able to run separately.
Upvotes: 0
Views: 117
Reputation: 2404
You can look at the sbt documentation for multi project builds
In your build.sbt
file you can create the following parts:
lazy val shared = (project in file("shared"))
lazy val ssh = (project in file("ssh"))
.dependsOn(shared)
lazy val http = (project in file("http"))
.enablePlugins(PlayScala)
.dependsOn(shared)
This way you will have shared code and separated parts. You could also add an other project that aggregates the ssh and http part into one project.
For communication between the two parts, you can use akka with remote actors
Upvotes: 2