softwaremill / softwaremill/macwire
Feature Request: Factory Methods for Akka Actors
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.3k
- Forks
- 77
- Avg merge
- 9m
- Merged PRs (30d)
- 4
Description
If we want to use an alternative constructor for a regular class, we can use the wireWith function to select the factory that we want. It would be nice to have this functionality for akka actors as well, either via currying / partial application or factory functions.
For example:
import akka.actor.{Actor, ActorRef, ActorSystem}
class DatabaseAccess()
class UserFinderActor(configArg: Int, databaseAccess: DatabaseAccess) extends Actor {
override def receive: Receive = {
case m => // ...
}
}
object UserFinderActor {
def apply(configArg: Int)(databaseAccess: DatabaseAccess) = new UserFinderActor(configArg,databaseAccess)
}
import com.softwaremill.macwire._
import com.softwaremill.macwire.akkasupport._
val theDatabaseAccess = wire[DatabaseAccess]
val system = ActorSystem("actor-system")
val theUserFinder = wireActorWith(UserFinderActor(1) _)("userFinder")
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing wireWith functionality and the wireActorWith entry point in the Akka support API. Compare the proposed currying or factory-function approaches, then define a supported way to wire an actor with supplied constructor arguments and validate it against the UserFinderActor example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100