Feature Request: Factory Methods for Akka Actors
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
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.
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")
- Dominant language
- Scala
- Stars
- 1.3k
- Forks
- 77
- Avg merge
- 9m
- Merged PRs (30d)
- 4
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.
More from softwaremill/macwire
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
softwaremill/macwire#412 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
softwaremill/macwire#391 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
softwaremill/macwire#301 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
softwaremill/macwire#281 · 5 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
softwaremill/macwire#278 · 3 comments ·
All issues in softwaremill/macwire
Similar issues
-
module: unknown type: bug/reported
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenXiangShan/XiangShan#6623 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ergoplatform/ergodocs#614 ·